@@ -403,53 +403,72 @@ namespace RTC
403
403
RTC_TRACE ((" Manager::load(fname = %s, initfunc = %s)" ,
404
404
fname.c_str (), initfunc.c_str ()));
405
405
406
- std::string file_name (fname);
406
+ coil::Properties prop;
407
+ prop[" module_file_name" ] = fname;
408
+
409
+ return load (prop, initfunc);
410
+ }
411
+
412
+ /* !
413
+ * @if jp
414
+ * @brief モジュールのロード
415
+ * @else
416
+ * @brief Load module
417
+ * @endif
418
+ */
419
+ ReturnCode_t Manager::load (coil::Properties &prop,
420
+ const std::string &initfunc)
421
+ {
422
+ RTC_TRACE ((" Manager::load(filename = %s, filepath = %s, language = %s, initfunc = %s)" ,
423
+ prop[" module_file_name" ].c_str (), prop[" module_file_path" ].c_str (), prop[" language" ].c_str (), initfunc.c_str ()));
424
+
425
+ std::string file_name (prop[" module_file_name" ]);
407
426
std::string init_func (initfunc);
408
427
m_listeners.module_ .preLoad (file_name, init_func);
409
428
try
429
+ {
430
+ if (init_func.empty ())
410
431
{
411
- if (init_func.empty ())
412
- {
413
- if (coil::isAbsolutePath (file_name))
414
- {
415
- coil::vstring mod (coil::split (file_name, " /" ));
416
- mod = coil::split (mod.back (), " \\ " );
417
- mod = coil::split (mod.back (), " ." );
418
- init_func = mod[0 ] + " Init" ;
419
- }
420
- else
421
- {
422
- coil::vstring mod (coil::split (file_name, " ." ));
423
- init_func = mod[0 ] + " Init" ;
424
- }
425
- }
426
- std::string path (m_module->load (file_name, init_func));
427
- RTC_DEBUG ((" module path: %s" , path.c_str ()));
428
- m_listeners.module_ .postLoad (path, init_func);
429
- }
430
- catch (RTC::ModuleManager::NotAllowedOperation& e)
431
- {
432
- RTC_ERROR ((" Operation not allowed: %s" ,
433
- e.reason .c_str ()));
434
- return RTC::PRECONDITION_NOT_MET;
435
- }
436
- catch (RTC::ModuleManager::NotFound& e)
437
- {
438
- RTC_ERROR ((" Not found: %s" ,
439
- e.name .c_str ()));
440
- return RTC::RTC_ERROR;
441
- }
442
- catch (RTC::ModuleManager::InvalidArguments& e)
443
- {
444
- RTC_ERROR ((" Invalid argument: %s" ,
445
- e.reason .c_str ()));
446
- return RTC::BAD_PARAMETER;
447
- }
448
- catch (RTC::ModuleManager::Error& e)
449
- {
450
- RTC_ERROR ((" Error: %s" , e.reason .c_str ()));
451
- return RTC::RTC_ERROR;
432
+ if (coil::isAbsolutePath (file_name))
433
+ {
434
+ coil::vstring mod (coil::split (file_name, " /" ));
435
+ mod = coil::split (mod.back (), " \\ " );
436
+ mod = coil::split (mod.back (), " ." );
437
+ init_func = mod[0 ] + " Init" ;
438
+ }
439
+ else
440
+ {
441
+ coil::vstring mod (coil::split (file_name, " ." ));
442
+ init_func = mod[0 ] + " Init" ;
443
+ }
452
444
}
445
+ std::string path (m_module->load (prop, init_func));
446
+ RTC_DEBUG ((" module path: %s" , path.c_str ()));
447
+ m_listeners.module_ .postLoad (path, init_func);
448
+ }
449
+ catch (RTC::ModuleManager::NotAllowedOperation &e)
450
+ {
451
+ RTC_ERROR ((" Operation not allowed: %s" ,
452
+ e.reason .c_str ()));
453
+ return RTC::PRECONDITION_NOT_MET;
454
+ }
455
+ catch (RTC::ModuleManager::NotFound &e)
456
+ {
457
+ RTC_ERROR ((" Not found: %s" ,
458
+ e.name .c_str ()));
459
+ return RTC::RTC_ERROR;
460
+ }
461
+ catch (RTC::ModuleManager::InvalidArguments &e)
462
+ {
463
+ RTC_ERROR ((" Invalid argument: %s" ,
464
+ e.reason .c_str ()));
465
+ return RTC::BAD_PARAMETER;
466
+ }
467
+ catch (RTC::ModuleManager::Error &e)
468
+ {
469
+ RTC_ERROR ((" Error: %s" , e.reason .c_str ()));
470
+ return RTC::RTC_ERROR;
471
+ }
453
472
catch (...)
454
473
{
455
474
RTC_ERROR ((" Unknown error." ));
@@ -687,30 +706,31 @@ std::vector<coil::Properties> Manager::getLoadableModules()
687
706
std::vector<coil::Properties> mp (m_module->getLoadableModules ());
688
707
RTC_INFO ((" %d loadable modules found" , mp.size ()));
689
708
690
- std::vector<coil::Properties>::iterator it;
691
- it = std::find_if (mp.begin (), mp.end (), ModulePredicate (comp_id));
692
- if (it == mp.end ())
693
- {
694
- RTC_ERROR ((" No module for %s in loadable modules list" ,
695
- comp_id[" implementation_id" ].c_str ()));
696
- return nullptr ;
697
- }
698
- if (it->findNode (" module_file_path" ) == nullptr )
699
- {
700
- RTC_ERROR ((" Hmm...module_file_path key not found." ));
701
- return nullptr ;
702
- }
703
- // module loading
704
- RTC_INFO ((" Loading module: %s" , (*it)[" module_file_path" ].c_str ()));
705
- load ((*it)[" module_file_path" ], " " );
706
- factory = m_factory.find (comp_id);
707
- if (factory == nullptr )
708
- {
709
- RTC_ERROR ((" Factory not found for loaded module: %s" ,
710
- comp_id[" implementation_id" ].c_str ()));
711
- return nullptr ;
712
- }
709
+ std::vector<coil::Properties>::iterator it;
710
+ it = std::find_if (mp.begin (), mp.end (), ModulePredicate (comp_id));
711
+ if (it == mp.end ())
712
+ {
713
+ RTC_ERROR ((" No module for %s in loadable modules list" ,
714
+ comp_id[" implementation_id" ].c_str ()));
715
+ return nullptr ;
713
716
}
717
+ if (it->findNode (" module_file_path" ) == nullptr )
718
+ {
719
+ RTC_ERROR ((" Hmm...module_file_path key not found." ));
720
+ return nullptr ;
721
+ }
722
+ // module loading
723
+ RTC_INFO ((" Loading module: %s" , (*it)[" module_file_path" ].c_str ()));
724
+ load ((*it), " " );
725
+ factory = m_factory.find (comp_id);
726
+ if (factory == nullptr )
727
+ {
728
+ RTC_ERROR ((" Factory not found for loaded module: %s" ,
729
+ comp_id[" implementation_id" ].c_str ()));
730
+ return nullptr ;
731
+ }
732
+
733
+ }
714
734
715
735
coil::Properties prop;
716
736
prop = factory->profile ();
0 commit comments