PortConnectListener.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00019 #ifndef RTC_PORTCONNECTLISTENER_H
00020 #define RTC_PORTCONNECTLISTENER_H
00021 
00022 #include <vector>
00023 #include <utility>
00024 #include <coil/Mutex.h>
00025 #include <coil/Guard.h>
00026 #include <rtm/RTC.h>
00027 #include <rtm/idl/RTCSkel.h>
00028 
00029 namespace RTC
00030 {
00031   //============================================================
00049   enum PortConnectListenerType
00050     {
00051       ON_NOTIFY_CONNECT,
00052       ON_NOTIFY_DISCONNECT,
00053       ON_UNSUBSCRIBE_INTERFACES,
00054       PORT_CONNECT_LISTENER_NUM
00055     };
00056 
00082   class PortConnectListener
00083   {
00084   public:
00108     static const char* toString(PortConnectListenerType type);
00109 
00117     virtual ~PortConnectListener();
00118 
00134     virtual void operator()(const char* portname,
00135                             RTC::ConnectorProfile& profile) = 0;
00136   };
00137 
00138 
00139   //============================================================
00161   enum PortConnectRetListenerType
00162     {
00163       ON_PUBLISH_INTERFACES,
00164       ON_CONNECT_NEXTPORT,
00165       ON_SUBSCRIBE_INTERFACES,
00166       ON_CONNECTED,
00167       ON_DISCONNECT_NEXT,
00168       ON_DISCONNECTED,
00169       PORT_CONNECT_RET_LISTENER_NUM
00170     };
00171 
00202   class PortConnectRetListener
00203   {
00204   public:
00228     static const char* toString(PortConnectRetListenerType type);
00229 
00237     virtual ~PortConnectRetListener();
00238 
00254     virtual void operator()(const char* portname,
00255                             RTC::ConnectorProfile& profile,
00256                             ReturnCode_t ret) = 0;
00257   };
00258 
00259   //============================================================
00276   class PortConnectListenerHolder
00277   {
00278     typedef std::pair<PortConnectListener*, bool> Entry;
00279     typedef coil::Guard<coil::Mutex> Guard;
00280   public:
00288     PortConnectListenerHolder();
00289     
00297     virtual ~PortConnectListenerHolder();
00298     
00320     void addListener(PortConnectListener* listener, bool autoclean);
00321     
00339     void removeListener(PortConnectListener* listener);
00340 
00358     void notify(const char* portname, RTC::ConnectorProfile& profile);
00359       
00360   private:
00361     std::vector<Entry> m_listeners;
00362     coil::Mutex m_mutex;
00363   };
00364 
00365 
00382   class PortConnectRetListenerHolder
00383   {
00384     typedef std::pair<PortConnectRetListener*, bool> Entry;
00385     typedef coil::Guard<coil::Mutex> Guard;
00386   public:
00394     PortConnectRetListenerHolder();
00395 
00403     virtual ~PortConnectRetListenerHolder();
00404     
00426     void addListener(PortConnectRetListener* listener, bool autoclean);
00427     
00445     void removeListener(PortConnectRetListener* listener);
00446     
00466     void notify(const char* portname, RTC::ConnectorProfile& profile,
00467                 ReturnCode_t ret);
00468     
00469   private:
00470     std::vector<Entry> m_listeners;
00471     coil::Mutex m_mutex;
00472   };
00473 
00487   class PortConnectListeners
00488   {
00489   public:
00499     PortConnectListenerHolder 
00500     portconnect_[PORT_CONNECT_LISTENER_NUM];
00510     PortConnectRetListenerHolder 
00511     portconnret_[PORT_CONNECT_RET_LISTENER_NUM];
00512   };
00513 
00514 
00515 }; // namespace RTC
00516 
00517 #endif // RTC_PORTCONNECTLISTENER_H


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