PortAdmin.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef RTC_PORTADMIN_H
00021 #define RTC_PORTADMIN_H
00022 
00023 #include <rtm/idl/RTCSkel.h>
00024 #include <rtm/PortBase.h>
00025 #include <rtm/ObjectManager.h>
00026 #include <rtm/SystemLogger.h>
00027 
00028 namespace RTC
00029 {
00052   class PortAdmin
00053   {
00054   public:
00074     PortAdmin(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa);
00075     
00089     virtual ~PortAdmin(void){};
00090     
00111     PortServiceList* getPortServiceList() const;
00112     
00133     PortProfileList getPortProfileList() const;
00134     
00161     PortService_ptr getPortRef(const char* port_name) const;
00162     
00189     PortBase* getPort(const char* port_name) const;
00190     
00217     bool addPort(PortBase& port);
00218 
00245     bool addPort(PortService_ptr port);
00246 
00271     void registerPort(PortBase& port);
00272 
00297     void registerPort(PortService_ptr port);
00298     
00324     bool removePort(PortBase& port);
00325 
00351     bool removePort(PortService_ptr port);
00352 
00376     void deletePort(PortBase& port);
00377 
00401     void deletePort(PortService_ptr port);
00402     
00427     void deletePortByName(const char* port_name);
00428 
00447     void activatePorts();
00448 
00467     void deactivatePorts();
00468 
00486     void finalizePorts();
00487     
00488   private:
00496     CORBA::ORB_var m_pORB;
00497     
00505     PortableServer::POA_var m_pPOA;
00506     
00514     PortServiceList m_portRefs;
00515 
00523     mutable Logger rtclog;
00524 
00532     template <class T>
00533     class comp_op
00534     {
00535     public:
00536       comp_op(const char* _name)
00537         : m_name(_name)
00538       {
00539       }
00540       comp_op(T* obj) 
00541         : m_name((const char*)(obj->getProfile().name))
00542       {
00543       }
00544       bool operator()(T* obj)
00545       {
00546         std::string name((const char*)obj->getProfile().name);
00547         return m_name == name;
00548       }
00549     private:
00550       std::string m_name;
00551     };
00552 
00560     class port_prof_collect
00561     {
00562     public:
00563       port_prof_collect(PortProfileList& p) : m_p(p) {}
00564       void operator()(const PortBase* port)
00565       {
00566         CORBA_SeqUtil::push_back(m_p, port->getPortProfile());
00567       }
00568     private:
00569       PortProfileList& m_p;
00570     };
00571 
00579     class port_prof_collect2
00580     {
00581     public:
00582       port_prof_collect2(PortProfileList& p) : m_p(p) {}
00583       void operator()(const PortService_ptr port)
00584       {
00585         PortProfile* pp(port->get_port_profile());
00586         CORBA_SeqUtil::push_back(m_p, *(pp));
00587         delete pp;
00588       }
00589     private:
00590       PortProfileList& m_p;
00591     };
00592     
00593     struct find_port_name;
00594     struct find_port;
00595     struct del_port;
00596     
00597     // サーバントを直接格納するオブジェクトマネージャ
00598     ObjectManager<const char*, PortBase, comp_op<PortBase> > m_portServants;
00599     
00600   };
00601 };     // namespace RTC
00602 #endif // RTC_PORTADMIN_H


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Aug 27 2015 14:16:38