Ring buffer implementation class. More...
#include <RingBuffer.h>
Classes | |
struct | condition |
struct for condition variable | |
Public Member Functions | |
RingBuffer (long int length=RINGBUFFER_DEFAULT_LENGTH) | |
Constructor. | |
virtual | ~RingBuffer (void) |
Virtual destractor. | |
virtual void | init (const coil::Properties &prop) |
Set the buffer. | |
virtual size_t | length (void) const |
Get the buffer length. | |
virtual ReturnCode | length (size_t n) |
Get the buffer length. | |
virtual ReturnCode | reset () |
Get the buffer length. | |
virtual DataType * | wptr (long int n=0) |
Get the buffer length. | |
virtual ReturnCode | advanceWptr (long int n=1) |
Get the buffer length. | |
virtual ReturnCode | put (const DataType &value) |
Write data into the buffer. | |
virtual ReturnCode | write (const DataType &value, long int sec=-1, long int nsec=0) |
Write data into the buffer. | |
virtual size_t | writable () const |
Write data into the buffer. | |
virtual bool | full (void) const |
Check on whether the buffer is full. | |
virtual DataType * | rptr (long int n=0) |
Get the buffer length. | |
virtual ReturnCode | advanceRptr (long int n=1) |
Get the buffer length. | |
virtual ReturnCode | get (DataType &value) |
Write data into the buffer. | |
virtual DataType & | get () |
Reading data from the buffer. | |
virtual ReturnCode | read (DataType &value, long int sec=-1, long int nsec=0) |
Readout data from the buffer. | |
virtual size_t | readable () const |
Write data into the buffer. | |
virtual bool | empty (void) const |
Check on whether the buffer is empty. | |
Public Attributes | |
BUFFERSTATUS_ENUM typedef coil::Guard< coil::Mutex > | Guard |
Ring buffer implementation class.
This is the buffer implementation class with ring shaped buffer of specified length. If data is stored in the entire buffer, data from now on will be overwritten from old data one by one. Therefore, only the length of latest data is stored in the buffer.
Note: In the current implementation, only last stored data can be read from the buffer.
DataType | Data type to store in the buffer |
RTC::RingBuffer< DataType >::RingBuffer | ( | long int | length = RINGBUFFER_DEFAULT_LENGTH |
) | [inline] |
Constructor.
Constructor. Initialize the buffer by specified buffer length. However, if the specified length is less than two, the buffer should be initialized by two in length.
length | Buffer length |
References RTC::RingBuffer< DataType >::reset().
virtual RTC::RingBuffer< DataType >::~RingBuffer | ( | void | ) | [inline, virtual] |
Virtual destractor.
Virtual destractor
virtual ReturnCode RTC::RingBuffer< DataType >::advanceRptr | ( | long int | n = 1 |
) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
Referenced by RTC::RingBuffer< DataType >::read(), and RTC::RingBuffer< DataType >::write().
virtual ReturnCode RTC::RingBuffer< DataType >::advanceWptr | ( | long int | n = 1 |
) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
Referenced by RTC::RingBuffer< DataType >::write().
virtual bool RTC::RingBuffer< DataType >::empty | ( | void | ) | const [inline, virtual] |
Check on whether the buffer is empty.
Pure virtual function to check on whether the buffer is empty.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
Referenced by RTC::RingBuffer< DataType >::read(), and RTC::RingBuffer< DataType >::write().
virtual bool RTC::RingBuffer< DataType >::full | ( | void | ) | const [inline, virtual] |
Check on whether the buffer is full.
Pure virtual function to check on whether the buffer is full.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
Referenced by RTC::RingBuffer< DataType >::read(), and RTC::RingBuffer< DataType >::write().
virtual DataType& RTC::RingBuffer< DataType >::get | ( | void | ) | [inline, virtual] |
Reading data from the buffer.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
virtual ReturnCode RTC::RingBuffer< DataType >::get | ( | DataType & | value | ) | [inline, virtual] |
Write data into the buffer.
Pure virtual function to write data into the buffer.
value | Target data to write. |
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
virtual void RTC::RingBuffer< DataType >::init | ( | const coil::Properties & | prop | ) | [inline, virtual] |
Set the buffer.
Implements RTC::BufferBase< DataType >.
virtual ReturnCode RTC::RingBuffer< DataType >::length | ( | size_t | n | ) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::reset().
virtual size_t RTC::RingBuffer< DataType >::length | ( | void | ) | const [inline, virtual] |
Get the buffer length.
Get the buffer length.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
virtual ReturnCode RTC::RingBuffer< DataType >::put | ( | const DataType & | value | ) | [inline, virtual] |
Write data into the buffer.
Pure virtual function to write data into the buffer. Always BUFFER_OK will be returned in this implementation.
value | Target data to write. |
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
Referenced by RTC::RingBuffer< DataType >::write().
virtual ReturnCode RTC::RingBuffer< DataType >::read | ( | DataType & | value, | |
long int | sec = -1 , |
|||
long int | nsec = 0 | |||
) | [inline, virtual] |
Readout data from the buffer.
Readout data stored into the buffer.
value | Readout data |
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::advanceRptr(), RTC::RingBuffer< DataType >::empty(), RTC::RingBuffer< DataType >::full(), and RTC::RingBuffer< DataType >::Guard.
virtual size_t RTC::RingBuffer< DataType >::readable | ( | ) | const [inline, virtual] |
Write data into the buffer.
Pure virtual function to write data into the buffer.
value | Target data to write. |
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
virtual ReturnCode RTC::RingBuffer< DataType >::reset | ( | ) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
Referenced by RTC::RingBuffer< DataType >::length(), and RTC::RingBuffer< DataType >::RingBuffer().
virtual DataType* RTC::RingBuffer< DataType >::rptr | ( | long int | n = 0 |
) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
virtual DataType* RTC::RingBuffer< DataType >::wptr | ( | long int | n = 0 |
) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
virtual size_t RTC::RingBuffer< DataType >::writable | ( | ) | const [inline, virtual] |
Write data into the buffer.
Pure virtual function to write data into the buffer.
value | Target data to write. |
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::Guard.
virtual ReturnCode RTC::RingBuffer< DataType >::write | ( | const DataType & | value, | |
long int | sec = -1 , |
|||
long int | nsec = 0 | |||
) | [inline, virtual] |
Write data into the buffer.
Write data which is given argument into the buffer.
value | Target data for writing |
Implements RTC::BufferBase< DataType >.
References RTC::RingBuffer< DataType >::advanceRptr(), RTC::RingBuffer< DataType >::advanceWptr(), RTC::RingBuffer< DataType >::empty(), RTC::RingBuffer< DataType >::full(), RTC::RingBuffer< DataType >::Guard, and RTC::RingBuffer< DataType >::put().
BUFFERSTATUS_ENUM typedef coil::Guard<coil::Mutex> RTC::RingBuffer< DataType >::Guard |
Referenced by RTC::RingBuffer< DataType >::advanceRptr(), RTC::RingBuffer< DataType >::advanceWptr(), RTC::RingBuffer< DataType >::empty(), RTC::RingBuffer< DataType >::full(), RTC::RingBuffer< DataType >::get(), RTC::RingBuffer< DataType >::length(), RTC::RingBuffer< DataType >::put(), RTC::RingBuffer< DataType >::read(), RTC::RingBuffer< DataType >::readable(), RTC::RingBuffer< DataType >::reset(), RTC::RingBuffer< DataType >::rptr(), RTC::RingBuffer< DataType >::wptr(), RTC::RingBuffer< DataType >::writable(), and RTC::RingBuffer< DataType >::write().