Skip to content
Snippets Groups Projects
Commit 499fa143 authored by Christoph Kampmeyer's avatar Christoph Kampmeyer
Browse files

wip #107: Detection of underlying instances:

Correctly navigate to parent module via virtual path.
parent ad850856
No related branches found
No related tags found
No related merge requests found
......@@ -3,82 +3,89 @@
#include <list>
#include <regex>
namespace ChimeraTK{
namespace ChimeraTK {
void StatusAggregator::populateStatusInput(){
std::cout << "Populating aggregator " << getName() << ", fully qualified name is: "
<< getQualifiedName() <<std::endl;
void StatusAggregator::populateStatusInput() {
std::cout << "Populating aggregator " << getName() << ", fully qualified name is: " << getQualifiedName()
<< std::endl;
// This does not work, we need to operate on the virtual hierarchy
//std::list<Module*> subModuleList{getOwner()->getSubmoduleList()};
// This approach crashes
// auto subModuleList = getOwner()->findTag(".*").getSubmoduleList();
// for(auto module : subModuleList){
// auto subModuleList = getOwner()->findTag(".*").getSubmoduleList();
// std::cout << "Testing Module " << module->getName() << std::endl;
// auto accList{module->getAccessorList()};
// }
// for(auto module : subModuleList){
// std::cout << "Testing Module " << module->getName() << std::endl;
// auto accList{module->getAccessorList()};
// }
// Another try, virtualise the entire Application
auto virtualApplicationHierarchy = Application::getInstance().findTag(".*");
auto virtualisedApplication = Application::getInstance().findTag(".*");
auto virtualPathToThis = getVirtualQualifiedName();
std::cout << " ** Fully qualified name in vitual hierarchy: "
//<< virtualApplicationHierarchy.getQualifiedName() << std::endl;
<< getVirtualQualifiedName() << std::endl;
// Split the name into individual modules
std::regex pathsepRegex{"/"};
std::sregex_token_iterator name{virtualPathToThis.begin(), virtualPathToThis.end(),
pathsepRegex, -1}, end;
// Remove application name and name of leaf node from the path
auto pathBegin = virtualPathToThis.find_first_not_of("/" + Application::getInstance().getName() + "/");
auto pathEnd = virtualPathToThis.find_last_of("/") - 1;
auto pathWithoutAppAndLeafNode{virtualPathToThis.substr(pathBegin, pathEnd - pathBegin + 1)};
++name; // Leave out first, empty match. FIXME: Should be avoided by regex
while(name != end){
std::cout << "Current path elem: " << *(name++) << std::endl;
std::list<VariableNetworkNode> allAccessors;
std::list<Module*> allSubmodules;
if(pathWithoutAppAndLeafNode == getName()) {
// Path to this module, the parent is the Application
allAccessors = virtualisedApplication.getAccessorListRecursive();
allSubmodules = virtualisedApplication.getSubmoduleListRecursive();
std::cout << "Parent is the Application" << std::endl;
}
else {
std::cout << "SubPath to this aggregator's parent : " << pathWithoutAppAndLeafNode << std::endl;
Module& virtualParent =
virtualisedApplication.submodule(virtualPathToThis.substr(pathBegin, pathEnd - pathBegin + 1));
// I can just call submodule instead of the above procedure
//Module& thisModule = virtualApplicationHierarchy.submodule(virtualPathToThis);
virtualParent.dump();
allAccessors = virtualParent.getAccessorListRecursive();
allSubmodules = virtualParent.getSubmoduleListRecursive();
}
// Works, as long as we do not use HIerarchyModifiers other than "none" in the test app
// Update: This still has problems, because getOwner gives us the "real" C++ Module
// We need to do everything on the virtual plane
// auto allAccessors{getOwner()->findTag(".*").getAccessorListRecursive()};
//auto allAccessors{virtualParent.getAccessorListRecursive()};
//auto allSubmodules{virtualParent.getSubmoduleListRecursive()};
// std::cout << " Size of allAccessors: " << allAccessors.size() << std::endl;
std::cout << " Size of allAccessors: " << allAccessors.size() << std::endl;
std::cout << " Size of allSubmodules: " << allSubmodules.size() << std::endl;
// for(auto acc : allAccessors){
for(auto acc : allAccessors) {
if(acc.getDirection().dir == VariableDirection::feeding) {
std::cout << " -- Accessor: " << acc.getName() << " of module: " << acc.getOwningModule()->getName()
<< std::endl;
}
}
// if(acc.getDirection().dir == VariableDirection::feeding){
// std::cout << " -- Accessor: " << acc.getName()
// << " of module: " << acc.getOwningModule()->getName()
// << std::endl;
// if(dynamic_cast<StatusMonitor*>(module)){
// std::cout << " Found Monitor " << module->getName() << std::endl;
// }
// else if(dynamic_cast<StatusAggregator*>(module)){
// std::string moduleName = module->getName();
// }
// if(dynamic_cast<StatusMonitor*>(module)){
// std::cout << " Found Monitor " << module->getName() << std::endl;
// }
// else if(dynamic_cast<StatusAggregator*>(module)){
// std::string moduleName = module->getName();
// std::cout << "Found Aggregator " << moduleName << std::endl;
// std::cout << "Found Aggregator " << moduleName << std::endl;
// statusInput.emplace_back(this, moduleName, "", "");
// }
// else if(dynamic_cast<ModuleGroup*>(module)){
// std::cout << "Found ModuleGroup " << module->getName() << std::endl;
// }
// else{}
// }
// statusInput.emplace_back(this, moduleName, "", "");
// }
// else if(dynamic_cast<ModuleGroup*>(module)){
// std::cout << "Found ModuleGroup " << module->getName() << std::endl;
// }
// else{}
// }
std::cout << std::endl << std::endl;
} // poplateStatusInput()*/
}
} // 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