Commit b1ac52dd authored by Locatelli's avatar Locatelli

Add virtual inheritance for base classes *Properties in Count

(TimeCountProperties, KineticCountProperties...). That implied to add
init function and empty constructor in some classes.
parent 71259840
* Add virtual inheritance for base classes *Properties in Count (TimeCountProperties, KineticCountProperties...). That implied to add init function and empty constructor in some classes.
* Replaced protocol buffers array encoding with Xavier training's project to speed up the transfers.
* Implemented the logging of properties when set from the client. PropertyRefresher refactored: PropertyContainer is a new base class.
* Added protobuf messages and communication requests to manage icons at startup of tablet.
......
......@@ -105,11 +105,36 @@ AbstractController::ExecutionError::ExecutionError(const std::string& message) :
* Constructor
*/
AbstractController::AbstractController(const string& type, const string& name, const string& ID, const string& controllerType) :
m_Type(type), m_Name(name), m_ID(ID), m_ControllerType(controllerType), m_Enabled(false), m_PropertyManager(new PropertyManager(name)), m_CommandManager(new CommandManager(name)), m_ServantManager(new ServantManager(name)), m_Histogramming(true) {
m_PropertyManager(NULL), m_CommandManager(NULL), m_ServantManager(NULL) {
constructor(type, name, ID, controllerType);
}
/*
* Constructor
*/
AbstractController::AbstractController() :
m_PropertyManager(NULL), m_CommandManager(NULL), m_ServantManager(NULL) {
}
void AbstractController::constructor(const std::string& type, const std::string& name, const string& ID, const string& controllerType) {
m_Type = type;
m_Name = name;
m_ID = ID;
m_ControllerType = controllerType;
m_Enabled = false;
if (m_PropertyManager == NULL) {
m_PropertyManager = new PropertyManager(name);
}
if (m_CommandManager == NULL) {
m_CommandManager = new CommandManager(name);
}
if (m_ServantManager == NULL) {
m_ServantManager = new ServantManager(name);
}
m_Histogramming = true;
}
AbstractController::AbstractController(const AbstractController& controller) {
m_Type = controller.m_Type;
......
......@@ -128,6 +128,7 @@ public:
* Copy constructor.
*/
AbstractController(const AbstractController& controller);
AbstractController();
/**
* Destructor.
......@@ -552,6 +553,8 @@ public:
protected:
void constructor(const std::string& type, const std::string& name, const string& ID, const string& controllerType);
/**
* Registers the property.
*/
......
......@@ -37,6 +37,20 @@ public:
initCommand(commandName);
}
Command() :
m_controller(0),
m_commandName(""),
m_function(0) {
}
template<class ServantType>
void init(ExperimentController * controller, const std::string & commandName, void (ServantType::*f)(), ServantType * servant) {
m_controller = controller;
m_commandName = commandName;
m_function = new common::Function<void, ServantType>(f, servant);
initCommand(commandName);
}
virtual ~Command();
void execute();
......
......@@ -21,6 +21,10 @@
namespace controller {
Init::Init(ExperimentController * controller) : Command(controller, "init", &Init::init, this) {}
Init::Init() : Command() {}
void Init::init(ExperimentController * controller) {
Command::init(controller, "init", &Init::init, this);
}
void Init::initCommand(bool logging) {
// second parameter indicates that AgentPolicy is used to block the call
......
......@@ -27,6 +27,8 @@ class Init : private Command {
public:
Init(ExperimentController * controller);
Init();
void init(ExperimentController * controller);
virtual void init() = 0;
......
......@@ -22,5 +22,12 @@ namespace controller {
Pausable::Pausable(ExperimentController * controller) : Pause(controller), Resume(controller) {}
Pausable::Pausable() : Pause(), Resume() {}
void Pausable::init(ExperimentController * controller) {
Pause::init(controller);
Resume::init(controller);
}
}
......@@ -28,6 +28,8 @@ class Pausable : public Pause, public Resume {
public:
Pausable(ExperimentController * controller);
Pausable();
void init(ExperimentController * controller);
};
}
......
......@@ -22,6 +22,12 @@ namespace controller {
Pause::Pause(ExperimentController * controller) : Command(controller, "pause", &Pause::pause, this) {}
Pause::Pause() : Command() {}
void Pause::init(ExperimentController * controller) {
Command::init(controller, "pause", &Pause::pause, this);
}
void Pause::pauseCommand(bool logging) {
// second parameter indicates that AgentPolicy is used to block the call
// i.e. the call never blocks
......
......@@ -27,6 +27,8 @@ class Pause : private Command {
public:
Pause(ExperimentController * controller);
Pause();
void init(ExperimentController * controller);
virtual void pause() = 0;
......
......@@ -22,6 +22,12 @@ namespace controller {
Resume::Resume(ExperimentController * controller) : Command(controller, "continue", &Resume::resume, this) {}
Resume::Resume() : Command() {}
void Resume::init(ExperimentController * controller) {
Command::init(controller, "continue", &Resume::resume, this);
}
void Resume::resumeCommand(bool logging) {
// second parameter indicates that AgentPolicy is not used to block the call
// i.e. the call never blocks
......
......@@ -27,6 +27,8 @@ class Resume : private Command {
public:
Resume(ExperimentController * controller);
Resume();
void init(ExperimentController * controller);
virtual void resume() = 0;
......
......@@ -22,6 +22,12 @@ namespace controller {
Start::Start(ExperimentController * controller) : Command(controller, "start", &Start::start, this) {}
Start::Start() : Command() {}
void Start::init(ExperimentController * controller) {
Command::init(controller, "start", &Start::start, this);
}
void Start::startCommand(bool logging) {
// second parameter indicates that AgentPolicy is used to block the call
command(logging, true);
......
......@@ -27,6 +27,8 @@ class Start : private Command {
public:
Start(ExperimentController * controller);
Start();
void init(ExperimentController * controller);
virtual void start() = 0;
......
......@@ -22,6 +22,12 @@ namespace controller {
Stop::Stop(ExperimentController * controller) : Command(controller, "stop", &Stop::stop, this) {}
Stop::Stop() : Command() {}
void Stop::init(ExperimentController * controller) {
Command::init(controller, "stop", &Stop::stop, this);
}
void Stop::stopCommand(bool logging) {
// second parameter indicates that AgentPolicy is not used to block the call
// i.e. the call never blocks
......
......@@ -27,6 +27,8 @@ class Stop : private Command {
public:
Stop(ExperimentController * controller);
Stop();
void init(ExperimentController * controller);
virtual void stop() = 0;
......
......@@ -22,6 +22,12 @@ namespace controller {
StopAtEnd::StopAtEnd(ExperimentController * controller) : Command(controller, "stopatend", &StopAtEnd::stopAtEnd, this) {}
StopAtEnd::StopAtEnd() : Command() {}
void StopAtEnd::init(ExperimentController * controller) {
Command::init(controller, "stopatend", &StopAtEnd::stopAtEnd, this);
}
void StopAtEnd::stopAtEndCommand(bool logging) {
// second parameter indicates that AgentPolicy is not used to block the call
// i.e. the call never blocks
......
......@@ -27,6 +27,8 @@ class StopAtEnd : private Command {
public:
StopAtEnd(ExperimentController * controller);
StopAtEnd();
void init(ExperimentController * controller);
virtual void stopAtEnd() = 0;
......
......@@ -22,5 +22,12 @@ namespace controller {
Stoppable::Stoppable(ExperimentController * controller) : Start(controller), Stop(controller) {}
Stoppable::Stoppable() : Start(), Stop() {}
void Stoppable::init(ExperimentController * controller) {
Start::init(controller);
Stop::init(controller);
}
}
......@@ -28,6 +28,8 @@ class Stoppable : public Start, public Stop {
public:
Stoppable(ExperimentController * controller);
Stoppable();
void init(ExperimentController * controller);
};
}
......
......@@ -58,20 +58,29 @@ ExperimentController::ExperimentController(const string& type, const string& nam
}
ExperimentController::ExperimentController(const string& type, const string& name) :
AbstractController(type, name, "", EXPERIMENT_CONTROLLER_TYPE), m_NRequiredControllers(0), m_Configured(false), m_saved(true), m_module(0),
isCommand(this, SAVE, "isCommand"), nickname(this, SAVE, "nickname"), commandProgression(this, NOSAVE | SPY, "progression"),commandStatus(this, NOSAVE | SPY, "commandStatus"),
driverDisconnected(this, NOSAVE | SPY, "driver_disconnected") {
isCommand.update(false);
AbstractController(type, name, "", EXPERIMENT_CONTROLLER_TYPE) {
constructor(type, name);
}
registerFunction(EXPERIMENT_CONTROLLER);
ExperimentController::ExperimentController(const string& name) :
AbstractController("", name, "", EXPERIMENT_CONTROLLER_TYPE) {
constructor("", name);
}
registerRefresher(commandProgression, &ExperimentController::refreshProgression, this);
ExperimentController::ExperimentController() :
AbstractController() {
}
ExperimentController::ExperimentController(const string& name) :
AbstractController("", name, "", EXPERIMENT_CONTROLLER_TYPE), m_NRequiredControllers(0), m_Configured(false), m_saved(true), m_module(0),
isCommand(this, SAVE, "isCommand"), nickname(this, SAVE, "nickname"), commandProgression(this, NOSAVE | SPY, "progression"),commandStatus(this, NOSAVE | SPY, "commandStatus"),
driverDisconnected(this, NOSAVE | SPY, "driver_disconnected") {
void ExperimentController::constructor(const string& type, const string& name) {
m_NRequiredControllers = 0;
m_Configured = false;
m_saved = true;
m_module = 0;
isCommand.init(this, SAVE, "isCommand");
nickname.init(this, SAVE, "nickname");
commandProgression.init(this, NOSAVE | SPY, "progression");
commandStatus.init(this, NOSAVE | SPY, "commandStatus");
driverDisconnected.init(this, NOSAVE | SPY, "driver_disconnected");
isCommand.update(false);
registerFunction(EXPERIMENT_CONTROLLER);
......@@ -79,6 +88,11 @@ ExperimentController::ExperimentController(const string& name) :
registerRefresher(commandProgression, &ExperimentController::refreshProgression, this);
}
void ExperimentController::init(const string& name) {
AbstractController::constructor("", name, "", "");
constructor("", name);
}
ExperimentController::ExperimentController(const ExperimentController & controller) :
AbstractController(controller) {
m_RequiredControllers = controller.m_RequiredControllers;
......
......@@ -93,8 +93,11 @@ public:
};
ExperimentController(const ExperimentController & controller);
ExperimentController();
virtual ~ExperimentController();
void init(const std::string& name);
void setModule(Module * module);
Module * getModule() const;
......@@ -396,6 +399,8 @@ protected:
private:
void constructor(const std::string& type, const std::string& name);
void updateDisconnected();
AbstractController* findControllerWithName(const string& name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment