#include <RingBuffer.h>
Public Member Functions | |
RingBuffer (long int length) | |
Constructor. | |
virtual | ~RingBuffer () |
Virtual destractor. | |
void | init (DataType &data) |
Initialize the buffer. | |
virtual long int | length () const |
Get the buffer length. | |
virtual bool | write (const DataType &value) |
Write data into the buffer. | |
virtual bool | read (DataType &value) |
Readout data from the buffer. | |
virtual bool | isFull () const |
Check whether the buffer is full. | |
virtual bool | isEmpty () const |
Check whether the buffer is empty. | |
bool | isNew () const |
Check whether the data is newest. | |
Protected Member Functions | |
virtual void | put (const DataType &data) |
Store data into the buffer. | |
virtual const DataType & | get () |
Get data from the buffer. | |
virtual DataType & | getRef () |
Get the buffer's reference to be written the next. | |
Classes | |
class | Data |
Buffer array. |
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 | ) | [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 |
virtual RTC::RingBuffer< DataType >::~RingBuffer | ( | ) | [inline, virtual] |
Virtual destractor.
Virtual destractor
void RTC::RingBuffer< DataType >::init | ( | DataType & | data | ) | [inline] |
Initialize the buffer.
Initialize the buffer. Store the specified value to eitire buffer.
data | Data for initialization |
virtual long int RTC::RingBuffer< DataType >::length | ( | ) | const [inline, virtual] |
Get the buffer length.
Get the buffer length.
Implements RTC::BufferBase< DataType >.
virtual bool RTC::RingBuffer< DataType >::write | ( | const DataType & | value | ) | [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 >.
virtual bool RTC::RingBuffer< DataType >::read | ( | DataType & | value | ) | [inline, virtual] |
Readout data from the buffer.
Readout data stored into the buffer.
value | Readout data |
Implements RTC::BufferBase< DataType >.
virtual bool RTC::RingBuffer< DataType >::isFull | ( | ) | const [inline, virtual] |
Check whether the buffer is full.
Check whether the buffer is full (Always return false)
Implements RTC::BufferBase< DataType >.
virtual bool RTC::RingBuffer< DataType >::isEmpty | ( | ) | const [inline, virtual] |
Check whether the buffer is empty.
Check whether the buffer is empty.
Note: In the current implementation, return whether the data which was stored at a current buffer's position was readout. (true:it has already readout data,false:it does not readout data)
Implements RTC::BufferBase< DataType >.
bool RTC::RingBuffer< DataType >::isNew | ( | ) | const [inline] |
Check whether the data is newest.
Check whether the data stored at a current buffer position is newest.
virtual void RTC::RingBuffer< DataType >::put | ( | const DataType & | data | ) | [inline, protected, virtual] |
Store data into the buffer.
Store data given by argument into the buffer.
Note: In the current implementation, the data position is set the readout position of data at the same time of storing data Therefore, the latest stored data is always got.
data | Target data for the store |
Implements RTC::BufferBase< DataType >.
virtual const DataType& RTC::RingBuffer< DataType >::get | ( | ) | [inline, protected, virtual] |
Get data from the buffer.
Get data stored into the buffer.
Implements RTC::BufferBase< DataType >.
virtual DataType& RTC::RingBuffer< DataType >::getRef | ( | ) | [inline, protected, virtual] |
Get the buffer's reference to be written the next.
Get the reference to the buffer that will be written.
Implements RTC::BufferBase< DataType >.