PublisherFlush.cpp
Go to the documentation of this file.
1 // -*- C++ -*-
20 #include <coil/Properties.h>
21 #include <rtm/RTC.h>
22 #include <rtm/PublisherBase.h>
23 #include <rtm/PublisherFlush.h>
24 #include <rtm/InPortConsumer.h>
25 #include <rtm/ConnectorListener.h>
26 
27 namespace RTC
28 {
37  : rtclog("PublisherFlush"),
38  m_consumer(0), m_listeners(0), m_active(false),
39  m_retcode(PORT_OK)
40  {
41  }
42 
51  {
52  RTC_TRACE(("~PublisherFlush()"));
53  // "consumer" should be deleted in the Connector
54  m_consumer = 0;
55  }
56 
65  {
66  RTC_TRACE(("init()"));
67  return PORT_OK;
68  }
69 
79  {
80  RTC_TRACE(("setConsumer()"));
81 
82  if (consumer == 0)
83  {
84  return INVALID_ARGS;
85  }
86  m_consumer = consumer;
87  return PORT_OK;
88  }
89 
98  {
99  RTC_TRACE(("setBuffer()"));
100 
101  return PORT_OK;
102  }
103 
113  RTC::ConnectorListeners* listeners)
114  {
115  RTC_TRACE(("setListeners()"));
116 
117  if (listeners == 0)
118  {
119  RTC_ERROR(("setListeners(listeners == 0): invalid argument"));
120  return INVALID_ARGS;
121  }
122 
123  m_profile = info;
124  m_listeners = listeners;
125 
126  return PORT_OK;
127  }
128 
137  unsigned long sec,
138  unsigned long usec)
139  {
140  RTC_PARANOID(("write()"));
141 
142  if (m_consumer == 0) { return PRECONDITION_NOT_MET; }
143  if (m_listeners == 0) { return PRECONDITION_NOT_MET; }
144 
145  if (m_retcode == CONNECTION_LOST)
146  {
147  RTC_DEBUG(("write(): connection lost."));
148  return m_retcode;
149  }
150 
151  onSend(data);
152  ReturnCode ret(m_consumer->put(data));
153  // consumer::put() returns
154  // {PORT_OK, PORT_ERROR, SEND_FULL, SEND_TIMEOUT, UNKNOWN_ERROR}
155 
156  switch (ret)
157  {
158  case PORT_OK:
159  onReceived(data);
160  return ret;
161  case PORT_ERROR:
162  onReceiverError(data);
163  return ret;
164  case SEND_FULL:
165  onReceiverFull(data);
166  return ret;
167  case SEND_TIMEOUT:
168  onReceiverTimeout(data);
169  return ret;
170  case CONNECTION_LOST:
171  onReceiverTimeout(data);
172  return ret;
173  case UNKNOWN_ERROR:
174  onReceiverError(data);
175  return ret;
176  default:
177  onReceiverError(data);
178  return ret;
179  }
180  return ret;
181  }
182 
191  {
192  return m_active;
193  }
194 
203  {
204  m_active = true;
205  return PORT_OK;
206  }
207 
216  {
217  m_active = false;
218  return PORT_OK;
219  }
220 
221 }; // namespace RTC
222 
223 
224 extern "C"
225 {
227  {
229  instance().addFactory("flush",
234  }
235 };
236 
ConnectorListeners class.
InPortConsumer abstract class.
#define RTC_ERROR(fmt)
Error log output macro.
Definition: SystemLogger.h:422
InPortConsumer * m_consumer
virtual ReturnCode write(const cdrMemoryStream &data, unsigned long sec, unsigned long usec)
Write data.
virtual ReturnCode deactivate()
deactivation
RT-Component.
virtual ::RTC::DataPortStatus::Enum setListener(ConnectorInfo &profile, RTC::ConnectorListeners *listeners)
Set the listener.
virtual ReturnCode init(coil::Properties &prop)
initialization
virtual ReturnCode setConsumer(InPortConsumer *consumer)
Store InPort consumer.
void onReceiverError(const cdrMemoryStream &data)
Notify an ON_RECEIVER_ERROR event to listeners.
AbstractClass * Creator()
Creator template.
RTC::ReturnCode_t ret(RTC::Local::ReturnCode_t r)
static GlobalFactory< AbstractClass, Identifier, Compare, Creator, Destructor > & instance()
Create instance.
Definition: Singleton.h:131
Enum
DataPortStatus return codes.
Definition: BufferStatus.h:84
void onReceived(const cdrMemoryStream &data)
Notify an ON_RECEIVED event to listeners.
#define RTC_PARANOID(fmt)
Paranoid level log output macro.
Definition: SystemLogger.h:555
virtual ReturnCode setBuffer(CdrBufferBase *buffer)
Setting buffer pointer.
PublisherFlush class.
#define RTC_DEBUG(fmt)
Debug level log output macro.
Definition: SystemLogger.h:488
#define RTC_TRACE(fmt)
void onSend(const cdrMemoryStream &data)
Notify an ON_SEND event to listners.
void onReceiverTimeout(const cdrMemoryStream &data)
Notify an ON_RECEIVER_TIMEOUT event to listeners.
virtual bool isActive()
If publisher is active state.
::RTC::BufferStatus::Enum ReturnCode
PublisherFlush class.
prop
Organization::get_organization_property ();.
Publisher base class.
void Destructor(AbstractClass *&obj)
Destructor template.
Class represents a set of properties.
Definition: Properties.h:101
ConnectorListeners * m_listeners
DATAPORTSTATUS_ENUM PublisherFlush()
Constructor.
Base class of Publisher.
Definition: PublisherBase.h:63
virtual ReturnCode activate()
activation
virtual ~PublisherFlush(void)
Destructor.
RTComponent header.
virtual ReturnCode put(const cdrMemoryStream &data)=0
Send data to the destination port.
BufferBase abstract class.
Definition: BufferBase.h:104
InPortConsumer class.
connector listener class
ConnectorInfo m_profile
Enum
DataPortStatus return codes.
void PublisherFlushInit()
void onReceiverFull(const cdrMemoryStream &data)
Notify an ON_RECEIVER_FULL event to listeners.


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Mon Jun 10 2019 14:07:54