00001
00019 #ifndef RTC_PORTCONNECTLISTENER_H
00020 #define RTC_PORTCONNECTLISTENER_H
00021
00022 #include <vector>
00023 #include <utility>
00024 #include <rtm/RTC.h>
00025 #include <rtm/idl/RTCSkel.h>
00026
00027 namespace RTC
00028 {
00029
00047 enum PortConnectListenerType
00048 {
00049 ON_NOTIFY_CONNECT,
00050 ON_NOTIFY_DISCONNECT,
00051 ON_UNSUBSCRIBE_INTERFACES,
00052 PORT_CONNECT_LISTENER_NUM
00053 };
00054
00080 class PortConnectListener
00081 {
00082 public:
00106 static const char* toString(PortConnectListenerType type);
00107
00115 virtual ~PortConnectListener();
00116
00132 virtual void operator()(const char* portname,
00133 RTC::ConnectorProfile& profile) = 0;
00134 };
00135
00136
00137
00159 enum PortConnectRetListenerType
00160 {
00161 ON_PUBLISH_INTERFACES,
00162 ON_CONNECT_NEXTPORT,
00163 ON_SUBSCRIBE_INTERFACES,
00164 ON_CONNECTED,
00165 ON_DISCONNECT_NEXT,
00166 ON_DISCONNECTED,
00167 PORT_CONNECT_RET_LISTENER_NUM
00168 };
00169
00200 class PortConnectRetListener
00201 {
00202 public:
00226 static const char* toString(PortConnectRetListenerType type);
00227
00235 virtual ~PortConnectRetListener();
00236
00252 virtual void operator()(const char* portname,
00253 RTC::ConnectorProfile& profile,
00254 ReturnCode_t ret) = 0;
00255 };
00256
00257
00274 class PortConnectListenerHolder
00275 {
00276 typedef std::pair<PortConnectListener*, bool> Entry;
00277 public:
00285 PortConnectListenerHolder();
00286
00294 virtual ~PortConnectListenerHolder();
00295
00317 void addListener(PortConnectListener* listener, bool autoclean);
00318
00336 void removeListener(PortConnectListener* listener);
00337
00355 void notify(const char* portname, RTC::ConnectorProfile& profile);
00356
00357 private:
00358 std::vector<Entry> m_listeners;
00359 };
00360
00361
00378 class PortConnectRetListenerHolder
00379 {
00380 typedef std::pair<PortConnectRetListener*, bool> Entry;
00381 public:
00389 PortConnectRetListenerHolder();
00390
00398 virtual ~PortConnectRetListenerHolder();
00399
00421 void addListener(PortConnectRetListener* listener, bool autoclean);
00422
00440 void removeListener(PortConnectRetListener* listener);
00441
00461 void notify(const char* portname, RTC::ConnectorProfile& profile,
00462 ReturnCode_t ret);
00463
00464 private:
00465 std::vector<Entry> m_listeners;
00466 };
00467
00481 class PortConnectListeners
00482 {
00483 public:
00493 PortConnectListenerHolder
00494 portconnect_[PORT_CONNECT_LISTENER_NUM];
00504 PortConnectRetListenerHolder
00505 portconnret_[PORT_CONNECT_RET_LISTENER_NUM];
00506 };
00507
00508
00509 };
00510
00511 #endif // RTC_PORTCONNECTLISTENER_H