diff --git a/src/VariableMapper.cc b/src/VariableMapper.cc index e145b239c7edadff0d45e1129e924dd986e19f0d..1ef8af34024b59708a327e3ba2f86a8c3027b4a6 100644 --- a/src/VariableMapper.cc +++ b/src/VariableMapper.cc @@ -167,7 +167,12 @@ void print_node(const xmlpp::Node* node, unsigned int indentation = 0) const xmlpp::TextNode* nodeAsText = dynamic_cast<const xmlpp::TextNode*>(node); std::string importSource = nodeAsText->get_content(); std::cout << "Importing in location '"<<locationName <<"': " << importSource << std::endl; - + + // a slash will be added after the source, so we make the source empty for an import of everything + if (importSource == "/"){ + importSource = ""; + } + // loop source tree, cut beginning, replace / with _ and add a property for (auto const & processVariable : _inputVariables){ if (_inputSortedDescriptions.find(processVariable) != _inputSortedDescriptions.end()){ diff --git a/tests/src/testVariableMapper.cpp b/tests/src/testVariableMapper.cpp index 55c66defe8c8bbee9513a403ac78ede6accd91a0..68d2fac487228a43c76fa5281c31a40e2046031d 100644 --- a/tests/src/testVariableMapper.cpp +++ b/tests/src/testVariableMapper.cpp @@ -115,6 +115,26 @@ BOOST_AUTO_TEST_CASE( testImportAll ){ testXmlParsing("variableTreeXml/globalImportAndRename.xml", propertyMap); } +BOOST_AUTO_TEST_CASE( testImportIntoLocation ){ + std::map< std::string, VariableMapper::PropertyDescription > propertyMap( + { {"/A/a/di", {"MASTER","A.a.di"}}, + {"/A/a/do", {"MASTER","A.a.do"}}, + {"/A/b", {"MASTER","A.b"}}, + {"/B/a/dr", {"MASTER","B.a.dr"}}, + {"/B/c/de", {"MASTER","B.c.de"}}, + {"/B/c/gne", {"MASTER","B.c.gne"}}, + {"/C/a/da", {"MASTER","C.a.da"}}, + {"/C/b/ge", {"MASTER","C.b.ge"}}, + {"/C/c/be", {"MASTER","C.c.be"}}, + {"/C/c/de", {"MASTER","C.c.de"}}, + {"/DIRECT/DOUBLE", {"MASTER","DIRECT.DOUBLE"}}, + {"/DIRECT/DOUBLE_ARRAY", {"MASTER","DIRECT.DOUBLE_ARRAY"}}, + {"/DIRECT/INT", {"MASTER","DIRECT.INT"}}, + {"/DIRECT/INT_ARRAY", {"MASTER","DIRECT.INT_ARRAY"}} + }); + testXmlParsing("variableTreeXml/importAllIntoLocation.xml", propertyMap); +} + BOOST_AUTO_TEST_CASE( testImportTooShort ){ try{ testXmlParsing("variableTreeXml/globalImportPartTooShort.xml", {}); diff --git a/tests/variableTreeXml/importAllIntoLocation.xml b/tests/variableTreeXml/importAllIntoLocation.xml new file mode 100644 index 0000000000000000000000000000000000000000..05fff9762a4baf8c407b455a37f67450d1ebe32c --- /dev/null +++ b/tests/variableTreeXml/importAllIntoLocation.xml @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<device_server xmlns="https://github.com/ChimeraTK/ControlSystemAdapter-DoocsAdapter"> + <location name="MASTER"> + <import>/</import> + </location> +</device_server>