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

Merge branch 'master' of github.com:ChimeraTK/ApplicationCore

parents d555e3e8 72e412fb
No related branches found
No related tags found
No related merge requests found
......@@ -50,19 +50,18 @@ options exist (highest priority first):
constructor, the StatusAggregator has to be declared in user code after all
instances of `ChimeraTK::StatusMonitor` in a Module.
* Usage of `HierarchyModifier::moveToRoot` on a StatusAggregator is
controversial:
controversial (currently not allowed, see R2.2):
* Either: Detection of aggregated instances may take place from the virtual
hierarchy level of the original (C++) parent module downwards. The
Aggregator and its status output would then appear on the root level.
* Or: `HierarchyModifier::moveToRoot` is not allowd on StatusAggregators
* Or: `HierarchyModifier::moveToRoot` is not allowed on StatusAggregators
## Implementation ##
### Requirements ###
* **R2.1**: The detection of instances needs to be performed recursively from the StatusAggregator's virtual parent module on
* **R2.2**: The detection has to work on instances the are modified by any of
the `ChimeraTK::HierarchyModifier`s
* **R2.2**: The detection has to work on instances the are modified by `ChimeraTK::HierarchyModifier`s `none` and `hideThis`. Other modifiers should give a `ChimeraTK::logic_error`
### Constraints and issues ###
......
......@@ -169,12 +169,12 @@ namespace ChimeraTK {
bool rootReached{false};
do {
if(currentLevelModule == &Application::getInstance()) {
rootReached = true;
}
auto currentLevelModifier = currentLevelModule->getHierarchyModifier();
bool skipNextLevel{false};
switch(currentLevelModifier) {
case HierarchyModifier::none:
......@@ -185,13 +185,10 @@ namespace ChimeraTK {
break;
case HierarchyModifier::oneLevelUp:
virtualQualifiedName = "/" + currentLevelModule->getName() + virtualQualifiedName;
// Need to leave out to next level
// TODO This needs to catch the case that the mdifier is illegally used on the first level
currentLevelModule = dynamic_cast<const Module*>(currentLevelModule)->getOwner();
skipNextLevel = true;
break;
case HierarchyModifier::oneUpAndHide:
// Need to leave out to next level
currentLevelModule = dynamic_cast<const Module*>(currentLevelModule)->getOwner();
skipNextLevel = true;
break;
case HierarchyModifier::moveToRoot:
virtualQualifiedName =
......@@ -199,6 +196,16 @@ namespace ChimeraTK {
rootReached = true;
}
if(skipNextLevel) {
auto lastLevelModule = currentLevelModule;
currentLevelModule = dynamic_cast<const Module*>(currentLevelModule)->getOwner();
if(currentLevelModule == &Application::getInstance()) {
throw logic_error(std::string("Module ") + lastLevelModule->getName() +
": cannot have hierarchy modifier 'oneLevelUp' or oneUpAndHide in root of the application.");
}
}
if(!rootReached) {
currentLevelModule = dynamic_cast<const Module*>(currentLevelModule)->getOwner();
}
......
......@@ -67,10 +67,10 @@ struct OuterGroup : public ctk::ModuleGroup {
struct TestApplication : public ctk::Application {
TestApplication(ctk::HierarchyModifier outerModuleModifier,
ctk::HierarchyModifier innerGroupModifier = ctk::HierarchyModifier::none)
ctk::HierarchyModifier innerGroupModifier = ctk::HierarchyModifier::none, bool skipConnection = false)
: Application("testApp"), outerModuleGroup1{this, "outerModuleGroup1", "", ctk::HierarchyModifier::none,
innerGroupModifier},
outerModule{this, "outerModule", "", outerModuleModifier} {}
outerModule{this, "outerModule", "", outerModuleModifier}, _skipConnection{skipConnection} {}
~TestApplication() { shutdown(); }
OuterGroup outerModuleGroup1;
......@@ -79,9 +79,14 @@ struct TestApplication : public ctk::Application {
ctk::ControlSystemModule cs;
void defineConnections() {
findTag(".*").connectTo(cs);
// Tests for getVirtualQualifiedName require that findTag is not used globally,
// so it can be disabled
if(!_skipConnection) {
findTag(".*").connectTo(cs);
}
//cs.dump();
}
bool _skipConnection;
};
// Check if HierarchyModifiers are properly handled in the call to findTag
......@@ -156,6 +161,20 @@ BOOST_AUTO_TEST_CASE(testGetVirtualQualifiedName) {
BOOST_CHECK_EQUAL(app.outerModule.getVirtualQualifiedName(), "/testApp");
}
// Modifiers oneLevelUp and oneUpAndHide need to be catched by getVirtualQualifiedName, if used on
// the top level og the application. Note: If defineConnections uses findTag on the entire app,
// the error is catched there, this is avoided by the boolean constructor arguments below
{
TestApplication app(ctk::HierarchyModifier::oneLevelUp, ctk::HierarchyModifier::none, true);
ctk::TestFacility test;
BOOST_CHECK_THROW(app.outerModule.getVirtualQualifiedName(), ctk::logic_error);
}
{
TestApplication app(ctk::HierarchyModifier::oneUpAndHide, ctk::HierarchyModifier::none, true);
ctk::TestFacility test;
BOOST_CHECK_THROW(app.outerModule.getVirtualQualifiedName(), ctk::logic_error);
}
{
TestApplication app(ctk::HierarchyModifier::moveToRoot, ctk::HierarchyModifier::moveToRoot);
ctk::TestFacility test;
......
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