RTC::RingBuffer< DataType > Class Template Reference

Ring buffer implementation class. More...

#include <RingBuffer.h>

Inheritance diagram for RTC::RingBuffer< DataType >:

RTC::BufferBase< DataType >

List of all members.

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.


Detailed Description

template<class DataType>
class RTC::RingBuffer< DataType >

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.

Parameters:
DataType Data type to store in the buffer
Since:
0.4.0

Constructor & Destructor Documentation

template<class DataType>
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.

Parameters:
length Buffer length

template<class DataType>
virtual RTC::RingBuffer< DataType >::~RingBuffer (  )  [inline, virtual]

Virtual destractor.

Virtual destractor


Member Function Documentation

template<class DataType>
void RTC::RingBuffer< DataType >::init ( DataType &  data  )  [inline]

Initialize the buffer.

Initialize the buffer. Store the specified value to eitire buffer.

Parameters:
data Data for initialization

template<class DataType>
virtual long int RTC::RingBuffer< DataType >::length (  )  const [inline, virtual]

Get the buffer length.

Get the buffer length.

Returns:
Buffer length

Implements RTC::BufferBase< DataType >.

template<class 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.

Parameters:
value Target data for writing
Returns:
Writing result (Always true: writing success is returned)

Implements RTC::BufferBase< DataType >.

template<class DataType>
virtual bool RTC::RingBuffer< DataType >::read ( DataType &  value  )  [inline, virtual]

Readout data from the buffer.

Readout data stored into the buffer.

Parameters:
value Readout data
Returns:
Readout result (Always true: readout success is returned)

Implements RTC::BufferBase< DataType >.

template<class 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)

Returns:
Full check result (Always false)

Implements RTC::BufferBase< DataType >.

template<class 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)

Returns:
Empty check result

Implements RTC::BufferBase< DataType >.

template<class 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.

Returns:
Newest data check result ( true:Newest data. Data has not been readout yet. false:Past data.Data has already been readout.)

template<class DataType>
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.

Parameters:
data Target data for the store

Implements RTC::BufferBase< DataType >.

template<class DataType>
virtual const DataType& RTC::RingBuffer< DataType >::get (  )  [inline, protected, virtual]

Get data from the buffer.

Get data stored into the buffer.

Returns:
Data got from buffer

Implements RTC::BufferBase< DataType >.

template<class 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.

Returns:
The buffer's reference to be written the next

Implements RTC::BufferBase< DataType >.


Generated on Wed May 21 05:17:34 2008 for OpenRTM by  doxygen 1.5.3