OpenRTM  1.0.0
PublisherFlush.h
説明を見る。
1 // -*- C++ -*-
20 #ifndef RTC_PUBLISHERFLUSH_H
21 #define RTC_PUBLISHERFLUSH_H
22 
23 #include <coil/Condition.h>
24 #include <rtm/PublisherBase.h>
25 #include <rtm/SystemLogger.h>
26 #include <rtm/ConnectorBase.h>
27 #include <rtm/ConnectorListener.h>
28 
29 namespace coil
30 {
31  class Properties;
32 };
33 
34 namespace RTC
35 {
36  class InPortConsumer;
37 
59  : public PublisherBase
60  {
61  public:
62  typedef coil::Mutex Mutex;
66 
81 
95  virtual ~PublisherFlush(void);
96 
121  virtual ReturnCode init(coil::Properties& prop);
122 
148  virtual ReturnCode setConsumer(InPortConsumer* consumer);
149 
171  virtual ReturnCode setBuffer(CdrBufferBase* buffer);
172 
206  virtual ::RTC::DataPortStatus::Enum
207  setListener(ConnectorInfo& profile,
208  RTC::ConnectorListeners* listeners);
209 
268  virtual ReturnCode write(const cdrMemoryStream& data,
269  unsigned long sec,
270  unsigned long usec);
298  virtual bool isActive();
299 
325  virtual ReturnCode activate();
326 
352  virtual ReturnCode deactivate();
353 
354  protected:
364  inline void onSend(const cdrMemoryStream& data)
365  {
366  m_listeners->
367  connectorData_[ON_SEND].notify(m_profile, data);
368  }
369 
379  inline void onReceived(const cdrMemoryStream& data)
380  {
381  m_listeners->
382  connectorData_[ON_RECEIVED].notify(m_profile, data);
383  }
384 
394  inline void onReceiverFull(const cdrMemoryStream& data)
395  {
396  m_listeners->
397  connectorData_[ON_RECEIVER_FULL].notify(m_profile, data);
398  }
399 
409  inline void onReceiverTimeout(const cdrMemoryStream& data)
410  {
411  m_listeners->
412  connectorData_[ON_RECEIVER_TIMEOUT].notify(m_profile, data);
413  }
414 
424  inline void onReceiverError(const cdrMemoryStream& data)
425  {
426  m_listeners->
427  connectorData_[ON_RECEIVER_ERROR].notify(m_profile, data);
428  }
429 
430  private:
431  Logger rtclog;
432  InPortConsumer* m_consumer;
433  ConnectorInfo m_profile;
434  ConnectorListeners* m_listeners;
435  ReturnCode m_retcode;
436  Mutex m_retmutex;
437  bool m_active;
438  };
439 
440 }; // namespace RTC
441 
442 extern "C"
443 {
445 };
446 
447 #endif // RTC_PUBLISHERFLUSH_H
448