Commands: define basic properties of unbound CommandSetup

This commit is contained in:
Fischlurch 2017-03-18 03:20:05 +01:00
parent 4648703952
commit 833193342f
4 changed files with 67 additions and 8 deletions

View file

@ -55,6 +55,7 @@ namespace cmd {
// using std::string;
// using lib::Symbol;
using control::Command;
using control::CommandSetup;
//using std::shared_ptr;

View file

@ -36,6 +36,7 @@
#include "lib/error.hpp"
//#include "lib/symbol.hpp"
//#include "lib/format-string.hpp"
#include "proc/control/command-setup.hpp"
#include "proc/control/command-instance-manager.hpp"
//#include <string>
@ -60,9 +61,15 @@ namespace control {
/** storage for.... */
CommandSetup::~CommandSetup() { }
CommandSetup::CommandSetup(Literal cmdID)
: cmdID_(cmdID)
{ }
// emit dtors of embedded objects here....
CommandInstanceManager::~CommandInstanceManager() { }
CommandSetup::~CommandSetup() { }
CommandInstanceManager::CommandInstanceManager() { }

View file

@ -55,11 +55,11 @@
#include "lib/error.hpp"
#include "proc/control/command.hpp"
//#include "lib/symbol.hpp"
#include "lib/symbol.hpp"
//#include "proc/common.hpp"
#include <boost/noncopyable.hpp>
//#include <string>
#include <string>
@ -67,8 +67,9 @@
namespace proc {
namespace control {
// using std::string;
using std::string;
// using lib::Symbol;
using lib::Literal;
//using std::shared_ptr;
@ -77,15 +78,36 @@ namespace control {
* @todo write type comment
*/
class CommandSetup
: boost::noncopyable
{
Literal cmdID_;
public:
~CommandSetup();
CommandSetup (Literal cmdID);
CommandSetup (CommandSetup const&) = delete;
CommandSetup (CommandSetup &&) = default;
CommandSetup& operator= (CommandSetup const&) = delete;
operator Literal const&() const
{
return cmdID_;
}
operator string() const
{
return string{cmdID_};
}
private:
friend bool
operator== (CommandSetup const& left, CommandSetup const& right)
{
return left.cmdID_ == right.cmdID_;
}
friend bool
operator!= (CommandSetup const& left, CommandSetup const& right)
{
return left.cmdID_ != right.cmdID_;
}
};

View file

@ -31,6 +31,7 @@
//#include "lib/p.hpp"
//#include <cstdlib>
#include <string>
//using std::rand;
@ -43,6 +44,8 @@ namespace test {
//using lib::time::TimeVar;
//using lib::time::TimeValue;
//using lib::time::Offset;
using lib::Literal;
using std::string;
@ -78,7 +81,33 @@ namespace test {
void
verify_DefinitionSetup()
{
UNIMPLEMENTED("create CommandSetup instances");
// can be created from arbitrary character literal
CommandSetup def_empty{"to be or not to be"};
// at runtime it is nothing but a dressed-up C-string
Literal empty_text = def_empty;
CHECK (empty_text == "to be or not to be");
CHECK (sizeof(def_empty) == sizeof(Literal));
CHECK (sizeof(def_empty) == sizeof(char*));
const char* actualContent = reinterpret_cast<char*&>(def_empty);
CHECK (actualContent == empty_text);
// for convenience a string conversion is provided...
CHECK (string(def_empty) == string(empty_text));
// can be equality compared based on sting (ID) content
CHECK (def_empty == CommandSetup("to be or not to be"));
CHECK (def_empty != CommandSetup("to pee or not to pee"));
CommandSetup def_0{"test.CommandSetup.def_0"};
CommandSetup def_1{"test.CommandSetup.def_1"};
CommandSetup def_2{"test.CommandSetup.def_2"};
//////////// does not compile -- copy is prohibited...
// CommandSetup empty2{def_empty};
// def_empty = def_1;
}