OpenRTM-aist  1.2.2
ComponentActionListener.h
Go to the documentation of this file.
1 // -*- C++ -*-
19 #ifndef RTC_COMPONENTACTIONLISTENER_H
20 #define RTC_COMPONENTACTIONLISTENER_H
21 
22 #include <vector>
23 #include <utility>
24 #include <coil/Mutex.h>
25 #include <coil/Guard.h>
26 #include <rtm/RTC.h>
27 #include <rtm/idl/RTCSkel.h>
28 #include <rtm/ConnectorBase.h>
29 
30 namespace RTC
31 {
32  typedef ExecutionContextHandle_t UniqueId;
33  //============================================================
58  {
72  };
73 
121  {
122  public:
146  static const char* toString(PreComponentActionListenerType type)
147  {
148  static const char* typeString[] =
149  {
150  "PRE_ON_INITIALIZE",
151  "PRE_ON_FINALIZE",
152  "PRE_ON_STARTUP",
153  "PRE_ON_SHUTDOWN",
154  "PRE_ON_ACTIVATED",
155  "PRE_ON_DEACTIVATED",
156  "PRE_ON_ABORTING",
157  "PRE_ON_ERROR",
158  "PRE_ON_RESET",
159  "PRE_ON_EXECUTE",
160  "PRE_ON_STATE_UPDATE",
161  "PRE_ON_RATE_CHANGED",
162  "PRE_COMPONENT_ACTION_LISTENER_NUM"
163  };
164  if (type < PRE_COMPONENT_ACTION_LISTENER_NUM) { return typeString[type]; }
165  return "";
166  }
167 
175  virtual ~PreComponentActionListener();
176 
192  virtual void operator()(UniqueId ec_id) = 0;
193  };
194 
195 
196  //============================================================
220  {
234  };
235 
236 
284  {
285  public:
309  static const char* toString(PostComponentActionListenerType type)
310  {
311  static const char* typeString[] =
312  {
313  "POST_ON_INITIALIZE",
314  "POST_ON_FINALIZE",
315  "POST_ON_STARTUP",
316  "POST_ON_SHUTDOWN",
317  "POST_ON_ACTIVATED",
318  "POST_ON_DEACTIVATED",
319  "POST_ON_ABORTING",
320  "POST_ON_ERROR",
321  "POST_ON_RESET",
322  "POST_ON_EXECUTE",
323  "POST_ON_STATE_UPDATE",
324  "POST_ON_RATE_CHANGED",
325  "POST_COMPONENT_ACTION_LISTENER_NUM"
326  };
328  {
329  return typeString[type];
330  }
331  return "";
332  }
333 
342 
358  virtual void operator()(UniqueId ec_id,
359  ReturnCode_t ret) = 0;
360  };
361 
362  //============================================================
377  {
381  };
382 
404  {
405  public:
429  static const char* toString(PortActionListenerType type)
430  {
431  static const char* typeString[] =
432  {
433  "ADD_PORT",
434  "REMOVE_PORT",
435  "PORT_ACTION_LISTENER_NUM"
436  };
437  if (type < PORT_ACTION_LISTENER_NUM) { return typeString[type]; }
438  return "";
439  }
440 
448  virtual ~PortActionListener();
449 
465  virtual void operator()(const ::RTC::PortProfile& pprof) = 0;
466  };
467 
468 
469  //============================================================
484  {
488  };
489 
511  {
512  public:
537  {
538  static const char* typeString[] =
539  {
540  "ATTACH_EC",
541  "DETACH_ECT",
542  "EC_ACTION_LISTENER_NUM"
543  };
544  if (type < EC_ACTION_LISTENER_NUM) { return typeString[type]; }
545  return "";
546  }
547 
556 
572  virtual void operator()(UniqueId ec_id) = 0;
573  };
574 
575 
576 
577  //============================================================
595  {
596  typedef std::pair<PreComponentActionListener*, bool> Entry;
598  public:
607 
616 
638  void addListener(PreComponentActionListener* listener, bool autoclean);
639 
658 
676  void notify(UniqueId ec_id);
677 
678  private:
679  std::vector<Entry> m_listeners;
680  coil::Mutex m_mutex;
681  };
682 
683 
701  {
702  typedef std::pair<PostComponentActionListener*, bool> Entry;
704  public:
721 
743  void addListener(PostComponentActionListener* listener, bool autoclean);
744 
763 
783  void notify(UniqueId ec_id, ReturnCode_t ret);
784 
785  private:
786  std::vector<Entry> m_listeners;
787  coil::Mutex m_mutex;
788  };
789 
790 
791  //============================================================
809  {
810  typedef std::pair<PortActionListener*, bool> Entry;
812  public:
828  virtual ~PortActionListenerHolder();
829 
851  void addListener(PortActionListener* listener, bool autoclean);
852 
870  void removeListener(PortActionListener* listener);
871 
891  void notify(const RTC::PortProfile& pprofile);
892 
893  private:
894  std::vector<Entry> m_listeners;
895  coil::Mutex m_mutex;
896  };
897 
915  {
916  typedef std::pair<ExecutionContextActionListener*, bool> Entry;
918  public:
935 
957  void addListener(ExecutionContextActionListener* listener, bool autoclean);
958 
977 
997  void notify(UniqueId ec_id);
998 
999  private:
1000  std::vector<Entry> m_listeners;
1001  coil::Mutex m_mutex;
1002  };
1003 
1004 
1019  {
1020  public:
1065  };
1066 
1067 
1068 }; // namespace RTC
1069 
1070 #endif // RTC_COMPONENTACTIONLISTENER_H
RTC::PostComponentActionListenerHolder::PostComponentActionListenerHolder
PostComponentActionListenerHolder()
Constructor.
RTC::PRE_ON_STARTUP
@ PRE_ON_STARTUP
Definition: ComponentActionListener.h:61
RTC::PRE_ON_SHUTDOWN
@ PRE_ON_SHUTDOWN
Definition: ComponentActionListener.h:62
RTC::PostComponentActionListenerHolder
PostComponentActionListener holder class.
Definition: ComponentActionListener.h:700
RTC::POST_ON_FINALIZE
@ POST_ON_FINALIZE
Definition: ComponentActionListener.h:222
RTC::PRE_ON_INITIALIZE
@ PRE_ON_INITIALIZE
Definition: ComponentActionListener.h:59
RTC::POST_ON_ACTIVATED
@ POST_ON_ACTIVATED
Definition: ComponentActionListener.h:225
RTC::PostComponentActionListener::operator()
virtual void operator()(UniqueId ec_id, ReturnCode_t ret)=0
Virtual Callback function.
RTC::ExecutionContextActionListenerHolder::addListener
void addListener(ExecutionContextActionListener *listener, bool autoclean)
Add the listener.
RTC::EC_ATTACHED
@ EC_ATTACHED
Definition: ComponentActionListener.h:485
RTC::PreComponentActionListener::~PreComponentActionListener
virtual ~PreComponentActionListener()
Destructor.
RTC::PreComponentActionListenerType
PreComponentActionListenerType
The types of ConnectorDataListener.
Definition: ComponentActionListener.h:57
coil::Mutex
Mutex class.
Definition: Mutex.h:40
RTC::POST_ON_ABORTING
@ POST_ON_ABORTING
Definition: ComponentActionListener.h:227
RTC::PreComponentActionListenerHolder::notify
void notify(UniqueId ec_id)
Notify listeners.
RTC::PortActionListener::~PortActionListener
virtual ~PortActionListener()
Destructor.
RTC::ExecutionContextActionListenerHolder::ExecutionContextActionListenerHolder
ExecutionContextActionListenerHolder()
Constructor.
RTC::ComponentActionListeners::ecaction_
ExecutionContextActionListenerHolder ecaction_[EC_ACTION_LISTENER_NUM]
ExecutionContextActionType listener array The ExecutionContextActionType listener is stored.
Definition: ComponentActionListener.h:1064
RTC::POST_ON_SHUTDOWN
@ POST_ON_SHUTDOWN
Definition: ComponentActionListener.h:224
RTC::PostComponentActionListenerHolder::notify
void notify(UniqueId ec_id, ReturnCode_t ret)
Notify listeners.
RTC::PostComponentActionListener::~PostComponentActionListener
virtual ~PostComponentActionListener()
Destructor.
RTC::EC_DETACHED
@ EC_DETACHED
Definition: ComponentActionListener.h:486
RTC::PORT_ACTION_LISTENER_NUM
@ PORT_ACTION_LISTENER_NUM
Definition: ComponentActionListener.h:380
RTC::PRE_ON_STATE_UPDATE
@ PRE_ON_STATE_UPDATE
Definition: ComponentActionListener.h:69
RTC::PostComponentActionListenerHolder::removeListener
void removeListener(PostComponentActionListener *listener)
Remove the listener.
RTC::ExecutionContextActionListenerHolder::notify
void notify(UniqueId ec_id)
Notify listeners.
RTC::PRE_ON_RESET
@ PRE_ON_RESET
Definition: ComponentActionListener.h:67
RTC::POST_ON_RATE_CHANGED
@ POST_ON_RATE_CHANGED
Definition: ComponentActionListener.h:232
RTC::PreComponentActionListener
PreComponentActionListener class.
Definition: ComponentActionListener.h:120
Guard.h
Guard template class.
RTC::PortActionListenerHolder
PortActionListener holder class.
Definition: ComponentActionListener.h:808
RTC::PortActionListener
PortActionListener class.
Definition: ComponentActionListener.h:403
RTC::POST_ON_STATE_UPDATE
@ POST_ON_STATE_UPDATE
Definition: ComponentActionListener.h:231
RTC::POST_ON_INITIALIZE
@ POST_ON_INITIALIZE
Definition: ComponentActionListener.h:221
RTC::ExecutionContextActionListener::toString
static const char * toString(ExecutionContextActionListenerType type)
Convert PreComponentActionListenerType into the string.
Definition: ComponentActionListener.h:536
RTC::POST_COMPONENT_ACTION_LISTENER_NUM
@ POST_COMPONENT_ACTION_LISTENER_NUM
Definition: ComponentActionListener.h:233
RTC::PRE_COMPONENT_ACTION_LISTENER_NUM
@ PRE_COMPONENT_ACTION_LISTENER_NUM
Definition: ComponentActionListener.h:71
RTC::PreComponentActionListener::operator()
virtual void operator()(UniqueId ec_id)=0
Virtual Callback function.
RTC::PortActionListener::toString
static const char * toString(PortActionListenerType type)
Convert PreComponentActionListenerType into the string.
Definition: ComponentActionListener.h:429
RTC::ExecutionContextActionListener
ExecutionContextActionListener class.
Definition: ComponentActionListener.h:510
RTC::PostComponentActionListenerHolder::~PostComponentActionListenerHolder
virtual ~PostComponentActionListenerHolder()
Destructor.
RTC::POST_ON_RESET
@ POST_ON_RESET
Definition: ComponentActionListener.h:229
RTC::EC_ACTION_LISTENER_NUM
@ EC_ACTION_LISTENER_NUM
Definition: ComponentActionListener.h:487
RTC::POST_ON_EXECUTE
@ POST_ON_EXECUTE
Definition: ComponentActionListener.h:230
RTC::PreComponentActionListener::toString
static const char * toString(PreComponentActionListenerType type)
Convert PreComponentActionListenerType into the string.
Definition: ComponentActionListener.h:146
ConnectorBase.h
Connector base class.
RTC::ExecutionContextActionListenerHolder::~ExecutionContextActionListenerHolder
virtual ~ExecutionContextActionListenerHolder()
Destructor.
RTC::PreComponentActionListenerHolder::addListener
void addListener(PreComponentActionListener *listener, bool autoclean)
Add the listener.
RTC::ADD_PORT
@ ADD_PORT
Definition: ComponentActionListener.h:378
RTC::PRE_ON_RATE_CHANGED
@ PRE_ON_RATE_CHANGED
Definition: ComponentActionListener.h:70
RTC::ComponentActionListeners::portaction_
PortActionListenerHolder portaction_[PORT_ACTION_LISTENER_NUM]
PortActionType listener array The PortActionType listener is stored.
Definition: ComponentActionListener.h:1053
RTC::PortActionListener::operator()
virtual void operator()(const ::RTC::PortProfile &pprof)=0
Virtual Callback function.
RTC::PostComponentActionListenerHolder::addListener
void addListener(PostComponentActionListener *listener, bool autoclean)
Add the listener.
RTC::PortActionListenerHolder::notify
void notify(const RTC::PortProfile &pprofile)
Notify listeners.
RTC::ComponentActionListeners
ComponentActionListeners class.
Definition: ComponentActionListener.h:1018
RTC::PreComponentActionListenerHolder::PreComponentActionListenerHolder
PreComponentActionListenerHolder()
Constructor.
RTC::PRE_ON_ERROR
@ PRE_ON_ERROR
Definition: ComponentActionListener.h:66
RTC::PRE_ON_FINALIZE
@ PRE_ON_FINALIZE
Definition: ComponentActionListener.h:60
RTC::ComponentActionListeners::postaction_
PostComponentActionListenerHolder postaction_[POST_COMPONENT_ACTION_LISTENER_NUM]
PostComponentActionType listener array The PostComponentActionType listener is stored.
Definition: ComponentActionListener.h:1042
RTC::PRE_ON_EXECUTE
@ PRE_ON_EXECUTE
Definition: ComponentActionListener.h:68
RTC::ComponentActionListeners::preaction_
PreComponentActionListenerHolder preaction_[PRE_COMPONENT_ACTION_LISTENER_NUM]
PreComponentActionListenerType listener array The PreComponentActionListenerType listener is stored.
Definition: ComponentActionListener.h:1031
RTC::PortActionListenerHolder::~PortActionListenerHolder
virtual ~PortActionListenerHolder()
Destructor.
Mutex.h
coil::Guard< coil::Mutex >
RTC::PRE_ON_DEACTIVATED
@ PRE_ON_DEACTIVATED
Definition: ComponentActionListener.h:64
RTC::PreComponentActionListenerHolder::removeListener
void removeListener(PreComponentActionListener *listener)
Remove the listener.
RTC::POST_ON_STARTUP
@ POST_ON_STARTUP
Definition: ComponentActionListener.h:223
RTC::PreComponentActionListenerHolder
PreComponentActionListener holder class.
Definition: ComponentActionListener.h:594
RTC::UniqueId
ExecutionContextHandle_t UniqueId
Definition: ComponentActionListener.h:32
RTC
RT-Component.
RTC::PortActionListenerHolder::addListener
void addListener(PortActionListener *listener, bool autoclean)
Add the listener.
RTC::PostComponentActionListenerType
PostComponentActionListenerType
The types of ConnectorDataListener.
Definition: ComponentActionListener.h:219
RTC::ExecutionContextActionListener::operator()
virtual void operator()(UniqueId ec_id)=0
Virtual Callback function.
RTC.h
RTComponent header.
RTC::POST_ON_DEACTIVATED
@ POST_ON_DEACTIVATED
Definition: ComponentActionListener.h:226
RTC::PortActionListenerType
PortActionListenerType
The types of PortActionListener.
Definition: ComponentActionListener.h:376
RTC::PortActionListenerHolder::removeListener
void removeListener(PortActionListener *listener)
Remove the listener.
RTC::PostComponentActionListener::toString
static const char * toString(PostComponentActionListenerType type)
Convert PostComponentActionListenerType into the string.
Definition: ComponentActionListener.h:309
RTC::POST_ON_ERROR
@ POST_ON_ERROR
Definition: ComponentActionListener.h:228
RTC::PRE_ON_ACTIVATED
@ PRE_ON_ACTIVATED
Definition: ComponentActionListener.h:63
RTC::PostComponentActionListener
PostComponentActionListener class.
Definition: ComponentActionListener.h:283
RTC::PortActionListenerHolder::PortActionListenerHolder
PortActionListenerHolder()
Constructor.
RTC::ExecutionContextActionListener::~ExecutionContextActionListener
virtual ~ExecutionContextActionListener()
Destructor.
RTC::PRE_ON_ABORTING
@ PRE_ON_ABORTING
Definition: ComponentActionListener.h:65
RTC::PreComponentActionListenerHolder::~PreComponentActionListenerHolder
virtual ~PreComponentActionListenerHolder()
Destructor.
RTC::REMOVE_PORT
@ REMOVE_PORT
Definition: ComponentActionListener.h:379
RTC::ExecutionContextActionListenerHolder
ExecutionContextActionListener holder class.
Definition: ComponentActionListener.h:914
RTC::ExecutionContextActionListenerType
ExecutionContextActionListenerType
The types of ExecutionContextActionListener.
Definition: ComponentActionListener.h:483
RTC::ExecutionContextActionListenerHolder::removeListener
void removeListener(ExecutionContextActionListener *listener)
Remove the listener.