@@ -204,7 +204,14 @@ void Bundle::deleteInstance()
204204 instance = nullptr ;
205205}
206206
207- bool Bundle::initialize ()
207+ void Bundle::loadTaskConfigurations ()
208+ {
209+ std::vector<std::string> configs = findFilesByExtension (
210+ (fs::path (" config" ) / " orogen" ).string (), " .yml" );
211+ taskConfigurations.initialize (configs);
212+ }
213+
214+ bool Bundle::initialize (bool loadTaskConfigs)
208215{
209216 std::clog << " Initializing Bundles" << std::endl;
210217 activeBundles.clear ();
@@ -265,10 +272,10 @@ bool Bundle::initialize()
265272 std::clog << std::endl;
266273
267274 // Initialze TaskConfigurations
268- std::clog << " Loading task configuration files from bundle " << std::endl;
269- std::vector<std::string> configs = findFilesByExtension (
270- ( fs::path ( " config " ) / " orogen " ). string (), " .yml " );
271- taskConfigurations. initialize (configs);
275+ if (loadTaskConfigs){
276+ std::clog << " Loading task configuration files from bundle " << std::endl;
277+ loadTaskConfigurations ( );
278+ }
272279 std::clog << " Bundles successfully initialized" << std::endl;
273280
274281 return true ;
@@ -459,6 +466,12 @@ std::string Bundle::findBundle(const std::string &bundle_name)
459466}
460467
461468
469+ TaskConfigurations::TaskConfigurations ()
470+ : initialized(false )
471+ {
472+
473+ }
474+
462475void TaskConfigurations::initialize (const std::vector<std::string> &configFiles)
463476{
464477 taskConfigurations.clear ();
@@ -483,17 +496,24 @@ void TaskConfigurations::initialize(const std::vector<std::string> &configFiles)
483496 taskConfigurations.at (task).mergeConfigFile (cfgFile);
484497 }
485498 }
499+ initialized = true ;
486500}
487501
488502Configuration TaskConfigurations::getConfig (const std::string &taskModelName,
489503 const std::vector<std::string> §ions)
490504{
505+ if (!initialized){
506+ throw std::runtime_error (" TaskConfiguration::getConfig was called, but TaskConfiguratuion was not initilized." );
507+ }
491508 MultiSectionConfiguration& mcfg = taskConfigurations.at (taskModelName);
492509 Configuration cfg = mcfg.getConfig (sections);
493510 return cfg;
494511}
495512
496513const MultiSectionConfiguration &TaskConfigurations::getMultiConfig (const std::string &taskModelName)
497514{
515+ if (!initialized){
516+ throw std::runtime_error (" TaskConfiguration::getMultiConfig was called, but TaskConfiguratuion was not initilized." );
517+ }
498518 return taskConfigurations.at (taskModelName);
499519}
0 commit comments