Skip to content
Snippets Groups Projects
Commit aebf312b authored by Martin Christoph Hierholzer's avatar Martin Christoph Hierholzer
Browse files

introduced a ModuleGroup (grouping ApplicationModules and other ModuleGroups)...

introduced a ModuleGroup (grouping ApplicationModules and other ModuleGroups) and enforced a proper hierarchy of modules to exclude that an ApplicationModule can own (directly or indirectly) another ApplicationModule
parent 4bb23cd6
No related branches found
No related tags found
No related merge requests found
......@@ -17,4 +17,6 @@
#include "DeviceModule.h"
#include "ControlSystemModule.h"
#include "VariableGroup.h"
#include "ModuleGroup.h"
#include "VirtualModule.h"
#include "ApplicationException.h"
......@@ -15,13 +15,31 @@
#include "Module.h"
namespace ChimeraTK {
class Application;
class ModuleGroup;
class ApplicationModule : public Module {
public:
using Module::Module;
/** Constructor: register the module with its owner. If eliminateHierarchy is true, the hierarchy level
* introduced by this module will be eliminated from the "dynamic" data model (see
* EntityOwner::setEliminateHierarchy()). The tags given as the last argument are added to all variables
* in this module recursively (see EntityOwner::addTag()).
*
* Note: ApplicationModules may only be owned by ModuleGroups or Applications. */
ApplicationModule(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy=false, const std::unordered_set<std::string> &tags={});
/** Default constructor: Allows late initialisation of modules (e.g. when creating arrays of modules).
*
* This construtor also has to be here to mitigate a bug in gcc. It is needed to allow constructor
* inheritance of modules owning other modules. This constructor will not actually be called then.
* See this bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054 */
ApplicationModule() : Module(nullptr, "invalid", "invalid ApplicationModule") {}
/** Destructor */
virtual ~ApplicationModule();
......
/*
* ModuleGroup.h
*
* Created on: Aug 23, 2017
* Author: Martin Hierholzer
*/
#ifndef CHIMERATK_MODULE_GROUP_H
#define CHIMERATK_MODULE_GROUP_H
#include <list>
#include <boost/thread.hpp>
#include "Module.h"
namespace ChimeraTK {
class ModuleGroup : public Module {
public:
/** Constructor: register the ModuleGroup with its owner. If eliminateHierarchy is true, the hierarchy level
* introduced by this group will be eliminated from the "dynamic" data model (see
* EntityOwner::setEliminateHierarchy()). The tags given as the last argument are added to all variables
* in this module recursively (see EntityOwner::addTag()).
*
* Note: ModuleGroups may only be owned by the Application or other ModuleGroups. */
ModuleGroup(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy=false, const std::unordered_set<std::string> &tags={});
/** Default constructor: Allows late initialisation of VariableGroups (e.g. when creating arrays of
* VariableGroups).
*
* This construtor also has to be here to mitigate a bug in gcc. It is needed to allow constructor
* inheritance of modules owning other modules. This constructor will not actually be called then.
* See this bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054 */
ModuleGroup() : Module(nullptr, "invalid", "invalid VariableGroup") {}
/** Destructor */
virtual ~ModuleGroup() {};
/** Move operation with the assignment operator
@todo should be in the base class!? */
ModuleGroup& operator=(ModuleGroup &&rhs) {
_name = std::move(rhs._name);
_owner = std::move(rhs._owner);
accessorList = std::move(rhs.accessorList);
moduleList = std::move(rhs.moduleList);
return *this;
}
ModuleGroup& operator=(ModuleGroup &rhs) = delete;
};
} /* namespace ChimeraTK */
#endif /* CHIMERATK_MODULE_GROUP_H */
......@@ -15,12 +15,29 @@
#include "Module.h"
namespace ChimeraTK {
class ApplicationModule;
class VariableGroup : public Module {
public:
using Module::Module;
/** Constructor: register the VariableGroup with its owner. If eliminateHierarchy is true, the hierarchy level
* introduced by this group will be eliminated from the "dynamic" data model (see
* EntityOwner::setEliminateHierarchy()). The tags given as the last argument are added to all variables
* in this group recursively (see EntityOwner::addTag()).
*
* Note: VariableGroups may only be owned by ApplicationModules or other VariableGroups. */
VariableGroup(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy=false, const std::unordered_set<std::string> &tags={});
/** Default constructor: Allows late initialisation of VariableGroups (e.g. when creating arrays of
* VariableGroups).
*
* This construtor also has to be here to mitigate a bug in gcc. It is needed to allow constructor
* inheritance of modules owning other modules. This constructor will not actually be called then.
* See this bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67054 */
VariableGroup() : Module(nullptr, "invalid", "invalid VariableGroup") {}
/** Destructor */
virtual ~VariableGroup() {};
......
......@@ -5,11 +5,24 @@
* Author: Martin Hierholzer
*/
#include "ApplicationModule.h"
#include "Application.h"
#include "ApplicationCore.h"
namespace ChimeraTK {
/*********************************************************************************************************************/
ApplicationModule::ApplicationModule(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy, const std::unordered_set<std::string> &tags)
: Module(owner,name,description,eliminateHierarchy,tags)
{
if(!dynamic_cast<ModuleGroup*>(owner) && !dynamic_cast<Application*>(owner)) {
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalParameter>(
"ApplicationModules must be owned either by ModuleGroups or the Application!");
}
}
/*********************************************************************************************************************/
void ApplicationModule::run() {
// start the module thread
......
/*
* ModuleGroup.cc
*
* Created on: Aug 23, 2017
* Author: Martin Hierholzer
*/
#include "ApplicationCore.h"
namespace ChimeraTK {
ModuleGroup::ModuleGroup(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy, const std::unordered_set<std::string> &tags)
: Module(owner,name,description,eliminateHierarchy,tags)
{
if(!dynamic_cast<Application*>(owner) && !dynamic_cast<ModuleGroup*>(owner)) {
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalParameter>(
"ModuleGroups must be owned either by the Application or other ModuleGroups!");
}
}
} /* namespace ChimeraTK */
......@@ -5,12 +5,19 @@
* Author: Martin Hierholzer
*/
#include <mtca4u/TransferElement.h>
#include "Application.h"
#include "VariableGroup.h"
#include "ApplicationCore.h"
namespace ChimeraTK {
VariableGroup::VariableGroup(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy, const std::unordered_set<std::string> &tags)
: Module(owner,name,description,eliminateHierarchy,tags)
{
if(!dynamic_cast<ApplicationModule*>(owner) && !dynamic_cast<VariableGroup*>(owner)) {
throw ApplicationExceptionWithID<ApplicationExceptionID::illegalParameter>(
"VariableGroups must be owned either by ApplicationModule or other VariableGroups!");
}
}
} /* namespace ChimeraTK */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment