00001 // -*- C++ -*- 00020 #ifndef RTM_MANAGERSERVANT_H 00021 #define RTM_MANAGERSERVANT_H 00022 00023 #include <iostream> 00024 #include <coil/Mutex.h> 00025 #include <coil/Guard.h> 00026 #include <rtm/idl/ManagerSkel.h> 00027 #include <rtm/Manager.h> 00028 #include <rtm/SystemLogger.h> 00029 00045 namespace RTM 00046 { 00063 class ManagerServant 00064 : public virtual POA_RTM::Manager, 00065 public virtual PortableServer::RefCountServantBase 00066 { 00067 public: 00081 // standard constructor 00082 ManagerServant(); 00083 00095 virtual ~ManagerServant(void); 00096 00121 RTC::ReturnCode_t load_module(const char* pathname, const char* initfunc); 00122 00142 RTC::ReturnCode_t unload_module(const char* pathname); 00143 00161 RTM::ModuleProfileList* get_loadable_modules(); 00162 00180 RTM::ModuleProfileList* get_loaded_modules(); 00181 00182 // component ´ØÏ¢ 00202 RTM::ModuleProfileList* get_factory_profiles(); 00203 00222 RTC::RTObject_ptr create_component(const char* module_name); 00223 00242 RTC::ReturnCode_t delete_component(const char* instance_name); 00243 00261 RTC::RTCList* get_components(); 00262 00282 RTC::ComponentProfileList* get_component_profiles(); 00283 00284 // manager ´ðËÜ 00302 RTM::ManagerProfile* get_profile(); 00303 00321 RTM::NVList* get_configuration(); 00322 00344 RTC::ReturnCode_t set_configuration(const char* name, const char* value); 00345 00365 ::CORBA::Boolean is_master(); 00366 00388 RTM::ManagerList* get_master_managers(); 00389 00413 RTC::ReturnCode_t add_master_manager(RTM::Manager_ptr mgr); 00414 00434 RTC::ReturnCode_t remove_master_manager(RTM::Manager_ptr mgr); 00435 00457 RTM::ManagerList* get_slave_managers(); 00458 00478 RTC::ReturnCode_t add_slave_manager(RTM::Manager_ptr mgr); 00479 00499 RTC::ReturnCode_t remove_slave_manager(RTM::Manager_ptr mgr); 00500 00501 00502 00512 RTC::ReturnCode_t fork(); 00522 RTC::ReturnCode_t shutdown(); 00532 RTC::ReturnCode_t restart(); 00533 00543 CORBA::Object_ptr get_service(const char* name); 00544 00554 RTM::Manager_ptr getObjRef() const; 00555 00565 bool createINSManager(); 00566 00576 RTM::Manager_ptr findManager(const char* host_port); 00577 00578 private: 00579 typedef coil::Guard<coil::Mutex> Guard; 00587 ::RTC::Logger rtclog; 00588 00596 ::RTC::Manager& m_mgr; 00597 00605 ::RTM::Manager_var m_objref; 00606 00614 ::RTM::ManagerList m_masters; 00615 00623 ::coil::Mutex m_masterMutex; 00624 00632 ::RTM::ManagerList m_slaves; 00633 00641 ::coil::Mutex m_slaveMutex; 00642 00650 CORBA::Boolean m_isMaster; 00651 00659 class is_equiv 00660 { 00661 RTM::Manager_var m_mgr; 00662 public: 00663 is_equiv(RTM::Manager_ptr mgr) 00664 : m_mgr(RTM::Manager::_duplicate(mgr)) {} 00665 bool operator()(RTM::Manager_ptr mgr) 00666 { 00667 return m_mgr->_is_equivalent(mgr); 00668 } 00669 }; 00670 00671 }; 00672 }; // namespace RTM 00673 #endif // RTM_MANAGERSERVANT_H