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

prevent readAll() etc. functions to recurse into submodules with their own thread

parent 5a45fa82
No related branches found
No related tags found
No related merge requests found
...@@ -54,8 +54,11 @@ namespace ChimeraTK { ...@@ -54,8 +54,11 @@ namespace ChimeraTK {
/** Obtain the list of submodules associated with this instance */ /** Obtain the list of submodules associated with this instance */
const std::list<Module*>& getSubmoduleList() const { return moduleList; } const std::list<Module*>& getSubmoduleList() const { return moduleList; }
/** Obtain the list of accessors/variables associated with this instance and any submodules */ /** Obtain the list of accessors/variables associated with this instance and any variable groups. If the optional
std::list<VariableNetworkNode> getAccessorListRecursive(); * argument is set to true, also submodules (which have their own thread) are included. In that case, the
* accessors in the returned list may not be used (i.e. write or read data or initiate transfers) from the same
* thread and only connections may be registered between the accessors. */
std::list<VariableNetworkNode> getAccessorListRecursive(bool includeSubmodules = false);
/** Obtain the list of submodules associated with this instance and any submodules */ /** Obtain the list of submodules associated with this instance and any submodules */
std::list<Module*> getSubmoduleListRecursive(); std::list<Module*> getSubmoduleListRecursive();
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "EntityOwner.h" #include "EntityOwner.h"
#include "Module.h" #include "Module.h"
#include "VirtualModule.h" #include "VirtualModule.h"
#include "VariableGroup.h"
namespace ChimeraTK { namespace ChimeraTK {
...@@ -49,13 +50,17 @@ namespace ChimeraTK { ...@@ -49,13 +50,17 @@ namespace ChimeraTK {
/*********************************************************************************************************************/ /*********************************************************************************************************************/
std::list<VariableNetworkNode> EntityOwner::getAccessorListRecursive() { std::list<VariableNetworkNode> EntityOwner::getAccessorListRecursive(bool includeSubmodules) {
// add accessors of this instance itself // add accessors of this instance itself
std::list<VariableNetworkNode> list = getAccessorList(); std::list<VariableNetworkNode> list = getAccessorList();
// iterate through submodules // iterate through submodules
for(auto submodule : getSubmoduleList()) { for(auto submodule : getSubmoduleList()) {
auto sublist = submodule->getAccessorListRecursive(); // ignore anything that is not a VariableGroup if submodules should not be included
/// @todo Add test for this!
if(!includeSubmodules && dynamic_cast<VariableGroup*>(submodule) == nullptr) continue;
// obtail list of accessors from the submodule/group and insert it into the list
auto sublist = submodule->getAccessorListRecursive(includeSubmodules);
list.insert(list.end(), sublist.begin(), sublist.end()); list.insert(list.end(), sublist.begin(), sublist.end());
} }
return list; return list;
...@@ -156,7 +161,7 @@ namespace ChimeraTK { ...@@ -156,7 +161,7 @@ namespace ChimeraTK {
VirtualModule EntityOwner::flatten() { VirtualModule EntityOwner::flatten() {
VirtualModule nextmodule{_name, _description}; VirtualModule nextmodule{_name, _description};
for(auto &node : getAccessorListRecursive()) { for(auto &node : getAccessorListRecursive(true)) {
nextmodule.registerAccessor(node); nextmodule.registerAccessor(node);
} }
return nextmodule; return nextmodule;
......
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