PublisherNew.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef RTC_PUBLISHERNEW_H
21 #define RTC_PUBLISHERNEW_H
22 
23 #include <coil/Task.h>
24 #include <coil/Mutex.h>
25 #include <coil/Condition.h>
26 #include <coil/PeriodicTask.h>
27 
28 #include <rtm/RTC.h>
29 #include <rtm/PublisherBase.h>
30 #include <rtm/CdrBufferBase.h>
31 #include <rtm/DataPortStatus.h>
32 #include <rtm/SystemLogger.h>
33 #include <rtm/ConnectorBase.h>
34 #include <rtm/ConnectorListener.h>
35 
36 namespace coil
37 {
38  class Properties;
39 };
40 
41 namespace RTC
42 {
43  class InPortConsumer;
44 
70  : public PublisherBase
71  {
72  public:
73  typedef coil::Mutex Mutex;
77 
91  PublisherNew();
92 
106  virtual ~PublisherNew(void);
107 
159  virtual ReturnCode init(coil::Properties& prop);
160 
186  virtual ReturnCode setConsumer(InPortConsumer* consumer);
187 
213  virtual ReturnCode setBuffer(CdrBufferBase* buffer);
214 
248  virtual ReturnCode setListener(ConnectorInfo& info,
249  ConnectorListeners* listeners);
250 
326  virtual ReturnCode write(const cdrMemoryStream& data,
327  unsigned long sec,
328  unsigned long usec);
329 
357  virtual bool isActive();
358 
384  virtual ReturnCode activate();
385 
411  virtual ReturnCode deactivate();
412 
426  virtual int svc(void);
427 
428  protected:
429  enum Policy
430  {
434  NEW
435  };
436 
444  void setPushPolicy(const coil::Properties& prop);
445 
453  bool createTask(const coil::Properties& prop);
454 
458  ReturnCode pushAll();
459 
463  ReturnCode pushFifo();
464 
468  ReturnCode pushSkip();
469 
473  ReturnCode pushNew();
474 
530  ReturnCode convertReturn(BufferStatus::Enum status,
531  const cdrMemoryStream& data);
532 
550  ReturnCode invokeListener(DataPortStatus::Enum status,
551  const cdrMemoryStream& data);
552 
562  inline void onBufferWrite(const cdrMemoryStream& data)
563  {
564  m_listeners->
565  connectorData_[ON_BUFFER_WRITE].notify(m_profile, data);
566  }
567 
577  inline void onBufferFull(const cdrMemoryStream& data)
578  {
579  m_listeners->
580  connectorData_[ON_BUFFER_FULL].notify(m_profile, data);
581  }
582 
592  inline void onBufferWriteTimeout(const cdrMemoryStream& data)
593  {
594  m_listeners->
595  connectorData_[ON_BUFFER_WRITE_TIMEOUT].notify(m_profile, data);
596  }
597 
607  inline void onBufferWriteOverwrite(const cdrMemoryStream& data)
608  {
609  m_listeners->
610  connectorData_[ON_BUFFER_OVERWRITE].notify(m_profile, data);
611  }
612 
622  inline void onBufferRead(const cdrMemoryStream& data)
623  {
624  m_listeners->
625  connectorData_[ON_BUFFER_READ].notify(m_profile, data);
626  }
627 
637  inline void onSend(const cdrMemoryStream& data)
638  {
639  m_listeners->
640  connectorData_[ON_SEND].notify(m_profile, data);
641  }
642 
652  inline void onReceived(const cdrMemoryStream& data)
653  {
654  m_listeners->
655  connectorData_[ON_RECEIVED].notify(m_profile, data);
656  }
657 
667  inline void onReceiverFull(const cdrMemoryStream& data)
668  {
669  m_listeners->
670  connectorData_[ON_RECEIVER_FULL].notify(m_profile, data);
671  }
672 
682  inline void onReceiverTimeout(const cdrMemoryStream& data)
683  {
684  m_listeners->
685  connectorData_[ON_RECEIVER_TIMEOUT].notify(m_profile, data);
686  }
687 
697  inline void onReceiverError(const cdrMemoryStream& data)
698  {
699  m_listeners->
700  connectorData_[ON_RECEIVER_ERROR].notify(m_profile, data);
701  }
702 
712  inline void onSenderError()
713  {
714  m_listeners->
715  connector_[ON_SENDER_ERROR].notify(m_profile);
716  }
717 
718 
719  private:
727  Mutex m_retmutex;
729  int m_skipn;
730  bool m_active;
732  };
733 }; // namespace RTC
734 
735 extern "C"
736 {
738 };
739 
740 #endif // RTC_PUBLISHERNEW_H
741 
ConnectorListeners class.
InPortConsumer abstract class.
coil::Guard< coil::Mutex > Guard
Definition: PublisherNew.h:75
#define DATAPORTSTATUS_ENUM
Importing RTC::DataPortStatus macro.
ConnectorListeners * m_listeners
Definition: PublisherNew.h:725
DataPortStatus class.
RT-Component.
Mutex class.
RT component logger class.
coil::Mutex Mutex
Definition: PublisherNew.h:73
void onBufferWrite(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE event to listeners.
Definition: PublisherNew.h:562
void onSenderError()
Notify an ON_SENDER_ERROR event to listeners.
Definition: PublisherNew.h:712
void onBufferFull(const cdrMemoryStream &data)
Notify an ON_BUFFER_FULL event to listeners.
Definition: PublisherNew.h:577
Enum
DataPortStatus return codes.
Definition: BufferStatus.h:84
void onBufferWriteOverwrite(const cdrMemoryStream &data)
Notify an ON_BUFFER_OVERWRITE event to listeners.
Definition: PublisherNew.h:607
void onBufferWriteTimeout(const cdrMemoryStream &data)
Notify an ON_BUFFER_WRITE_TIMEOUT event to listeners.
Definition: PublisherNew.h:592
Connector base class.
void onBufferRead(const cdrMemoryStream &data)
Notify an ON_BUFFER_READ event to listeners.
Definition: PublisherNew.h:622
void onReceiverError(const cdrMemoryStream &data)
Notify an ON_RECEIVER_ERROR event to listeners.
Definition: PublisherNew.h:697
void onReceiverTimeout(const cdrMemoryStream &data)
Notify an ON_RECEIVER_TIMEOUT event to listeners.
Definition: PublisherNew.h:682
#define DLL_EXPORT
Definition: PluginC.cpp:8
Condition template class.
PeriodicTaskBase class.
prop
Organization::get_organization_property ();.
Publisher base class.
CdrBufferBase * m_buffer
Definition: PublisherNew.h:722
Class represents a set of properties.
Definition: Properties.h:101
coil::PeriodicTaskBase * m_task
Definition: PublisherNew.h:724
Base class of Publisher.
Definition: PublisherBase.h:63
void DLL_EXPORT PublisherNewInit()
RTComponent header.
ReturnCode m_retcode
Definition: PublisherNew.h:726
void onReceiverFull(const cdrMemoryStream &data)
Notify an ON_RECEIVER_FULL event to listeners.
Definition: PublisherNew.h:667
coil::Condition< Mutex > Condition
Definition: PublisherNew.h:74
BufferBase abstract class.
Definition: BufferBase.h:104
void onReceived(const cdrMemoryStream &data)
Notify an ON_RECEIVED event to listeners.
Definition: PublisherNew.h:652
connector listener class
void onSend(const cdrMemoryStream &data)
Notify an ON_SEND event to listners.
Definition: PublisherNew.h:637
Enum
DataPortStatus return codes.
ConnectorInfo m_profile
Definition: PublisherNew.h:723
Common Object Interface Layer.
InPortConsumer * m_consumer
Definition: PublisherNew.h:721


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Thu Jun 6 2019 19:25:59