BufferBase.h
Go to the documentation of this file.
1 // -*- C++ -*-
20 #ifndef RTC_BUFFERBASE_H
21 #define RTC_BUFFERBASE_H
22 
23 #include <stddef.h>
24 #include <coil/Properties.h>
25 #include <rtm/BufferStatus.h>
26 
41 namespace RTC
42 {
103  template <class DataType>
105  : public BufferStatus
106  {
107  public:
109 
121  virtual ~BufferBase(void)
122  {
123  };
124 
136  virtual void init(const coil::Properties& prop) = 0;
137 
157  virtual size_t length(void) const = 0;
158 
183  virtual ReturnCode length(size_t n) = 0;
184 
208  virtual ReturnCode reset() = 0;
209 
210 
211  //----------------------------------------------------------------------
233  virtual DataType* wptr(long int n = 0) = 0;
234 
257  virtual ReturnCode advanceWptr(long int n = 1) = 0;
258 
284  virtual ReturnCode put(const DataType& value) = 0;
285 
311  virtual ReturnCode write(const DataType& value,
312  long int sec = -1, long int nsec = -1) = 0;
313 
335  virtual size_t writable() const = 0;
336 
356  virtual bool full(void) const = 0;
357 
358  //----------------------------------------------------------------------
379  virtual DataType* rptr(long int n = 0) = 0;
380 
403  virtual ReturnCode advanceRptr(long int n = 1) = 0;
404 
430  virtual ReturnCode get(DataType& value) = 0;
431 
451  virtual DataType& get() = 0;
452 
476  virtual ReturnCode read(DataType& value,
477  long int sec = -1, long int nsec = -1) = 0;
478 
500  virtual size_t readable() const = 0;
501 
521  virtual bool empty(void) const = 0;
522 
523  };
524 
551  template <class DataType>
553  : public BufferBase<DataType>
554  {
555  public:
577  NullBuffer(long int size = 1)
578  : m_length(1)
579  {
580  }
581 
597  virtual ~NullBuffer(void)
598  {
599  }
600 
620  virtual long int length(void) const
621  {
622  return 1;
623  }
624 
648  virtual bool write(const DataType& value)
649  {
650  m_data = value;
651  return true;
652  }
653 
677  virtual bool read(DataType& value)
678  {
679  value = m_data;
680  return true;
681  }
682 
702  virtual bool isFull(void) const
703  {
704  return false;
705  }
706 
726  virtual bool isEmpty(void) const
727  {
728  return false;
729  }
730 
731  protected:
751  virtual void put(const DataType& data)
752  {
753  m_data = data;
754  }
755 
775  virtual const DataType& get(void)
776  {
777  return m_data;
778  }
779 
802  virtual DataType& getRef(void)
803  {
804  return m_data;
805  }
806 
807  private:
808  DataType m_data;
809  long int m_length;
810  };
811 }; // namespace RTC
812 #endif // BufferBase_h
virtual bool isEmpty(void) const
Check on whether the buffer is empty.
Definition: BufferBase.h:726
virtual ReturnCode advanceWptr(long int n=1)=0
Forward n writing pointers.
RT-Component.
Concrete buffer class for dummy.
Definition: BufferBase.h:552
virtual size_t writable() const =0
Get a writable number.
NullBuffer(long int size=1)
Constructer.
Definition: BufferBase.h:577
virtual bool read(DataType &value)
Read data from the buffer.
Definition: BufferBase.h:677
virtual BUFFERSTATUS_ENUM ~BufferBase(void)
Virtual destructor.
Definition: BufferBase.h:121
virtual ReturnCode put(const DataType &value)=0
Write data into the buffer.
BufferStatus mixin class.
Definition: BufferStatus.h:52
Enum
DataPortStatus return codes.
Definition: BufferStatus.h:84
virtual ReturnCode reset()=0
Reset the buffer status.
virtual long int length(void) const
Get the buffer length (always 1)
Definition: BufferBase.h:620
virtual DataType * wptr(long int n=0)=0
Get the writing pointer.
#define BUFFERSTATUS_ENUM
Importing RTC::BufferStatus macro.
Definition: BufferStatus.h:157
Buffer status enum definition.
virtual bool full(void) const =0
Check on whether the buffer is full.
virtual DataType * rptr(long int n=0)=0
Get the reading pointer.
virtual DataType & getRef(void)
Get the buffer&#39;s reference to be written the next.
Definition: BufferBase.h:802
long int m_length
Definition: BufferBase.h:809
prop
Organization::get_organization_property ();.
virtual ReturnCode read(DataType &value, long int sec=-1, long int nsec=-1)=0
Read data from the buffer.
Class represents a set of properties.
Definition: Properties.h:101
virtual ReturnCode advanceRptr(long int n=1)=0
Forward n reading pointers.
virtual size_t readable() const =0
Write data into the buffer.
virtual ReturnCode write(const DataType &value, long int sec=-1, long int nsec=-1)=0
Write data into the buffer.
virtual bool isFull(void) const
Check on whether the buffer is full.
Definition: BufferBase.h:702
DataType m_data
Definition: BufferBase.h:808
virtual void put(const DataType &data)
Store data into the buffer.
Definition: BufferBase.h:751
virtual void init(const coil::Properties &prop)=0
Set the buffer.
BufferBase abstract class.
Definition: BufferBase.h:104
virtual bool write(const DataType &value)
Write data into the buffer.
Definition: BufferBase.h:648
virtual ~NullBuffer(void)
Destructor.
Definition: BufferBase.h:597
virtual bool empty(void) const =0
Check on whether the buffer is empty.
virtual size_t length(void) const =0
Get the buffer length.


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