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 DATAPORTSTATUS_ENUM 00066 00080 PublisherFlush(); 00081 00095 virtual ~PublisherFlush(void); 00096 00121 virtual ReturnCode init(coil::Properties& prop); 00122 00148 virtual ReturnCode setConsumer(InPortConsumer* consumer); 00149 00171 virtual ReturnCode setBuffer(CdrBufferBase* buffer); 00172 00206 virtual ::RTC::DataPortStatus::Enum 00207 setListener(ConnectorInfo& profile, 00208 RTC::ConnectorListeners* listeners); 00209 00268 virtual ReturnCode write(const cdrMemoryStream& data, 00269 unsigned long sec, 00270 unsigned long usec); 00298 virtual bool isActive(); 00299 00325 virtual ReturnCode activate(); 00326 00352 virtual ReturnCode deactivate(); 00353 00354 protected: 00364 inline void onSend(const cdrMemoryStream& data) 00365 { 00366 m_listeners-> 00367 connectorData_[ON_SEND].notify(m_profile, data); 00368 } 00369 00379 inline void onReceived(const cdrMemoryStream& data) 00380 { 00381 m_listeners-> 00382 connectorData_[ON_RECEIVED].notify(m_profile, data); 00383 } 00384 00394 inline void onReceiverFull(const cdrMemoryStream& data) 00395 { 00396 m_listeners-> 00397 connectorData_[ON_RECEIVER_FULL].notify(m_profile, data); 00398 } 00399 00409 inline void onReceiverTimeout(const cdrMemoryStream& data) 00410 { 00411 m_listeners-> 00412 connectorData_[ON_RECEIVER_TIMEOUT].notify(m_profile, data); 00413 } 00414 00424 inline void onReceiverError(const cdrMemoryStream& data) 00425 { 00426 m_listeners-> 00427 connectorData_[ON_RECEIVER_ERROR].notify(m_profile, data); 00428 } 00429 00430 private: 00431 Logger rtclog; 00432 InPortConsumer* m_consumer; 00433 ConnectorInfo m_profile; 00434 ConnectorListeners* m_listeners; 00435 ReturnCode m_retcode; 00436 Mutex m_retmutex; 00437 bool m_active; 00438 }; 00439 00440 }; // namespace RTC 00441 00442 extern "C" 00443 { 00444 void DLL_EXPORT PublisherFlushInit(); 00445 }; 00446 00447 #endif // RTC_PUBLISHERFLUSH_H 00448