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

allow adding tags in the module constructor

parent dd2c4502
No related branches found
No related tags found
No related merge requests found
......@@ -30,7 +30,7 @@ namespace ChimeraTK {
/** Constructor: register the EntityOwner with its owner */
EntityOwner(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy=false);
bool eliminateHierarchy=false, const std::unordered_set<std::string> &tags={});
/** Virtual destructor to make the type polymorphic */
virtual ~EntityOwner();
......@@ -72,6 +72,7 @@ namespace ChimeraTK {
/** Called inside the constructor of Accessor: adds the accessor to the list */
void registerAccessor(VariableNetworkNode accessor) {
for(auto &tag : _tags) accessor.addTag(tag);
accessorList.push_back(accessor);
}
......@@ -129,6 +130,9 @@ namespace ChimeraTK {
/** Flag whether this level of hierarchy should be eliminated or not */
bool _eliminateHierarchy{false};
/** List of tags to be added to all accessors and modules inside this module */
std::unordered_set<std::string> _tags;
};
} /* namespace ChimeraTK */
......
......@@ -19,10 +19,13 @@ namespace ChimeraTK {
public:
/** Constructor: register the module with its owner */
/** 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()). */
Module(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy=false);
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
......
......@@ -16,8 +16,8 @@
namespace ChimeraTK {
EntityOwner::EntityOwner(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy)
: _name(name), _description(description), _owner(owner), _eliminateHierarchy(eliminateHierarchy)
bool eliminateHierarchy, const std::unordered_set<std::string> &tags)
: _name(name), _description(description), _owner(owner), _eliminateHierarchy(eliminateHierarchy), _tags(tags)
{
if(owner != nullptr) {
auto thisMustBeAModule = static_cast<Module*>(this); /// @todo TODO FIXME this is a bit dangerous...
......@@ -37,6 +37,7 @@ namespace ChimeraTK {
/*********************************************************************************************************************/
void EntityOwner::registerModule(Module *module) {
for(auto &tag : _tags) module->addTag(tag);
moduleList.push_back(module);
}
......@@ -148,6 +149,7 @@ namespace ChimeraTK {
void EntityOwner::addTag(const std::string &tag) {
for(auto &node : getAccessorList()) node.addTag(tag);
for(auto &submodule : getSubmoduleList()) submodule->addTag(tag);
_tags.insert(tag);
}
/*********************************************************************************************************************/
......
......@@ -11,8 +11,8 @@
namespace ChimeraTK {
Module::Module(EntityOwner *owner, const std::string &name, const std::string &description,
bool eliminateHierarchy)
: EntityOwner(owner, name, description, eliminateHierarchy)
bool eliminateHierarchy, const std::unordered_set<std::string> &tags)
: EntityOwner(owner, name, description, eliminateHierarchy, tags)
{}
/*********************************************************************************************************************/
......
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