NamingManager.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 #ifndef RTC_NAMINGMANAGER_H
00020 #define RTC_NAMINGMANAGER_H
00021 
00022 #include <rtm/RTC.h>
00023 
00024 #include <coil/Task.h>
00025 #include <coil/Mutex.h>
00026 #include <coil/Guard.h>
00027 #include <rtm/CorbaNaming.h>
00028 #include <rtm/RTObject.h>
00029 #include <rtm/SystemLogger.h>
00030 #include <rtm/ManagerServant.h>
00031 
00032 namespace RTC
00033 {
00034   class Manager;
00063   class NamingBase
00064   {
00065     typedef coil::Mutex Mutex;
00066     typedef coil::Guard<Mutex> Guard;
00067   public:
00079     NamingBase() {};
00080     
00092     virtual ~NamingBase(void) {};
00093     
00112     virtual void bindObject(const char* name, const RTObject_impl* rtobj) = 0;
00113 
00132     virtual void bindObject(const char* name,
00133                             const RTM::ManagerServant* mgr) = 0;
00134     
00152     virtual void unbindObject(const char* name) = 0;
00153 
00169     virtual bool isAlive() = 0;
00170   };
00171   
00172 
00196   class NamingOnCorba
00197     : public virtual NamingBase
00198   {
00199   public:
00226     NamingOnCorba(CORBA::ORB_ptr orb, const char* names);
00227     
00239     virtual ~NamingOnCorba(void){};
00240     
00264     virtual void bindObject(const char* name, const RTObject_impl* rtobj);
00282     virtual void bindObject(const char* name, const RTM::ManagerServant* mgr);
00283     
00303     virtual void unbindObject(const char* name);
00304     
00320     virtual bool isAlive();
00321 
00322   private:
00323     Logger rtclog;
00324     CorbaNaming m_cosnaming;
00325     std::string m_endpoint;
00326     bool m_replaceEndpoint;
00327     std::map<std::string, RTObject_impl*> m_names;
00328   };
00329   
00353   class NamingManager
00354   {
00355     typedef coil::Mutex Mutex;
00356     typedef coil::Guard<Mutex> Guard;
00357   public:
00377     NamingManager(Manager* manager);
00378     
00390     virtual ~NamingManager(void);
00391     
00415     void registerNameServer(const char* method, const char* name_server);
00416     
00439     void bindObject(const char* name, const RTObject_impl* rtobj);
00440 
00464     void bindObject(const char* name, const RTM::ManagerServant* mgr);
00465     
00482     void update();
00483     
00503     void unbindObject(const char* name);
00504     
00520     void unbindAll();
00521     
00541     std::vector<RTObject_impl*> getObjects();
00542     
00543   protected:
00569     NamingBase* createNamingObj(const char* method, const char* name_server);
00570     
00590     void bindCompsTo(NamingBase* ns);
00591     
00613     void registerCompName(const char* name, const RTObject_impl* rtobj);
00614 
00637     void registerMgrName(const char* name, const RTM::ManagerServant* mgr);
00638     
00658     void unregisterCompName(const char* name);
00659 
00680     void unregisterMgrName(const char* name);
00681 
00701     class Names;
00702     void retryConnection(Names* ns);
00703     
00704   protected:
00705     // Name Servers' method/name and object
00713     class Names
00714     {
00715     public:
00716       Names(const char* meth, const char* name, NamingBase* naming)
00717         : method(meth), nsname(name), ns(naming)
00718       {
00719       }
00720       
00721       ~Names()
00722       {
00723         delete ns;
00724       }
00725       
00726       std::string method;
00727       std::string nsname;
00728       NamingBase* ns;
00729     };
00737     std::vector<Names*> m_names;
00745     Mutex m_namesMutex;
00746     
00747     // Components' name and object
00755     struct Comps
00756     {
00757       Comps(const char* n, const RTObject_impl* obj)
00758         : name(n), rtobj(obj)
00759       {}
00760       std::string name;
00761       const RTObject_impl* rtobj;
00762     };
00770     struct Mgr
00771     {
00772       Mgr(const char* n, const RTM::ManagerServant* obj)
00773         : name(n), mgr(obj)
00774       {}
00775       std::string name;
00776       const RTM::ManagerServant* mgr;
00777     };
00785     std::vector<Comps*> m_compNames;
00793     Mutex m_compNamesMutex;
00801     std::vector<Mgr*> m_mgrNames;
00809     Mutex m_mgrNamesMutex;
00810     
00818     Manager* m_manager;
00819     
00827     Logger rtclog;
00828   }; // class NamingManager
00829 }; // namespace RTC
00830 
00831 #endif // RTC_NAMINGMANAGER_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sat Jun 8 2019 18:49:05