PublisherNew.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00020 #ifndef PublisherNew_h
00021 #define PublisherNew_h
00022 
00023 #include <coil/Task.h>
00024 #include <coil/Mutex.h>
00025 #include <coil/Condition.h>
00026 #include <coil/PeriodicTask.h>
00027 
00028 #include <rtm/RTC.h>
00029 #include <rtm/PublisherBase.h>
00030 #include <rtm/CdrBufferBase.h>
00031 #include <rtm/DataPortStatus.h>
00032 #include <rtm/SystemLogger.h>
00033 
00034 namespace coil
00035 {
00036   class Properties;
00037 };
00038 
00039 namespace RTC
00040 {
00041   class InPortConsumer;
00067   class PublisherNew
00068     : public PublisherBase
00069   {
00070   public:
00071     typedef coil::Mutex Mutex;
00072     typedef coil::Condition<Mutex> Condition;
00073     typedef coil::Guard<coil::Mutex> Guard;
00074     DATAPORTSTATUS_ENUM
00075     
00097     PublisherNew();
00098     
00112     virtual ~PublisherNew(void);
00113 
00121     virtual ReturnCode init(coil::Properties& prop);
00122     virtual ReturnCode setConsumer(InPortConsumer* consumer);
00123     virtual ReturnCode setBuffer(CdrBufferBase* buffer);
00124     virtual ReturnCode write(const cdrMemoryStream& data,
00125                      unsigned long sec,
00126                      unsigned long usec);
00127     virtual bool isActive();
00128     virtual ReturnCode activate();
00129     virtual ReturnCode deactivate();
00130     
00150     virtual int svc(void);
00151     
00175     //    virtual int open(void *args);
00176     
00196     //    virtual void release();
00197     
00198   protected:
00199     enum Policy
00200       {
00201         ALL,
00202         FIFO,
00203         SKIP,
00204         NEW
00205       };
00206 
00210     ReturnCode pushAll();
00214     ReturnCode pushFifo();
00218     ReturnCode pushSkip();
00222     ReturnCode pushNew();
00223 
00224     ReturnCode convertReturn(BufferStatus::Enum status);
00225     
00226   private:
00227     Logger rtclog;
00228     InPortConsumer* m_consumer;
00229     CdrBufferBase* m_buffer;
00230     coil::PeriodicTaskBase* m_task;
00231     ReturnCode m_retcode;
00232     Mutex m_retmutex;
00233     Policy m_pushPolicy;
00234     int m_skipn;
00235     bool m_active;
00236   };
00237 };     // namespace RTC
00238 
00239 extern "C"
00240 {
00241   void DLL_EXPORT PublisherNewInit();
00242 };
00243 
00244 #endif // PublisherNew_h
00245 

Generated on Sun May 24 14:08:45 2009 for OpenRTM by  doxygen 1.5.3