Manager.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
19 #include <rtm/Manager.h>
20 #include <rtm/ManagerConfig.h>
21 #include <rtm/ModuleManager.h>
22 #include <rtm/CorbaNaming.h>
23 #include <rtm/NamingManager.h>
24 #include <rtm/RTC.h>
29 #include <rtm/RTCUtil.h>
30 #include <rtm/ManagerServant.h>
31 #include <fstream>
32 #include <iostream>
33 #include <coil/Properties.h>
34 #include <coil/stringutil.h>
35 #include <coil/Signal.h>
36 #include <coil/TimeValue.h>
37 #include <coil/Timer.h>
38 #include <coil/OS.h>
39 #include <rtm/FactoryInit.h>
40 #include <rtm/CORBA_IORUtil.h>
42 
43 #if defined(minor)
44 #undef minor
45 #endif
46 
47 //static sig_atomic_t g_mgrActive = true;
48 extern "C" void handler (int)
49 {
51 }
52 
53 namespace RTC
54 {
55  Manager* Manager::manager = NULL;
57 
59  : m_name(comp->getInstanceName())
60  {}
62  : m_name(name)
63  {}
64  Manager::InstanceName::InstanceName(const std::string name)
65  : m_name(name)
66  {}
68  {
69  return m_name == comp->getInstanceName();
70  }
71 
72 
81  : m_initProc(0), m_namingManager(0), m_timer(0),
83  m_runner(0), m_terminator(0)
84  {
86  }
87 
96  : m_initProc(0), m_namingManager(0), m_timer(0),
98  m_runner(0), m_terminator(0)
99  {
101  }
102 
110  Manager* Manager::init(int argc, char** argv)
111  {
112  // DCL for singleton
113  if (!manager)
114  {
115  Guard guard(mutex);
116  if (!manager)
117  {
118  manager = new Manager();
119  manager->initManager(argc, argv);
120  manager->initLogger();
121  manager->initORB();
122  manager->initNaming();
126  manager->initTimer();
128  }
129  }
130  return manager;
131  }
132 
141  {
142  // DCL for singleton
143  if (!manager)
144  {
145  Guard guard(mutex);
146  if (!manager)
147  {
148  manager = new Manager();
149  manager->initManager(0, NULL);
150  manager->initLogger();
151  manager->initORB();
152  manager->initNaming();
156  manager->initTimer();
157  }
158  }
159  return *manager;
160  }
161 
170  {
171  if (m_terminator != NULL)
173  }
174 
183  {
184  RTC_TRACE(("Manager::shutdown()"));
186  shutdownNaming();
187  shutdownORB();
188  shutdownManager();
189  // 終了待ち合わせ
190  if (m_runner != NULL)
191  {
192  m_runner->wait();
193  }
194  else
195  {
196  join();
197  }
198  shutdownLogger();
199  }
200 
209  {
210  RTC_TRACE(("Manager::wait()"));
211  {
212  Guard guard(m_terminate.mutex);
214  }
215  while (1)
216  {
217  {
218  Guard guard(m_terminate.mutex);
219  if (m_terminate.waiting > 1) break;
220  }
221  coil::usleep(100000);
222  }
223  }
224 
233  {
234  m_initProc = proc;
235  }
236 
245  {
246  RTC_TRACE(("Manager::activateManager()"));
247 
248  try
249  {
250  if(CORBA::is_nil(this->getPOAManager()))
251  {
252  RTC_ERROR(("Could not get POA manager."));
253  return false;
254  }
255  this->getPOAManager()->activate();
256  RTC_TRACE(("POA Manager activated."));
257  }
258  catch (...)
259  {
260  RTC_ERROR(("POA Manager activatatin failed."));
261  return false;
262  }
263 
264  std::vector<std::string> mods;
265  mods = coil::split(m_config["manager.modules.preload"], ",");
266 
267  for (int i(0), len(mods.size()); i < len; ++i)
268  {
269  std::string basename(coil::split(mods[i], ".").operator[](0));
270  basename += "Init";
271  try
272  {
273  m_module->load(mods[i], basename);
274  }
275  catch (ModuleManager::Error& e)
276  {
277  RTC_ERROR(("Module load error: %s", e.reason.c_str()));
278  }
280  {
281  RTC_ERROR(("Symbol not found: %s", e.name.c_str()));
282  }
284  {
285  RTC_ERROR(("Module not found: %s", e.name.c_str()));
286  }
287  catch (...)
288  {
289  RTC_ERROR(("Unknown Exception"));
290  }
291  }
292 
293  m_config["sdo.service.consumer.available_services"]
295 
296  if (m_initProc != NULL)
297  {
298  m_initProc(this);
299  }
300 
301  std::vector<std::string> comp;
302  comp = coil::split(m_config["manager.components.precreate"], ",");
303  for (int i(0), len(comp.size()); i < len; ++i)
304  {
305  this->createComponent(comp[i].c_str());
306  }
307 
308  return true;
309  }
310 
318  void Manager::runManager(bool no_block)
319  {
320  if (no_block)
321  {
322  RTC_TRACE(("Manager::runManager(): non-blocking mode"));
323  m_runner = new OrbRunner(m_pORB);
324  m_runner->open(0);
325  }
326  else
327  {
328  RTC_TRACE(("Manager::runManager(): blocking mode"));
329  m_pORB->run();
330  RTC_TRACE(("Manager::runManager(): ORB was terminated"));
331  join();
332  }
333  return;
334  }
335 
336  //============================================================
337  // Module management
338  //============================================================
346  void Manager::load(const char* fname, const char* initfunc)
347  {
348  RTC_TRACE(("Manager::load(fname = %s, initfunc = %s)",
349  fname, initfunc));
350  std::string file_name(fname);
351  std::string init_func(initfunc);
352  try
353  {
354  if (init_func.empty())
355  {
356  coil::vstring mod(coil::split(fname, "."));
357  init_func = mod[0] + "Init";
358  }
359  std::string path(m_module->load(file_name, init_func));
360  RTC_DEBUG(("module path: %s", path.c_str()));
361  }
362  catch (...)
363  {
364  RTC_ERROR(("module load error."));
365  }
366  return;
367  }
368 
376  void Manager::unload(const char* fname)
377  {
378  RTC_TRACE(("Manager::unload()"));
379  m_module->unload(fname);
380  return;
381  }
382 
391  {
392  RTC_TRACE(("Manager::unloadAll()"));
393  m_module->unloadAll();
394  return;
395  }
396 
404  std::vector<coil::Properties> Manager::getLoadedModules()
405  {
406  RTC_TRACE(("Manager::getLoadedModules()"));
407  return m_module->getLoadedModules();
408  }
409 
417 std::vector<coil::Properties> Manager::getLoadableModules()
418  {
419  RTC_TRACE(("Manager::getLoadableModules()"));
420  return m_module->getLoadableModules();
421  }
422 
423  //============================================================
424  // Component factory management
425  //============================================================
434  RtcNewFunc new_func,
435  RtcDeleteFunc delete_func)
436  {
437  RTC_TRACE(("Manager::registerFactory(%s)", profile["type_name"].c_str()));
438  FactoryBase* factory;
439  factory = new FactoryCXX(profile, new_func, delete_func);
440  try
441  {
442  bool ret = m_factory.registerObject(factory);
443  if (!ret) {
444  delete factory;
445  return false;
446  }
447  return true;
448  }
449  catch (...)
450  {
451  delete factory;
452  return false;
453  }
454  }
455 
456  std::vector<coil::Properties> Manager::getFactoryProfiles()
457  {
458  std::vector<FactoryBase*> factories(m_factory.getObjects());
459  std::vector<coil::Properties> props;
460  for (int i(0), len(factories.size()); i < len; ++i)
461  {
462  props.push_back(factories[i]->profile());
463  }
464  return props;
465  }
466 
474  bool Manager::registerECFactory(const char* name,
475  ECNewFunc new_func,
476  ECDeleteFunc delete_func)
477  {
478  RTC_TRACE(("Manager::registerECFactory(%s)", name));
479  try
480  {
481  ECFactoryBase* factory;
482  factory = new ECFactoryCXX(name, new_func, delete_func);
483  if(m_ecfactory.registerObject(factory))
484  {
485  return true;
486  }
487  }
488  catch (...)
489  {
490  return false;
491  }
492  return false;
493  }
494 
502  std::vector<std::string> Manager::getModulesFactories()
503  {
504  RTC_TRACE(("Manager::getModulesFactories()"));
505 
506  ModuleFactories m;
507  return m_factory.for_each(m).modlist;
508  }
509 
510  //============================================================
511  // Component management
512  //============================================================
520  RTObject_impl* Manager::createComponent(const char* comp_args)
521  {
522  RTC_TRACE(("Manager::createComponent(%s)", comp_args));
523  //------------------------------------------------------------
524  // extract "comp_type" and "comp_prop" from comp_arg
525  coil::Properties comp_prop, comp_id;
526  if (!procComponentArgs(comp_args, comp_id, comp_prop)) return NULL;
527 
528  //------------------------------------------------------------
529  // Because the format of port-name had been changed from <port_name>
530  // to <instance_name>.<port_name>, the following processing was added.
531  // (since r1648)
532 
533  if (comp_prop.findNode("exported_ports") != 0)
534  {
535  coil::vstring exported_ports;
536  exported_ports = coil::split(comp_prop["exported_ports"], ",");
537 
538  std::string exported_ports_str("");
539  for (size_t i(0), len(exported_ports.size()); i < len; ++i)
540  {
541  coil::vstring keyval(coil::split(exported_ports[i], "."));
542  if (keyval.size() > 2)
543  {
544  exported_ports_str += (keyval[0] + "." + keyval.back());
545  }
546  else
547  {
548  exported_ports_str += exported_ports[i];
549  }
550 
551  if (i != exported_ports.size() - 1)
552  {
553  exported_ports_str += ",";
554  }
555  }
556 
557  comp_prop["exported_ports"] = exported_ports_str;
558  comp_prop["conf.default.exported_ports"] = exported_ports_str;
559 
560  }
561  //------------------------------------------------------------
562 
563  //------------------------------------------------------------
564  // Create Component
565  FactoryBase* factory(m_factory.find(comp_id));
566  if (factory == 0)
567  {
568  RTC_ERROR(("Factory not found: %s",
569  comp_id["implementation_id"].c_str()));
570 
571  // automatic module loading
572  std::vector<coil::Properties> mp(m_module->getLoadableModules());
573  RTC_INFO(("%d loadable modules found", mp.size()));
574 
575  std::vector<coil::Properties>::iterator it;
576  it = std::find_if(mp.begin(), mp.end(), ModulePredicate(comp_id));
577  if (it == mp.end())
578  {
579  RTC_ERROR(("No module for %s in loadable modules list",
580  comp_id["implementation_id"].c_str()));
581  return 0;
582  }
583  if (it->findNode("module_file_name") == 0)
584  {
585  RTC_ERROR(("Hmm...module_file_name key not found."));
586  return 0;
587  }
588  // module loading
589  RTC_INFO(("Loading module: %s", (*it)["module_file_name"].c_str()))
590  load((*it)["module_file_name"].c_str(), "");
591  factory = m_factory.find(comp_id);
592  if (factory == 0)
593  {
594  RTC_ERROR(("Factory not found for loaded module: %s",
595  comp_id["implementation_id"].c_str()));
596  return 0;
597  }
598  }
599 
601  prop = factory->profile();
602 
603  const char* inherit_prop[] = {
604  "config.version",
605  "openrtm.name",
606  "openrtm.version",
607  "os.name",
608  "os.release",
609  "os.version",
610  "os.arch",
611  "os.hostname",
612  "corba.endpoint",
613  "corba.id",
614  "exec_cxt.periodic.type",
615  "exec_cxt.periodic.rate",
616  "exec_cxt.evdriven.type",
617  "logger.enable",
618  "logger.log_level",
619  "naming.enable",
620  "naming.type",
621  "naming.formats",
622  ""
623  };
624 
625  for (int i(0); inherit_prop[i][0] != '\0'; ++i)
626  {
627  const char* key(inherit_prop[i]);
628  prop[key] = m_config[key];
629  }
630 
631  RTObject_impl* comp;
632  comp = factory->create(this);
633  if (comp == NULL)
634  {
635  RTC_ERROR(("RTC creation failed: %s",
636  comp_id["implementation_id"].c_str()));
637  return NULL;
638  }
639  RTC_TRACE(("RTC created: %s", comp_id["implementation_id"].c_str()));
640 
641  prop << comp_prop;
642 
643  //------------------------------------------------------------
644  // Load configuration file specified in "rtc.conf"
645  //
646  // rtc.conf:
647  // [category].[type_name].config_file = file_name
648  // [category].[instance_name].config_file = file_name
649  configureComponent(comp, prop);
650 
651  // comp->setProperties(prop);
652 
653  //------------------------------------------------------------
654  // Component initialization
655  if (comp->initialize() != RTC::RTC_OK)
656  {
657  RTC_TRACE(("RTC initialization failed: %s",
658  comp_id["implementation_id"].c_str()));
659  comp->exit();
660  RTC_TRACE(("%s was finalized", comp_id["implementation_id"].c_str()));
661  return NULL;
662  }
663  RTC_TRACE(("RTC initialization succeeded: %s",
664  comp_id["implementation_id"].c_str()));
665  //------------------------------------------------------------
666  // Bind component to naming service
667  registerComponent(comp);
668  return comp;
669  }
670 
679  {
680  RTC_TRACE(("Manager::registerComponent(%s)", comp->getInstanceName()));
681  // ### NamingManager のみで代用可能
683 
684  std::vector<std::string> names(comp->getNamingNames());
685 
686  for (int i(0), len(names.size()); i < len; ++i)
687  {
688  RTC_TRACE(("Bind name: %s", names[i].c_str()));
689  m_namingManager->bindObject(names[i].c_str(), comp);
690  }
691  return true;
692  }
693 
702  {
703  RTC_TRACE(("Manager::unregisterComponent(%s)", comp->getInstanceName()));
704  // ### NamingManager のみで代用可能
706 
707  std::vector<std::string> names(comp->getNamingNames());
708 
709  for (int i(0), len(names.size()); i < len; ++i)
710  {
711  RTC_TRACE(("Unbind name: %s", names[i].c_str()));
712  m_namingManager->unbindObject(names[i].c_str());
713  }
714 
715  return true;
716  }
717 
718 
720  {
721  RTC_TRACE(("Manager::createContext()"));
722  RTC_TRACE(("ExecutionContext type: %s",
723  m_config.getProperty("exec_cxt.periodic.type").c_str()));
724 
725  std::string ec_id;
726  coil::Properties ec_prop;
727  if (!procContextArgs(ec_args, ec_id, ec_prop)) return NULL;
728 
729  ECFactoryBase* factory(m_ecfactory.find(ec_id.c_str()));
730  if (factory == NULL)
731  {
732  RTC_ERROR(("Factory not found: %s", ec_id.c_str()));
733  return NULL;
734  }
735 
737  ec = factory->create();
738  return ec;
739  }
740 
749  {
750  RTC_TRACE(("deleteComponent(RTObject*)"));
751  // cleanup from manager's table, and naming serivce
752  unregisterComponent(comp);
753 
754  // find factory
755  coil::Properties& comp_id(comp->getProperties());
756  FactoryBase* factory(m_factory.find(comp_id));
757  if (factory == NULL)
758  {
759  RTC_DEBUG(("Factory not found: %s",
760  comp_id["implementation_id"].c_str()));
761  return;
762  }
763  else
764  {
765  RTC_DEBUG(("Factory found: %s",
766  comp_id["implementation_id"].c_str()));
767  factory->destroy(comp);
768  }
769 
770  if (coil::toBool(m_config["manager.shutdown_on_nortcs"],
771  "YES", "NO", true) &&
772  !coil::toBool(m_config["manager.is_master"], "YES", "NO", false))
773  {
774  std::vector<RTObject_impl*> comps;
775  comps = getComponents();
776  if (comps.size() == 0)
777  {
778  shutdown();
779  }
780  }
781  }
782 
783  void Manager::deleteComponent(const char* instance_name)
784  {
785  RTC_TRACE(("deleteComponent(%s)", instance_name));
786  RTObject_impl* comp;
787  comp = m_compManager.find(instance_name);
788  if (comp == 0)
789  {
790  RTC_WARN(("RTC %s was not found in manager.", instance_name));
791  return;
792  }
793  deleteComponent(comp);
794  }
795 
803  RTObject_impl* Manager::getComponent(const char* instance_name)
804  {
805  RTC_TRACE(("Manager::getComponent(%s)", instance_name));
806  return m_compManager.find(instance_name);
807  }
808 
816  std::vector<RTObject_impl*> Manager::getComponents()
817  {
818  RTC_TRACE(("Manager::getComponents()"));
819  return m_compManager.getObjects();
820  }
821 
822  //============================================================
823  // CORBA 関連
824  //============================================================
832  CORBA::ORB_ptr Manager::getORB()
833  {
834  RTC_TRACE(("Manager::getORB()"));
835  return m_pORB;
836  }
837 
845  PortableServer::POA_ptr Manager::getPOA()
846  {
847  RTC_TRACE(("Manager::getPOA()"));
848  return m_pPOA;
849  }
850 
858  PortableServer::POAManager_ptr Manager::getPOAManager()
859  {
860  RTC_TRACE(("Manager::getPOAManager()"));
861  return m_pPOAManager;
862  }
863 
864  //============================================================
865  // Protected functions
866  //============================================================
867 
868  //============================================================
869  // Manager initialization and finalization
870  //============================================================
878  void Manager::initManager(int argc, char** argv)
879  {
880  // load configurations
881  ManagerConfig config(argc, argv);
882  config.configure(m_config);
883  m_config["logger.file_name"] =
884  formatString(m_config["logger.file_name"].c_str(), m_config);
885 
886  // initialize ModuleManager
888 
889  // initialize Terminator
890  m_terminator = new Terminator(this);
891  {
892  Guard guard(m_terminate.mutex);
893  m_terminate.waiting = 0;
894  }
895 
896  // initialize Timer
897  if (coil::toBool(m_config["timer.enable"], "YES", "NO", true))
898  {
899  coil::TimeValue tm(0, 100000);
900  std::string tick(m_config["timer.tick"]);
901  if (!tick.empty())
902  {
903  tm = atof(tick.c_str());
904  m_timer = new coil::Timer(tm);
905  m_timer->start();
906  }
907  }
908 
909  if (coil::toBool(m_config["manager.shutdown_auto"], "YES", "NO", true) &&
910  !coil::toBool(m_config["manager.is_master"], "YES", "NO", false))
911  {
912  coil::TimeValue tm(10, 0);
913  if (m_config.findNode("manager.auto_shutdown_duration") != NULL)
914  {
915  double duration;
916  const char* s = m_config["manager.auto_shutdown_duration"].c_str();
917  if (coil::stringTo(duration, s))
918  {
919  tm = duration;
920  }
921  }
922  if (m_timer != NULL)
923  {
926  }
927  }
928 
929  {
930  coil::TimeValue tm(1, 0);
931  if (m_timer != NULL)
932  {
935  }
936  }
937 
938  }
939 
948  {
949  RTC_TRACE(("Manager::shutdownManager()"));
950  m_timer->stop();
951  }
952 
954  {
955  RTC_TRACE(("Manager::shutdownOnNoRtcs()"));
956  if (coil::toBool(m_config["manager.shutdown_on_nortcs"], "YES", "NO", true))
957  {
958  std::vector<RTObject_impl*> comps(getComponents());
959  if (comps.size() == 0)
960  {
961  shutdown();
962  }
963  }
964 
965  }
966 
967  //============================================================
968  // Logger initialization and finalization
969  //============================================================
978  {
979  rtclog.setLevel("SILENT");
980  rtclog.setName("manager");
981 
982  if (!coil::toBool(m_config["logger.enable"], "YES", "NO", true))
983  {
984  return true;
985  }
986 
987  std::vector<std::string> logouts;
988  logouts = coil::split(m_config["logger.file_name"], ",");
989 
990  for (int i(0), len(logouts.size()); i < len; ++i)
991  {
992  std::string logfile(logouts[i]);
993  if (logfile == "") continue;
994 
995  // Open logfile
996  if (logfile == "STDOUT" || logfile == "stdout")
997  {
998  m_logStreamBuf.addStream(std::cout.rdbuf());
999  continue;
1000  }
1001 
1002  std::filebuf* of = new std::filebuf();
1003  of->open(logfile.c_str(), std::ios::out | std::ios::app);
1004 
1005  if (!of->is_open())
1006  {
1007  std::cerr << "Error: cannot open logfile: "
1008  << logfile << std::endl;
1009  delete of;
1010  continue;
1011  }
1012  m_logStreamBuf.addStream(of, true);
1013  m_logfiles.push_back(of);
1014  }
1015 
1016 
1017  // Set date format for log entry header
1018  rtclog.setDateFormat(m_config["logger.date_format"].c_str());
1019 
1020  // Loglevel was set from configuration file.
1021  rtclog.setLevel(m_config["logger.log_level"].c_str());
1022 
1023  // Log stream mutex locking mode
1024  coil::toBool(m_config["logger.stream_lock"],
1025  "enable", "disable", false) ?
1027 
1028 
1029  RTC_INFO(("%s", m_config["openrtm.version"].c_str()));
1030  RTC_INFO(("Copyright (C) 2003-2010"));
1031  RTC_INFO((" Noriaki Ando"));
1032  RTC_INFO((" Intelligent Systems Research Institute, AIST"));
1033  RTC_INFO(("Manager starting."));
1034  RTC_INFO(("Starting local logging."));
1035 
1036  return true;;
1037  }
1038 
1047  {
1048  RTC_TRACE(("Manager::shutdownLogger()"));
1049  rtclog.flush();
1050 
1051  for (int i(0), len(m_logfiles.size()); i < len; ++i)
1052  {
1053  m_logfiles[i]->close();
1054  // m_logStreamBuf.removeStream(m_logfiles[i]->rdbuf());
1055  delete m_logfiles[i];
1056  }
1057  if (!m_logfiles.empty())
1058  {
1059  m_logfiles.clear();
1060  }
1061  }
1062 
1063  //============================================================
1064  // ORB initialization and finalization
1065  //============================================================
1074  {
1075  RTC_TRACE(("Manager::initORB()"));
1076  // Initialize ORB
1077  try
1078  {
1079  std::vector<std::string> args(coil::split(createORBOptions(), " "));
1080  // TAO's ORB_init needs argv[0] as command name.
1081  args.insert(args.begin(), "manager");
1082  char** argv = coil::toArgv(args);
1083  int argc(args.size());
1084 
1085  // ORB initialization
1086  m_pORB = CORBA::ORB_init(argc, argv);
1087  // Get the RootPOA
1088  CORBA::Object_var obj =
1089  m_pORB->resolve_initial_references((char*)"RootPOA");
1090  m_pPOA = PortableServer::POA::_narrow(obj);
1091  if (CORBA::is_nil(m_pPOA))
1092  {
1093  RTC_ERROR(("Could not resolve RootPOA."));
1094  return false;
1095  }
1096  // Get the POAManager
1097  m_pPOAManager = m_pPOA->the_POAManager();
1098 
1099 #ifdef ORB_IS_OMNIORB
1100  const char* conf = "corba.alternate_iiop_addresses";
1101  if (m_config.findNode(conf) != NULL)
1102  {
1103  coil::vstring addr_list;
1104  addr_list = coil::split(m_config[conf], ",", true);
1105 
1106  for (size_t i(0); i < addr_list.size(); ++i)
1107  {
1108  coil::vstring addr_port = coil::split(addr_list[i], ":");
1109  if (addr_port.size() == 2)
1110  {
1111  IIOP::Address iiop_addr;
1112  iiop_addr.host = addr_port[0].c_str();
1113  CORBA::UShort port;
1114  coil::stringTo(port, addr_port[1].c_str());
1115  iiop_addr.port = port;
1116  omniIOR::add_IIOP_ADDRESS(iiop_addr);
1117  }
1118  }
1119  }
1120 #endif // ORB_IS_OMNIORB
1121  }
1122  catch (...)
1123  {
1124  RTC_ERROR(("Exception: Caught unknown exception in initORB()." ));
1125  return false;
1126  }
1127  return true;
1128  }
1129 
1138  {
1139  std::string opt(m_config["corba.args"]);
1140  RTC_DEBUG(("corba.args: %s", opt.c_str()));
1141 
1143 
1144  coil::vstring endpoints;
1145  createORBEndpoints(endpoints);
1146  createORBEndpointOption(opt, endpoints);
1147 
1148  RTC_PARANOID(("ORB options: %s", opt.c_str()));
1149  return opt;
1150  }
1151 
1153  {
1154  // corba.endpoint is obsolete
1155  // corba.endpoints with comma separated values are acceptable
1156  if (m_config.findNode("corba.endpoints") != 0)
1157  {
1158  endpoints = coil::split(m_config["corba.endpoints"], ",");
1159  RTC_DEBUG(("corba.endpoints: %s", m_config["corba.endpoints"].c_str()));
1160  }
1161 
1162  if (m_config.findNode("corba.endpoint") != 0)
1163  {
1164  coil::vstring tmp(coil::split(m_config["corba.endpoint"], ","));
1165  endpoints.insert(endpoints.end(), tmp.begin(), tmp.end());
1166  RTC_DEBUG(("corba.endpoint: %s", m_config["corba.endpoint"].c_str()));
1167  }
1168  // If this process has master manager,
1169  // master manager's endpoint inserted at the top of endpoints
1170  RTC_DEBUG(("manager.is_master: %s",
1171  m_config["manager.is_master"].c_str()));
1172  if (coil::toBool(m_config["manager.is_master"], "YES", "NO", false))
1173  {
1174  std::string mm(m_config.getProperty("corba.master_manager", ":2810"));
1175  coil::vstring mmm(coil::split(mm, ":"));
1176  if (mmm.size() == 2)
1177  {
1178  endpoints.insert(endpoints.begin(), std::string(":") + mmm[1]);
1179  }
1180  else
1181  {
1182  endpoints.insert(endpoints.begin(), ":2810");
1183  }
1184  }
1185  coil::vstring tmp(endpoints);
1186  endpoints = coil::unique_sv(tmp);
1187  }
1188 
1189  void Manager::createORBEndpointOption(std::string& opt,
1190  coil::vstring& endpoints)
1191  {
1192  std::string corba(m_config["corba.id"]);
1193  RTC_DEBUG(("corba.id: %s", corba.c_str()));
1194 
1195  for (size_t i(0); i < endpoints.size(); ++i)
1196  {
1197  std::string& endpoint(endpoints[i]);
1198  RTC_DEBUG(("Endpoint is : %s", endpoint.c_str()));
1199  if (endpoint.find(":") == std::string::npos) { endpoint += ":"; }
1200 
1201  if (corba == "omniORB")
1202  {
1203  coil::normalize(endpoint);
1204  if (coil::normalize(endpoint) == "all:")
1205  {
1206 #ifdef ORB_IS_OMNIORB
1207 #ifdef RTC_CORBA_CXXMAPPING11
1208  // omniORB 4.1 or later
1209  opt += " -ORBendPointPublish all(addr)";
1210 #else
1211  // omniORB 4.0
1212  opt += " -ORBendPointPublishAllIFs 1";
1213 #endif // RTC_CORBA_CXXMAPPING1
1214 #endif // ORB_IS_OMNIORB
1215  }
1216  else
1217  {
1218  opt += " -ORBendPoint giop:tcp:" + endpoint;
1219  }
1220  }
1221  else if (corba == "TAO")
1222  {
1223  opt += "-ORBEndPoint iiop://" + endpoint;
1224  }
1225  else if (corba == "MICO")
1226  {
1227  opt += "-ORBIIOPAddr inet:" + endpoint;
1228  }
1229  }
1230  }
1231 
1232 
1241  {
1242  RTC_TRACE(("Manager::shutdownORB()"));
1243  if(CORBA::is_nil(m_pORB))
1244  {
1245  return;
1246  }
1247  try
1248  {
1249  while (m_pORB->work_pending())
1250  {
1251  RTC_PARANOID(("Pending work still exists."));
1252  if (m_pORB->work_pending())
1253  m_pORB->perform_work();
1254  }
1255  RTC_DEBUG(("No pending works of ORB. Shutting down POA and ORB."));
1256  }
1257  catch(...)
1258  {
1259  RTC_ERROR(("Caught SystemException during perform_work."));
1260  }
1261 
1262  if (!CORBA::is_nil(m_pPOA))
1263  {
1264  try
1265  {
1266  if (!CORBA::is_nil(m_pPOAManager))
1267  m_pPOAManager->deactivate(false, true);
1268  RTC_DEBUG(("POA Manager was deactivated."));
1269  m_pPOA->destroy(false, true);
1270  m_pPOA = PortableServer::POA::_nil();
1271  RTC_DEBUG(("POA was destroid."));
1272  }
1273  catch (CORBA::SystemException& ex)
1274  {
1275  RTC_ERROR(("Exception cought during root POA destruction"));
1276 #ifndef ORB_IS_RTORB
1277  RTC_ERROR(("CORBA::SystemException(minor=%d)", ex.minor()));
1278 #endif // ORB_IS_RTORB
1279  }
1280  catch (...)
1281  {
1282  RTC_ERROR(("Caught unknown exception during POA destruction."));
1283  }
1284  }
1285 
1286  if (!CORBA::is_nil(m_pORB))
1287  {
1288  try
1289  {
1290  m_pORB->shutdown(true);
1291  RTC_DEBUG(("ORB was shutdown."));
1292  //m_pORB->destroy();
1293  RTC_DEBUG(("ORB was destroied."));
1294  m_pORB = CORBA::ORB::_nil();
1295  }
1296  catch (CORBA::SystemException& ex)
1297  {
1298  RTC_ERROR(("Exception caught during ORB shutdown"));
1299 #ifndef ORB_IS_RTORB
1300  RTC_ERROR(("CORBA::SystemException(minodor=%d)", ex.minor()));
1301 #endif // ORB_IS_RTORB
1302  }
1303  catch (...)
1304  {
1305  RTC_ERROR(("Caught unknown exception during ORB shutdown."));
1306  }
1307  }
1308  }
1309 
1310  //============================================================
1311  // Naming initialization and finalization
1312  //============================================================
1321  {
1322  RTC_TRACE(("Manager::initNaming()"));
1323 
1324  m_namingManager = new NamingManager(this);
1325 
1326  // If NameService is disabled, return immediately
1327  if (!coil::toBool(m_config["naming.enable"], "YES", "NO", true))
1328  {
1329  return true;
1330  }
1331 
1332  // NameServer registration for each method and servers
1333  std::vector<std::string> meth(coil::split(m_config["naming.type"], ","));
1334 
1335  for (int i(0), len_i(meth.size()); i < len_i; ++i)
1336  {
1337  std::vector<std::string> names;
1338  names = coil::split(m_config[meth[i] + ".nameservers"], ",");
1339 
1340 
1341  for (int j(0), len_j(names.size()); j < len_j; ++j)
1342  {
1343  RTC_TRACE(("Register Naming Server: %s/%s", \
1344  meth[i].c_str(), names[j].c_str()));
1345  m_namingManager->registerNameServer(meth[i].c_str(),
1346  names[j].c_str());
1347  }
1348  }
1349 
1350  // NamingManager Timer update initialization
1351  if (coil::toBool(m_config["naming.update.enable"], "YES", "NO", true))
1352  {
1353  coil::TimeValue tm(10, 0); // default interval = 10sec for safty
1354  std::string intr(m_config["naming.update.interval"]);
1355  if (!intr.empty())
1356  {
1357  tm = atof(intr.c_str());
1358  }
1359  if (m_timer != NULL)
1360  {
1362  &NamingManager::update, tm);
1363  }
1364  }
1365  return true;
1366  }
1367 
1376  {
1377  RTC_TRACE(("Manager::shutdownNaming()"));
1379  delete m_namingManager;
1380  }
1381 
1382  //============================================================
1383  // Naming initialization and finalization
1384  //============================================================
1393  {
1394  RTC_TRACE(("Manager::initExecContext()"));
1398  return true;
1399  }
1400 
1402  {
1403  RTC_TRACE(("Manager::initComposite()"));
1405 
1406  return true;
1407  }
1408 
1410  {
1411  RTC_TRACE(("Manager::initFactories()"));
1412  FactoryInit();
1413  return true;
1414  }
1415 
1424  {
1425  return true;
1426  }
1427 
1428 
1430  {
1431  RTC_TRACE(("Manager::initManagerServant()"));
1432  if (!coil::toBool(m_config["manager.corba_servant"], "YES", "NO", true))
1433  {
1434  return true;
1435  }
1436  m_mgrservant = new ::RTM::ManagerServant();
1437  coil::Properties& prop(m_config.getNode("manager"));
1438  std::vector<std::string> names(coil::split(prop["naming_formats"], ","));
1439 
1440  if (coil::toBool(prop["is_master"], "YES", "NO", true))
1441  {
1442  for (int i(0), len(names.size()); i < len; ++i)
1443  {
1444  std::string mgr_name(formatString(names[i].c_str(), prop));
1445  m_namingManager->bindObject(mgr_name.c_str(), m_mgrservant);
1446  }
1447  }
1448 
1449  std::ifstream otherref(m_config["manager.refstring_path"].c_str());
1450  if (otherref.fail() != 0)
1451  {
1452  otherref.close();
1453  std::ofstream reffile(m_config["manager.refstring_path"].c_str());
1454  RTM::Manager_var mgr_v(RTM::Manager::
1455  _duplicate(m_mgrservant->getObjRef()));
1456  CORBA::String_var str_var = m_pORB->object_to_string(mgr_v);
1457  reffile << str_var;
1458  reffile.close();
1459  }
1460  else
1461  {
1462  std::string refstring;
1463  otherref >> refstring;
1464  otherref.close();
1465 
1466  CORBA::Object_var obj = m_pORB->string_to_object(refstring.c_str());
1467  RTM::Manager_var mgr = RTM::Manager::_narrow(obj);
1468  // if (CORBA::is_nil(mgr)) return false;
1469  // mgr->set_child(m_mgrservant->getObjRef());
1470  // m_mgrservant->set_owner(mgr);
1471  }
1472 
1473  return true;
1474  }
1475 
1484  {
1485  RTC_TRACE(("Manager::shutdownComponents()"));
1486  std::vector<RTObject_impl*> comps;
1487  comps = m_namingManager->getObjects();
1488  for (int i(0), len(comps.size()); i < len; ++i)
1489  {
1490  try
1491  {
1492  comps[i]->exit();
1493  coil::Properties p(comps[i]->getInstanceName());
1494  p << comps[i]->getProperties();
1495  rtclog.lock();
1497  rtclog.unlock();
1498  }
1499  catch (...)
1500  {
1501  ;
1502  }
1503  }
1504  for (CORBA::ULong i(0), len(m_ecs.size()); i < len; ++i)
1505  {
1506  try{
1507  PortableServer::ObjectId_var oid = m_pPOA->servant_to_id(m_ecs[i]);
1508  m_pPOA->deactivate_object(oid);
1509  }
1510  catch (...)
1511  {
1512  ;
1513  }
1514  }
1515  }
1516 
1525  {
1526  RTC_TRACE(("Manager::cleanupComponent()"));
1527  unregisterComponent(comp);
1528  }
1529 
1531  {
1532  RTC_VERBOSE(("Manager::cleanupComponents()"));
1533  Guard guard(m_finalized.mutex);
1534  RTC_VERBOSE(("%d components are marked as finalized.",
1535  m_finalized.comps.size()));
1536  for (size_t i(0); i < m_finalized.comps.size(); ++i)
1537  {
1539  }
1540  m_finalized.comps.clear();
1541  }
1542 
1544  {
1545  RTC_TRACE(("Manager::notifyFinalized()"));
1546  Guard guard(m_finalized.mutex);
1547  m_finalized.comps.push_back(comp);
1548  }
1549 
1557  bool Manager::procComponentArgs(const char* comp_arg,
1558  coil::Properties& comp_id,
1559  coil::Properties& comp_conf)
1560  {
1561  std::vector<std::string> id_and_conf(coil::split(comp_arg, "?"));
1562  // arg should be "id?key0=value0&key1=value1...".
1563  // id is mandatory, conf is optional
1564  if (id_and_conf.size() != 1 && id_and_conf.size() != 2)
1565  {
1566  RTC_ERROR(("Invalid arguments. Two or more '?' in arg : %s", comp_arg));
1567  return false;
1568  }
1569  if (id_and_conf[0].find(":") == std::string::npos)
1570  {
1571  id_and_conf[0].insert(0, "RTC:::");
1572  id_and_conf[0] += ":";
1573  }
1574  std::vector<std::string> id(coil::split(id_and_conf[0], ":"));
1575 
1576  // id should be devided into 1 or 5 elements
1577  // RTC:[vendor]:[category]:impl_id:[version] => 5
1578  if (id.size() != 5)
1579  {
1580  RTC_ERROR(("Invalid RTC id format.: %s", id_and_conf[0].c_str()));
1581  return false;
1582  }
1583 
1584  const char* prof[] =
1585  {
1586  "RTC", "vendor", "category", "implementation_id", "version"
1587  };
1588 
1589  if (id[0] != prof[0])
1590  {
1591  RTC_ERROR(("Invalid id type: %s", id[0].c_str()));
1592  return false;
1593  }
1594  for (int i(1); i < 5; ++i)
1595  {
1596  comp_id[prof[i]] = id[i];
1597  RTC_TRACE(("RTC basic propfile %s: %s", prof[i], id[i].c_str()));
1598  }
1599 
1600  if (id_and_conf.size() == 2)
1601  {
1602  std::vector<std::string> conf(coil::split(id_and_conf[1], "&"));
1603  for (int i(0), len(conf.size()); i < len; ++i)
1604  {
1605  if (conf[i].empty()) { continue; }
1606  std::vector<std::string> keyval(coil::split(conf[i], "="));
1607  if (keyval.size() != 2) { continue; }
1608  comp_conf[keyval[0]] = keyval[1];
1609  RTC_TRACE(("RTC property %s: %s",
1610  keyval[0].c_str(), keyval[1].c_str()));
1611  }
1612  }
1613  return true;
1614  }
1615 
1616  bool Manager::procContextArgs(const char* ec_args,
1617  std::string& ec_id,
1618  coil::Properties& ec_conf)
1619  {
1620  std::vector<std::string> id_and_conf(coil::split(ec_args, "?"));
1621  if (id_and_conf.size() != 1 && id_and_conf.size() != 2)
1622  {
1623  RTC_ERROR(("Invalid arguments. Two or more '?' in arg : %s", ec_args));
1624  return false;
1625  }
1626  if (id_and_conf[0].empty())
1627  {
1628  RTC_ERROR(("Empty ExecutionContext's name"));
1629  return false;
1630  }
1631  ec_id =id_and_conf[0];
1632 
1633  if (id_and_conf.size() == 2)
1634  {
1635  std::vector<std::string> conf(coil::split(id_and_conf[1], "&"));
1636  for (int i(0), len(conf.size()); i < len; ++i)
1637  {
1638  std::vector<std::string> k(coil::split(conf[i], "="));
1639  ec_conf[k[0]] = k[1];
1640  RTC_TRACE(("EC property %s: %s", k[0].c_str(), k[1].c_str()));
1641  }
1642  }
1643  return true;
1644  }
1645 
1654  const coil::Properties& prop)
1655  {
1656  std::string category(comp->getCategory());
1657  std::string type_name(comp->getTypeName());
1658  std::string inst_name(comp->getInstanceName());
1659 
1660  std::string type_conf(category + "." + type_name + ".config_file");
1661  std::string name_conf(category + "." + inst_name + ".config_file");
1662 
1663 
1664  coil::vstring config_fname;
1665  coil::Properties type_prop, name_prop;
1666 
1667  // Load "category.instance_name.config_file"
1668  if (!m_config[name_conf].empty())
1669  {
1670  std::ifstream conff(m_config[name_conf].c_str());
1671  if (!conff.fail())
1672  {
1673  name_prop.load(conff);
1674  }
1675  }
1676  if (m_config.findNode(category + "." + inst_name) != NULL)
1677  {
1678  name_prop << m_config.getNode(category + "." + inst_name);
1679  }
1680 
1681  if (!m_config[type_conf].empty())
1682  {
1683  std::ifstream conff(m_config[type_conf].c_str());
1684  if (!conff.fail())
1685  {
1686  type_prop.load(conff);
1687  }
1688  }
1689  if (m_config.findNode(category + "." + type_name) != NULL)
1690  {
1691  type_prop << m_config.getNode(category + "." + type_name);
1692  }
1693 
1694  // Merge Properties. type_prop is merged properties
1695  comp->setProperties(prop);
1696  type_prop << name_prop;
1697  comp->setProperties(type_prop);
1698 
1699  //------------------------------------------------------------
1700  // Format component's name for NameService
1701  std::string naming_formats;
1702  coil::Properties& comp_prop(comp->getProperties());
1703 
1704  naming_formats += m_config["naming.formats"];
1705  if (comp_prop.findNode("naming.formats") != 0)
1706  {
1707  naming_formats = comp_prop["naming.formats"];
1708  }
1709  naming_formats = coil::flatten(coil::unique_sv(coil::split(naming_formats,
1710  ",")));
1711 
1712  std::string naming_names;
1713  naming_names = formatString(naming_formats.c_str(), comp->getProperties());
1714  comp->getProperties()["naming.formats"] = naming_formats;
1715  comp->getProperties()["naming.names"] = naming_names;
1716  }
1717 
1725  bool Manager::mergeProperty(coil::Properties& prop, const char* file_name)
1726  {
1727  if (file_name == NULL)
1728  {
1729  RTC_ERROR(("Invalid configuration file name."));
1730  return false;
1731  }
1732  if (file_name[0] != '\0')
1733  {
1734  std::ifstream conff(file_name);
1735  if (!conff.fail())
1736  {
1737  prop.load(conff);
1738  conff.close();
1739  return true;
1740  }
1741  }
1742  return false;
1743  }
1744 
1752  std::string Manager::formatString(const char* naming_format,
1754  {
1755  std::string name(naming_format), str("");
1756  std::string::iterator it, it_end;
1757  int count(0);
1758 
1759  it = name.begin();
1760  it_end = name.end();
1761  for ( ; it != it_end; ++it)
1762  {
1763  char c(*it);
1764  if (c == '%')
1765  {
1766  ++count;
1767  if (!(count % 2)) str.push_back((*it));
1768  }
1769  else if (c == '$')
1770  {
1771  count = 0;
1772  ++it;
1773  if (*it == '{' || *it == '(')
1774  {
1775  ++it;
1776  std::string env;
1777  for ( ; it != it_end && (*it) != '}' && (*it) != ')'; ++it)
1778  {
1779  env += *it;
1780  }
1781  char* envval = coil::getenv(env.c_str());
1782  if (envval != NULL) str += envval;
1783  }
1784  else
1785  {
1786  str.push_back(c);
1787  }
1788  }
1789  else
1790  {
1791  if (count > 0 && (count % 2))
1792  {
1793  count = 0;
1794  if (c == 'n') str += prop["instance_name"];
1795  else if (c == 't') str += prop["type_name"];
1796  else if (c == 'm') str += prop["type_name"];
1797  else if (c == 'v') str += prop["version"];
1798  else if (c == 'V') str += prop["vendor"];
1799  else if (c == 'c') str += prop["category"];
1800  else if (c == 'h') str += m_config["os.hostname"];
1801  else if (c == 'M') str += m_config["manager.name"];
1802  else if (c == 'p') str += m_config["manager.pid"];
1803  else str.push_back(c);
1804  }
1805  else
1806  {
1807  count = 0;
1808  str.push_back(c);
1809  }
1810  }
1811  }
1812  return str;
1813  }
1814 
1815 };
void setDateFormat(const char *format)
Set date/time format for adding the header.
RTObject_impl *(* RtcNewFunc)(Manager *manager)
Definition: rtm/Factory.h:33
ECFactoryCXX class.
Definition: ECFactory.h:221
#define RTC_ERROR(fmt)
Error log output macro.
Definition: SystemLogger.h:422
static Mutex mutex
The mutex of the pointer to the Manager.
Definition: Manager.h:1555
PortableServer::POAManager_ptr getPOAManager()
Get POAManager that Manager has.
Definition: Manager.cpp:858
std::string normalize(std::string &str)
Erase the head/tail blank and replace upper case to lower case.
Definition: stringutil.cpp:303
void(* ModuleInitProc)(Manager *manager)
Definition: Manager.h:58
RTObject_impl * createComponent(const char *comp_args)
Create RT-Components.
Definition: Manager.cpp:520
std::string createORBOptions()
Create ORB command options.
Definition: Manager.cpp:1137
Logger rtclog
Logger stream.
Definition: Manager.h:1654
bool procContextArgs(const char *ec_args, std::string &ec_id, coil::Properties &ec_conf)
Extracting ExecutionContext&#39;s name/properties from the given string.
Definition: Manager.cpp:1616
const char * getCategory()
[local interface] Get category information
Definition: RTObject.h:2099
RT-Component.
void deleteComponent(RTObject_impl *comp)
Unregister RT-Components that have been registered to Manager.
Definition: Manager.cpp:748
std::vector< coil::Properties > getLoadedModules()
Get a list of loaded modules.
Definition: Manager.cpp:404
virtual int open(void *args)
ORB activation processing.
Definition: Manager.h:1894
Structure for exception handling when file open is failed.
RTComponent utils.
virtual ReturnCode_t initialize()
[CORBA interface] Initialize the RTC that realizes this interface.
Definition: RTObject.cpp:310
Term m_terminate
Synchronous flag for manager termination.
Definition: Manager.h:2103
bool stringTo(To &val, const char *str)
Convert the given std::string to object.
Definition: stringutil.h:597
PortableServer::POA_ptr getPOA()
Get a pointer to RootPOA held by Manager.
Definition: Manager.cpp:845
std::vector< coil::Properties > getLoadableModules()
Get the loadable module list.
FactoryManager m_factory
ComponentManager.
Definition: Manager.h:1780
factory initialization function
Mutex class.
void runManager(bool no_block=false)
Run the Manager.
Definition: Manager.cpp:318
void terminate()
Termination processing.
Definition: Manager.h:2019
RTObject_impl * getComponent(const char *instance_name)
Get RT-Component&#39;s pointer.
Definition: Manager.cpp:803
bool initFactories()
Factories initialization.
Definition: Manager.cpp:1409
void cleanupComponents()
This method deletes RT-Components.
Definition: Manager.cpp:1530
RTM::ManagerServant * m_mgrservant
The pointer to the ManagerServant.
Definition: Manager.h:1450
bool registerComponent(RTObject_impl *comp)
Register RT-Component directly without Factory.
Definition: Manager.cpp:678
Object * find(const Identifier &id) const
Find the object.
std::vector< RTObject_impl * > getObjects()
Get all bound objects.
std::vector< coil::Properties > getLoadableModules()
Get a list of loadable modules.
Definition: Manager.cpp:417
void shutdown()
Shutdown Manager.
Definition: Manager.cpp:182
A base class for ExecutionContext.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
std::vector< std::string > getNamingNames()
[local interface] Get Naming Server information
Definition: RTObject.cpp:1457
RT-Component class.
Definition: RTObject.h:89
virtual ExecutionContextBase * create()=0
Pure virtual function to create ExecutionContext.
void terminate()
Terminate manager.
Definition: Manager.cpp:169
void load(const char *fname, const char *initfunc)
[CORBA interface] Load module
Definition: Manager.cpp:346
vstring split(const std::string &input, const std::string &delimiter, bool ignore_empty)
Split string by delimiter.
Definition: stringutil.cpp:341
RTC manager configuration.
Manager class.
Definition: Manager.h:80
void bindObject(const char *name, const RTObject_impl *rtobj)
Bind the specified objects to NamingService.
Structure for exception handling when specified symbol cannot be found.
bool initExecContext()
ExecutionContextManager initialization.
Definition: Manager.cpp:1392
void setName(const char *name)
Set suffix of date/time string of header.
vstring unique_sv(vstring sv)
Eliminate duplication from the given string list.
Definition: stringutil.cpp:537
void registerNameServer(const char *method, const char *name_server)
Regster the NameServer.
CORBA::ORB_ptr getORB()
Get the pointer to ORB.
Definition: Manager.cpp:832
std::string load(const std::string &file_name)
Load the module.
void PeriodicExecutionContextInit(RTC::Manager *manager)
Initialization function to register to ECFactory.
bool initComposite()
PeriodicECSharedComposite initialization.
Definition: Manager.cpp:1401
coil::Timer * m_timer
Timer Object.
Definition: Manager.h:1633
coil::Properties & getProperties()
[local interface] Get RTC property
Definition: RTObject.cpp:1525
void configure(coil::Properties &prop)
Specify the configuration information to the Property.
ListenerId registerListenerObj(ListenerClass *obj, void(ListenerClass::*cbf)(), TimeValue tm)
Register listener.
Definition: Timer.h:255
std::vector< coil::Properties > getLoadedModules()
Get the module list that has been loaded.
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
Definition: Singleton.h:131
void OpenHRPExecutionContextInit(RTC::Manager *manager)
Initialization function to register to ECFactory.
static Manager & instance()
Get instance of the manager.
Definition: Manager.cpp:140
NamingManager * m_namingManager
The pointer to the NamingManager.
Definition: Manager.h:1624
void(* SignalHandler)(int)
TimeValue class.
Definition: TimeValue.h:40
#define RTC_WARN(fmt)
Warning log output macro.
Definition: SystemLogger.h:444
string mgr_name
Get Manager object reference.
RTComponent manager class.
#define RTC_DEBUG_STR(str)
Definition: SystemLogger.h:489
#define RTC_PARANOID(fmt)
Paranoid level log output macro.
Definition: SystemLogger.h:555
virtual int wait(void)
Waiting for the thread terminate.
std::vector< std::string > vstring
Definition: stringutil.h:37
const char * getTypeName()
[local interface] Get type name
Definition: RTObject.h:1998
void FactoryInit()
Definition: FactoryInit.cpp:36
std::vector< coil::Properties > getFactoryProfiles()
Get profiles of factories.
Definition: Manager.cpp:456
env
ネームサーバー定義 env = RtmEnv(sys.argv, ["localhost:2809"]) list0 = env.name_space["localhost:2809"].list_obj() env.name_space[&#39;localhost:2809&#39;].rtc_handles.keys() ns = env.name_space[&#39;localhost:2809&#39;]
Definition: ConnectTest.py:25
void stop()
Stop Timer task.
Definition: Timer.cpp:107
void addStream(streambuf_type *stream, bool cleanup=false)
Destructor.
static Manager * manager
The pointer to the Manager.
Definition: Manager.h:1546
void configureComponent(RTObject_impl *comp, const coil::Properties &prop)
Configure RT-Component.
Definition: Manager.cpp:1653
ECFactoryBase abstract class.
Definition: ECFactory.h:115
std::vector< std::filebuf * > m_logfiles
Files for log output.
Definition: Manager.h:1663
Periodic Execution Context Shared Composite Component class.
void notifyFinalized(RTObject_impl *comp)
This method deletes RT-Components.
Definition: Manager.cpp:1543
#define RTC_DEBUG(fmt)
Debug level log output macro.
Definition: SystemLogger.h:488
std::vector< ExecutionContextBase * > m_ecs
ExecutionContext list.
Definition: Manager.h:1817
CORBA naming service helper class.
std::string flatten(vstring sv)
Create CSV file from the given string list.
Definition: stringutil.cpp:549
void shutdownNaming()
NamingManager finalization.
Definition: Manager.cpp:1375
LogStreamBuf m_logStreamBuf
Logger buffer.
Definition: Manager.h:1645
Finalized m_finalized
Definition: Manager.h:2110
bool registerObject(Object *obj)
Register the specified object.
#define RTC_TRACE(fmt)
void shutdownLogger()
System Logger finalization.
Definition: Manager.cpp:1046
std::vector< std::string > getModulesFactories()
Get the list of all Factories.
Definition: Manager.cpp:502
def j(str, encoding="cp932")
Definition: RunAtFirst.py:198
CORBA::Long find(const CorbaSequence &seq, Functor f)
Return the index of CORBA sequence element that functor matches.
void ExtTrigExecutionContextInit(RTC::Manager *manager)
Register Factory class for this ExecutionContext.
void handler(int)
Definition: Manager.cpp:48
Object * unregisterObject(const Identifier &id)
Unregister the specified object.
static Manager * init(int argc, char **argv)
Initialize manager.
Definition: Manager.cpp:110
OrbRunner class.
Definition: Manager.h:1851
Structure for exception handling when specified module cannot be found.
RTComponent manager servant implementation class.
void initManager(int argc, char **argv)
Manager internal initialization.
Definition: Manager.cpp:878
char ** toArgv(const vstring &args)
Convert the given string list into the argument list.
Definition: stringutil.cpp:568
coil::Properties m_config
Managaer&#39;s configuration Properties.
Definition: Manager.h:1606
ExtTrigExecutionContext class.
CORBA::ORB_var m_pORB
The pointer to the ORB.
Definition: Manager.h:1567
Loadable modules manager class.
Properties *const findNode(const std::string &key) const
Get node of properties.
Definition: Properties.cpp:439
bool procComponentArgs(const char *comp_arg, coil::Properties &comp_id, coil::Properties &comp_conf)
Extracting component type/properties from the given string.
Definition: Manager.cpp:1557
ExecutionContextBase * createContext(const char *ec_args)
Create Context.
Definition: Manager.cpp:719
void load(std::istream &inStream)
Loads property list that consists of key:value from input stream.
Definition: Properties.cpp:334
void enableLock()
Enable the lock mode.
InstanceName(RTObject_impl *comp)
Definition: Manager.cpp:58
void createORBEndpoints(coil::vstring &endpoints)
Create Endpoints.
Definition: Manager.cpp:1152
bool unregisterComponent(RTObject_impl *comp)
Unregister RT-Components.
Definition: Manager.cpp:701
Manager()
Protected Constructor.
Definition: Manager.cpp:80
void join()
Wait for Manager&#39;s termination.
Definition: Manager.cpp:208
virtual ReturnCode_t exit()
[CORBA interface]top the RTC&#39;s execution context(s) and finalize it along with its contents...
Definition: RTObject.cpp:394
void shutdownManager()
Shutdown Manager.
Definition: Manager.cpp:947
ACE_Sig_Action SignalAction
const char * getInstanceName()
[local interface] Get instance name
Definition: RTObject.h:1952
Execution context for OpenHRP3.
Pred for_each(Pred p)
Functor for searching object.
bool activateManager()
Activate the Manager.
Definition: Manager.cpp:244
bool setLevel(const char *level)
Set log level by string.
bool registerECFactory(const char *name, ECNewFunc new_func, ECDeleteFunc delete_func)
Register ExecutionContext Factory.
Definition: Manager.cpp:474
prop
Organization::get_organization_property ();.
ModuleManager * m_module
The pointer to the ModuleManager.
Definition: Manager.h:1615
naming Service helper class
CORBA IOR manipulation utility functions.
ostream_type & level(int level)
Acquire log stream.
Terminator * m_terminator
The pointer to ORB termination helper class.
Definition: Manager.h:2083
void unloadAll()
Unload all modules.
Definition: Manager.cpp:390
Timer class.
Definition: Timer.h:53
bool mergeProperty(coil::Properties &prop, const char *file_name)
Merge property information.
Definition: Manager.cpp:1725
Class represents a set of properties.
Definition: Properties.h:101
void unloadAll()
Unload all modules.
void unload(const char *fname)
Unload module.
Definition: Manager.cpp:376
char * getenv(const char *name)
Get environment variable.
Definition: ace/coil/OS.h:48
bool toBool(std::string str, std::string yes, std::string no, bool default_value)
Convert given string into bool value.
Definition: stringutil.cpp:410
void createORBEndpointOption(std::string &opt, coil::vstring &endpoint)
Create a command optional line of Endpoint of ORB.
Definition: Manager.cpp:1189
ExecutionContextBase *(* ECNewFunc)()
Definition: ECFactory.h:29
void update()
Update information of NamingServer.
std::vector< RTObject_impl * > comps
Definition: Manager.h:2108
void setModuleInitProc(ModuleInitProc proc)
Set initial procedure.
Definition: Manager.cpp:232
PeriodicExecutionContext class.
bool initManagerServant()
ManagerServant initialization.
Definition: Manager.cpp:1429
FactoryBase base class.
Definition: rtm/Factory.h:118
void shutdownOnNoRtcs()
Shutdown Manager.
Definition: Manager.cpp:953
bool initLogger()
System logger initialization.
Definition: Manager.cpp:977
bool initNaming()
NamingManager initialization.
Definition: Manager.cpp:1320
#define RTC_INFO(fmt)
Information level log output macro.
Definition: SystemLogger.h:466
RTM::Manager_ptr getObjRef() const
Get the reference of Manager.
void unload(const std::string &file_name)
Unload the module.
void lock()
Acquire log lock Acquire log lock when the lock mode is set.
void(* RtcDeleteFunc)(RTObject_impl *rtc)
Definition: rtm/Factory.h:34
ComponentManager m_compManager
ComponentManager.
Definition: Manager.h:1687
RTComponent header.
bool operator()(RTObject_impl *comp)
Definition: Manager.cpp:67
void cleanupComponent(RTObject_impl *comp)
Unregister RT-Components.
Definition: Manager.cpp:1524
const char * basename(const char *path)
Get a file name part than a file pass.
Definition: ace/coil/File.h:33
Properties & getNode(const std::string &key)
Get node of properties.
Definition: Properties.cpp:455
PortableServer::POA_var m_pPOA
The pointer to the POA.
Definition: Manager.h:1576
std::vector< Object * > getObjects() const
Get a list of obejects that are registerd.
FactoryCXX class.
Definition: rtm/Factory.h:286
void disableLock()
Disable the lock mode.
void unlock()
Release the log lock Release the log lock when the lock mode is set.
void shutdownORB()
ORB finalization.
Definition: Manager.cpp:1240
ECFactoryManager m_ecfactory
ExecutionContext Manager.
Definition: Manager.h:1808
void PeriodicECSharedCompositeInit(RTC::Manager *manager)
bool initTimer()
Timer initialization.
Definition: Manager.cpp:1423
std::string formatString(const char *naming_format, coil::Properties &prop)
Construct registration information when registering to Naming server.
Definition: Manager.cpp:1752
void unbindObject(const char *name)
Unbind the specified objects from NamingService.
void(* ECDeleteFunc)(ExecutionContextBase *ec)
Definition: ECFactory.h:30
OrbRunner * m_runner
The pointer to ORB helper class.
Definition: Manager.h:1959
SDO service consumer base class and its factory.
bool registerFactory(coil::Properties &profile, RtcNewFunc new_func, RtcDeleteFunc delete_func)
Register RT-Component Factory.
Definition: Manager.cpp:433
void shutdownComponents()
NamingManager finalization.
Definition: Manager.cpp:1483
#define RTC_VERBOSE(fmt)
Verbose level log output macro.
Definition: SystemLogger.h:533
void setProperties(const coil::Properties &prop)
[local interface] Set RTC property
Definition: RTObject.cpp:1497
PortableServer::POAManager_var m_pPOAManager
The pointer to the POAManager.
Definition: Manager.h:1585
Terminator class.
Definition: Manager.h:1983
ModuleInitProc m_initProc
User&#39;s initialization function&#39;s pointer.
Definition: Manager.h:1597
const std::string & getProperty(const std::string &key) const
Search for the property with the specified key in this property.
Definition: Properties.cpp:156
std::vector< RTObject_impl * > getComponents()
Get all RT-Components registered in the Manager.
Definition: Manager.cpp:816
int usleep(useconds_t usec)
Stop a processing at specified micro second time.
Definition: ace/coil/Time.h:51
bool initORB()
CORBA ORB initialization.
Definition: Manager.cpp:1073
void unbindAll()
Unbind all objects from NamingService.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:53