Ring buffer implementation class. More...
#include <RingBuffer.h>
Classes | |
struct | condition |
struct for condition variable More... | |
Public Member Functions | |
virtual ReturnCode | advanceRptr (long int n=1) |
Get the buffer length. | |
virtual ReturnCode | advanceWptr (long int n=1) |
Get the buffer length. | |
virtual bool | empty (void) const |
Check on whether the buffer is empty. | |
virtual bool | full (void) const |
Check on whether the buffer is full. | |
virtual ReturnCode | get (DataType &value) |
Write data into the buffer. | |
virtual DataType & | get () |
Reading data from the buffer. | |
virtual void | init (const coil::Properties &prop) |
virtual size_t | length (void) const |
Get the buffer length. | |
virtual ReturnCode | length (size_t n) |
Get the buffer length. | |
virtual ReturnCode | put (const DataType &value) |
Write data into 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 ReturnCode | reset () |
Get the buffer length. | |
RingBuffer (long int length=RINGBUFFER_DEFAULT_LENGTH) | |
Constructor. | |
virtual DataType * | rptr (long int n=0) |
Get the buffer length. | |
virtual DataType * | wptr (long int n=0) |
Get the buffer length. | |
virtual size_t | writable () const |
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 | ~RingBuffer (void) |
Virtual destractor. | |
Public Attributes | |
BUFFERSTATUS_ENUM typedef coil::Guard< coil::Mutex > | Guard |
Private Member Functions | |
void | initLength (const coil::Properties &prop) |
void | initReadPolicy (const coil::Properties &prop) |
void | initWritePolicy (const coil::Properties &prop) |
Private Attributes | |
std::vector< DataType > | m_buffer |
baffer array | |
condition | m_empty |
empty condition variable | |
size_t | m_fillcount |
Fill count. | |
condition | m_full |
full condition variable | |
size_t | m_length |
Buffer length. | |
bool | m_overwrite |
Overwrite flag. | |
coil::Mutex | m_posmutex |
mutex for position variable | |
bool | m_readback |
Readback flag. | |
size_t | m_rpos |
poitner to read | |
coil::TimeValue | m_rtimeout |
Timeout time of reading. | |
bool | m_timedread |
Timedread flag. | |
bool | m_timedwrite |
Timedwrite flag. | |
size_t | m_wcount |
Counter for writing. | |
size_t | m_wpos |
pointer to write | |
coil::TimeValue | m_wtimeout |
Timeout time for writing. |
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 |
Definition at line 89 of file RingBuffer.h.
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 |
Definition at line 118 of file RingBuffer.h.
virtual RTC::RingBuffer< DataType >::~RingBuffer | ( | void | ) | [inline, virtual] |
virtual ReturnCode RTC::RingBuffer< DataType >::advanceRptr | ( | long int | n = 1 | ) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Definition at line 591 of file RingBuffer.h.
virtual ReturnCode RTC::RingBuffer< DataType >::advanceWptr | ( | long int | n = 1 | ) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Definition at line 334 of file RingBuffer.h.
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.
Definition at line 823 of file RingBuffer.h.
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.
Definition at line 537 of file RingBuffer.h.
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. |
Definition at line 635 of file RingBuffer.h.
virtual DataType& RTC::RingBuffer< DataType >::get | ( | ) | [inline, virtual] |
virtual void RTC::RingBuffer< DataType >::init | ( | const coil::Properties & | prop | ) | [inline, virtual] |
Definition at line 187 of file RingBuffer.h.
void RTC::RingBuffer< DataType >::initLength | ( | const coil::Properties & | prop | ) | [inline, private] |
Definition at line 830 of file RingBuffer.h.
void RTC::RingBuffer< DataType >::initReadPolicy | ( | const coil::Properties & | prop | ) | [inline, private] |
Definition at line 875 of file RingBuffer.h.
void RTC::RingBuffer< DataType >::initWritePolicy | ( | const coil::Properties & | prop | ) | [inline, private] |
Definition at line 845 of file RingBuffer.h.
virtual size_t RTC::RingBuffer< DataType >::length | ( | void | ) | const [inline, virtual] |
Get the buffer length.
Get the buffer length.
Definition at line 214 of file RingBuffer.h.
virtual ReturnCode RTC::RingBuffer< DataType >::length | ( | size_t | n | ) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Definition at line 242 of file RingBuffer.h.
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. |
Definition at line 382 of file RingBuffer.h.
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 |
Definition at line 708 of file RingBuffer.h.
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. |
Definition at line 798 of file RingBuffer.h.
virtual ReturnCode RTC::RingBuffer< DataType >::reset | ( | ) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Definition at line 272 of file RingBuffer.h.
virtual DataType* RTC::RingBuffer< DataType >::rptr | ( | long int | n = 0 | ) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Definition at line 564 of file RingBuffer.h.
virtual DataType* RTC::RingBuffer< DataType >::wptr | ( | long int | n = 0 | ) | [inline, virtual] |
Get the buffer length.
Pure virtual function to get the buffer length.
Definition at line 305 of file RingBuffer.h.
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. |
Definition at line 512 of file RingBuffer.h.
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 |
Definition at line 430 of file RingBuffer.h.
BUFFERSTATUS_ENUM typedef coil::Guard<coil::Mutex> RTC::RingBuffer< DataType >::Guard |
Definition at line 94 of file RingBuffer.h.
std::vector<DataType> RTC::RingBuffer< DataType >::m_buffer [private] |
baffer array
Definition at line 1006 of file RingBuffer.h.
condition RTC::RingBuffer< DataType >::m_empty [private] |
empty condition variable
Definition at line 1038 of file RingBuffer.h.
size_t RTC::RingBuffer< DataType >::m_fillcount [private] |
Fill count.
Definition at line 988 of file RingBuffer.h.
condition RTC::RingBuffer< DataType >::m_full [private] |
full condition variable
Definition at line 1047 of file RingBuffer.h.
size_t RTC::RingBuffer< DataType >::m_length [private] |
Buffer length.
Definition at line 961 of file RingBuffer.h.
bool RTC::RingBuffer< DataType >::m_overwrite [private] |
Overwrite flag.
Definition at line 908 of file RingBuffer.h.
coil::Mutex RTC::RingBuffer< DataType >::m_posmutex [mutable, private] |
mutex for position variable
Definition at line 1029 of file RingBuffer.h.
bool RTC::RingBuffer< DataType >::m_readback [private] |
Readback flag.
Definition at line 917 of file RingBuffer.h.
size_t RTC::RingBuffer< DataType >::m_rpos [private] |
poitner to read
Definition at line 979 of file RingBuffer.h.
coil::TimeValue RTC::RingBuffer< DataType >::m_rtimeout [private] |
Timeout time of reading.
Definition at line 952 of file RingBuffer.h.
bool RTC::RingBuffer< DataType >::m_timedread [private] |
Timedread flag.
Definition at line 934 of file RingBuffer.h.
bool RTC::RingBuffer< DataType >::m_timedwrite [private] |
Timedwrite flag.
Definition at line 926 of file RingBuffer.h.
size_t RTC::RingBuffer< DataType >::m_wcount [private] |
Counter for writing.
Definition at line 997 of file RingBuffer.h.
size_t RTC::RingBuffer< DataType >::m_wpos [private] |
pointer to write
Definition at line 970 of file RingBuffer.h.
coil::TimeValue RTC::RingBuffer< DataType >::m_wtimeout [private] |
Timeout time for writing.
Definition at line 943 of file RingBuffer.h.