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. More... | |
virtual ReturnCode | advanceWptr (long int n=1) |
Get the buffer length. More... | |
virtual bool | empty (void) const |
Check on whether the buffer is empty. More... | |
virtual bool | full (void) const |
Check on whether the buffer is full. More... | |
virtual ReturnCode | get (DataType &value) |
Write data into the buffer. More... | |
virtual DataType & | get () |
Reading data from the buffer. More... | |
virtual void | init (const coil::Properties &prop) |
Set the buffer. More... | |
virtual size_t | length (void) const |
Get the buffer length. More... | |
virtual ReturnCode | length (size_t n) |
Get the buffer length. More... | |
virtual ReturnCode | put (const DataType &value) |
Write data into the buffer. More... | |
virtual ReturnCode | read (DataType &value, long int sec=-1, long int nsec=0) |
Readout data from the buffer. More... | |
virtual size_t | readable () const |
Write data into the buffer. More... | |
virtual ReturnCode | reset () |
Get the buffer length. More... | |
RingBuffer (long int length=RINGBUFFER_DEFAULT_LENGTH) | |
Constructor. More... | |
virtual DataType * | rptr (long int n=0) |
Get the buffer length. More... | |
virtual DataType * | wptr (long int n=0) |
Get the buffer length. More... | |
virtual size_t | writable () const |
Write data into the buffer. More... | |
virtual ReturnCode | write (const DataType &value, long int sec=-1, long int nsec=0) |
Write data into the buffer. More... | |
virtual | ~RingBuffer (void) |
Virtual destractor. More... | |
Public Member Functions inherited from RTC::BufferBase< DataType > | |
virtual BUFFERSTATUS_ENUM | ~BufferBase (void) |
Virtual destructor. More... | |
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 More... | |
condition | m_empty |
empty condition variable More... | |
size_t | m_fillcount |
Fill count. More... | |
condition | m_full |
full condition variable More... | |
size_t | m_length |
Buffer length. More... | |
bool | m_overwrite |
Overwrite flag. More... | |
coil::Mutex | m_posmutex |
mutex for position variable More... | |
bool | m_readback |
Readback flag. More... | |
size_t | m_rpos |
poitner to read More... | |
coil::TimeValue | m_rtimeout |
Timeout time of reading. More... | |
bool | m_timedread |
Timedread flag. More... | |
bool | m_timedwrite |
Timedwrite flag. More... | |
size_t | m_wcount |
Counter for writing. More... | |
size_t | m_wpos |
pointer to write More... | |
coil::TimeValue | m_wtimeout |
Timeout time for writing. More... | |
Additional Inherited Members | |
Public Types inherited from RTC::BufferStatus | |
enum | Enum { BUFFER_OK = 0, BUFFER_ERROR, BUFFER_FULL, BUFFER_EMPTY, NOT_SUPPORTED, TIMEOUT, PRECONDITION_NOT_MET } |
DataPortStatus return codes. More... | |
Static Public Member Functions inherited from RTC::BufferStatus | |
static const char * | toString (Enum status) |
Convert BufferStatus into the string. More... | |
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.
|
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.
|
inlinevirtual |
|
inlinevirtual |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
Definition at line 594 of file RingBuffer.h.
|
inlinevirtual |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
Definition at line 334 of file RingBuffer.h.
|
inlinevirtual |
Check on whether the buffer is empty.
Pure virtual function to check on whether the buffer is empty.
Implements RTC::BufferBase< DataType >.
Definition at line 829 of file RingBuffer.h.
|
inlinevirtual |
Check on whether the buffer is full.
Pure virtual function to check on whether the buffer is full.
Implements RTC::BufferBase< DataType >.
Definition at line 540 of file RingBuffer.h.
|
inlinevirtual |
Write data into the buffer.
Pure virtual function to write data into the buffer.
value | Target data to write. |
Implements RTC::BufferBase< DataType >.
Definition at line 638 of file RingBuffer.h.
|
inlinevirtual |
Reading data from the buffer.
Implements RTC::BufferBase< DataType >.
Definition at line 663 of file RingBuffer.h.
|
inlinevirtual |
Set the buffer.
Implements RTC::BufferBase< DataType >.
Definition at line 187 of file RingBuffer.h.
|
inlineprivate |
Definition at line 836 of file RingBuffer.h.
|
inlineprivate |
Definition at line 881 of file RingBuffer.h.
|
inlineprivate |
Definition at line 851 of file RingBuffer.h.
|
inlinevirtual |
Get the buffer length.
Get the buffer length.
Implements RTC::BufferBase< DataType >.
Definition at line 214 of file RingBuffer.h.
|
inlinevirtual |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
Definition at line 242 of file RingBuffer.h.
|
inlinevirtual |
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 >.
Definition at line 382 of file RingBuffer.h.
|
inlinevirtual |
Readout data from the buffer.
Readout data stored into the buffer.
value | Readout data |
Implements RTC::BufferBase< DataType >.
Definition at line 711 of file RingBuffer.h.
|
inlinevirtual |
Write data into the buffer.
Pure virtual function to write data into the buffer.
value | Target data to write. |
Implements RTC::BufferBase< DataType >.
Definition at line 804 of file RingBuffer.h.
|
inlinevirtual |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
Definition at line 272 of file RingBuffer.h.
|
inlinevirtual |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
Definition at line 567 of file RingBuffer.h.
|
inlinevirtual |
Get the buffer length.
Pure virtual function to get the buffer length.
Implements RTC::BufferBase< DataType >.
Definition at line 305 of file RingBuffer.h.
|
inlinevirtual |
Write data into the buffer.
Pure virtual function to write data into the buffer.
value | Target data to write. |
Implements RTC::BufferBase< DataType >.
Definition at line 515 of file RingBuffer.h.
|
inlinevirtual |
Write data into the buffer.
Write data which is given argument into the buffer.
value | Target data for writing |
Implements RTC::BufferBase< DataType >.
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.
|
private |
baffer array
Definition at line 1012 of file RingBuffer.h.
|
private |
empty condition variable
Definition at line 1044 of file RingBuffer.h.
|
private |
Fill count.
Definition at line 994 of file RingBuffer.h.
|
private |
full condition variable
Definition at line 1053 of file RingBuffer.h.
|
private |
Buffer length.
Definition at line 967 of file RingBuffer.h.
|
private |
Overwrite flag.
Definition at line 914 of file RingBuffer.h.
|
mutableprivate |
mutex for position variable
Definition at line 1035 of file RingBuffer.h.
|
private |
Readback flag.
Definition at line 923 of file RingBuffer.h.
|
private |
poitner to read
Definition at line 985 of file RingBuffer.h.
|
private |
Timeout time of reading.
Definition at line 958 of file RingBuffer.h.
|
private |
Timedread flag.
Definition at line 940 of file RingBuffer.h.
|
private |
Timedwrite flag.
Definition at line 932 of file RingBuffer.h.
|
private |
Counter for writing.
Definition at line 1003 of file RingBuffer.h.
|
private |
pointer to write
Definition at line 976 of file RingBuffer.h.
|
private |
Timeout time for writing.
Definition at line 949 of file RingBuffer.h.