diff --git a/include/VariableMapper.h b/include/VariableMapper.h index cf8f32548d81739b26378aed946848d9edafd7e1..9301d39ce9850edbc8c8326a2d21f65f68a5b209 100644 --- a/include/VariableMapper.h +++ b/include/VariableMapper.h @@ -62,6 +62,8 @@ namespace ChimeraTK{ VariableMapper(VariableMapper &)=delete; void operator=(VariableMapper const &)=delete; + + void directImport(std::set< std::string > inputVariables); protected: VariableMapper()=default; diff --git a/src/VariableMapper.cc b/src/VariableMapper.cc index f457578774f3c89761104ae1715bc9d8bd9240e5..92bbf179115da7a902f6ec999bc07ad6d09457dc 100644 --- a/src/VariableMapper.cc +++ b/src/VariableMapper.cc @@ -167,6 +167,14 @@ namespace ChimeraTK{ return output; } + void VariableMapper::directImport(std::set< std::string > inputVariables){ + _inputVariables=inputVariables; + _locationDefaults.clear(); + _globalDefaults = PropertyAttributes(); + _inputSortedDescriptions.clear(); + + import("/",""); // import from /, create location names from first level of the tree + } } // namespace ChimeraTK diff --git a/tests/src/testVariableMapper.cpp b/tests/src/testVariableMapper.cpp index cedeecfde7302ac880cdddb4ef1f13e352b145e5..47bac1e58615ac2bdc892f34089989f1cee6269f 100644 --- a/tests/src/testVariableMapper.cpp +++ b/tests/src/testVariableMapper.cpp @@ -109,6 +109,11 @@ BOOST_AUTO_TEST_CASE( testImportAll ){ }); testXmlParsing("variableTreeXml/importAll.xml", propertyMap); + // test direct mapping without xml + VariableMapper & vm = VariableMapper::getInstance(); + vm.directImport( generateInputVariables()); + BOOST_CHECK( mapCompare( vm.getAllProperties(), propertyMap) ); + // modify the expected property map for the renaming case propertyMap["/DIRECT/DOUBLE"]= VariableMapper::PropertyDescription("DIRECT","BAR"); propertyMap["/DIRECT/INT"]= VariableMapper::PropertyDescription("DIRECT","FOO");