00001 // -*- C++ -*- 00020 #ifndef RTC_PUBLISHERFLUSH_H 00021 #define RTC_PUBLISHERFLUSH_H 00022 00023 #include <coil/Condition.h> 00024 #include <rtm/PublisherBase.h> 00025 #include <rtm/SystemLogger.h> 00026 #include <rtm/ConnectorBase.h> 00027 #include <rtm/ConnectorListener.h> 00028 00029 namespace coil 00030 { 00031 class Properties; 00032 }; 00033 00034 namespace RTC 00035 { 00036 class InPortConsumer; 00037 00058 class PublisherFlush 00059 : public PublisherBase 00060 { 00061 public: 00062 typedef coil::Mutex Mutex; 00063 typedef coil::Condition<Mutex> Condition; 00064 typedef coil::Guard<coil::Mutex> Guard; 00065 00066 DATAPORTSTATUS_ENUM 00067 00088 PublisherFlush(); 00089 00105 virtual ~PublisherFlush(void); 00106 00114 virtual ReturnCode init(coil::Properties& prop); 00115 00124 virtual ReturnCode setConsumer(InPortConsumer* consumer); 00144 virtual ReturnCode setBuffer(CdrBufferBase* buffer); 00160 virtual ::RTC::DataPortStatus::Enum 00161 setListener(ConnectorInfo& profile, 00162 RTC::ConnectorListeners* listeners); 00178 virtual ReturnCode write(const cdrMemoryStream& data, 00179 unsigned long sec, 00180 unsigned long usec); 00201 virtual bool isActive(); 00214 virtual ReturnCode activate(); 00227 virtual ReturnCode deactivate(); 00228 00229 protected: 00233 // inline void onBufferWrite(const cdrMemoryStream& data) 00234 // { 00235 // m_listeners-> 00236 // connectorData_[ON_BUFFER_WRITE].notify(m_profile, data); 00237 // } 00238 00239 // inline void onBufferFull(const cdrMemoryStream& data) 00240 // { 00241 // m_listeners-> 00242 // connectorData_[ON_BUFFER_FULL].notify(m_profile, data); 00243 // } 00244 00245 // inline void onBufferWriteTimeout(const cdrMemoryStream& data) 00246 // { 00247 // m_listeners-> 00248 // connectorData_[ON_BUFFER_WRITE_TIMEOUT].notify(m_profile, data); 00249 // } 00250 00251 // inline void onBufferWriteOverwrite(const cdrMemoryStream& data) 00252 // { 00253 // m_listeners-> 00254 // connectorData_[ON_BUFFER_OVERWRITE].notify(m_profile, data); 00255 // } 00256 00257 // inline void onBufferRead(const cdrMemoryStream& data) 00258 // { 00259 // m_listeners-> 00260 // connectorData_[ON_BUFFER_READ].notify(m_profile, data); 00261 // } 00262 00272 inline void onSend(const cdrMemoryStream& data) 00273 { 00274 m_listeners-> 00275 connectorData_[ON_SEND].notify(m_profile, data); 00276 } 00277 00287 inline void onReceived(const cdrMemoryStream& data) 00288 { 00289 m_listeners-> 00290 connectorData_[ON_RECEIVED].notify(m_profile, data); 00291 } 00292 00302 inline void onReceiverFull(const cdrMemoryStream& data) 00303 { 00304 m_listeners-> 00305 connectorData_[ON_RECEIVER_FULL].notify(m_profile, data); 00306 } 00307 00317 inline void onReceiverTimeout(const cdrMemoryStream& data) 00318 { 00319 m_listeners-> 00320 connectorData_[ON_RECEIVER_TIMEOUT].notify(m_profile, data); 00321 } 00322 00332 inline void onReceiverError(const cdrMemoryStream& data) 00333 { 00334 m_listeners-> 00335 connectorData_[ON_RECEIVER_ERROR].notify(m_profile, data); 00336 } 00337 00341 // inline void onBufferEmpty() 00342 // { 00343 // m_listeners-> 00344 // connector_[ON_BUFFER_EMPTY].notify(m_profile); 00345 // } 00346 00347 // inline void onBufferReadTimeout() 00348 // { 00349 // m_listeners-> 00350 // connector_[ON_BUFFER_READ_TIMEOUT].notify(m_profile); 00351 // } 00352 00353 // inline void onSenderEmpty() 00354 // { 00355 // m_listeners-> 00356 // connector_[ON_SENDER_EMPTY].notify(m_profile); 00357 // } 00358 00359 // inline void onSenderTimeout() 00360 // { 00361 // m_listeners-> 00362 // connector_[ON_SENDER_TIMEOUT].notify(m_profile); 00363 // } 00364 00365 // inline void onSenderError() 00366 // { 00367 // m_listeners-> 00368 // connector_[ON_SENDER_ERROR].notify(m_profile); 00369 // } 00370 00371 00372 private: 00373 Logger rtclog; 00374 InPortConsumer* m_consumer; 00375 ConnectorInfo m_profile; 00376 ConnectorListeners* m_listeners; 00377 ReturnCode m_retcode; 00378 Mutex m_retmutex; 00379 bool m_active; 00380 }; 00381 00382 }; // namespace RTC 00383 00384 extern "C" 00385 { 00386 void DLL_EXPORT PublisherFlushInit(); 00387 }; 00388 00389 #endif // RTC_PUBLISHERFLUSH_H 00390