Orocos Real-Time Toolkit  2.9.0
Public Types | Public Member Functions | List of all members
RTT::base::BufferUnSync< T > Class Template Reference

Implements a not threadsafe buffer. More...

#include <rtt/base/BufferUnSync.hpp>

Inheritance diagram for RTT::base::BufferUnSync< T >:
RTT::base::BufferInterface< T > RTT::base::BufferBase

Public Types

typedef BufferBase::Options Options
 
typedef BufferInterface< T >::reference_t reference_t
 
typedef BufferInterface< T >::param_t param_t
 
typedef BufferInterface< T >::size_type size_type
 
typedef T value_t
 
typedef boost::shared_ptr< BufferInterface< T > > shared_ptr
 

Public Member Functions

 BufferUnSync (size_type size, const Options &options=Options())
 Create an uninitialized buffer of size size. More...
 
 BufferUnSync (size_type size, param_t initial_value, const Options &options=Options())
 Create a buffer of size size. More...
 
virtual bool data_sample (param_t sample, bool reset=true)
 Initializes this buffer with a data sample, such that for dynamical allocated types T, the buffer can reserve place to hold these elements. More...
 
virtual value_t data_sample () const
 Reads back a data sample. More...
 
 ~BufferUnSync ()
 Destructor. More...
 
bool Push (param_t item)
 Write a single value to the buffer. More...
 
size_type Push (const std::vector< value_t > &items)
 Write a sequence of values to the buffer. More...
 
FlowStatus Pop (reference_t item)
 Read the oldest value from the buffer. More...
 
size_type Pop (std::vector< value_t > &items)
 Read the whole buffer. More...
 
value_tPopWithoutRelease ()
 Returns a pointer to the first element in the buffer. More...
 
void Release (value_t *item)
 Releases the pointer. More...
 
size_type capacity () const
 Returns the maximum number of items that can be stored in the buffer. More...
 
size_type size () const
 Returns the actual number of items that are stored in the buffer. More...
 
void clear ()
 Clears all contents of this buffer. More...
 
bool empty () const
 Check if this buffer is empty. More...
 
bool full () const
 Check if this buffer is full. More...
 
virtual size_type dropped () const
 Returns the number of dropped samples, because the buffer was full. More...
 

Detailed Description

template<class T>
class RTT::base::BufferUnSync< T >

Implements a not threadsafe buffer.

Only use when no more than one thread accesses this buffer at a time.

See also
BufferLockFree, BufferUnSync

Definition at line 58 of file BufferUnSync.hpp.

Member Typedef Documentation

template<class T >
typedef BufferBase::Options RTT::base::BufferUnSync< T >::Options

Definition at line 62 of file BufferUnSync.hpp.

template<class T >
typedef BufferInterface<T>::param_t RTT::base::BufferUnSync< T >::param_t

Definition at line 64 of file BufferUnSync.hpp.

template<class T >
typedef BufferInterface<T>::reference_t RTT::base::BufferUnSync< T >::reference_t

Definition at line 63 of file BufferUnSync.hpp.

template<class T>
typedef boost::shared_ptr< BufferInterface<T> > RTT::base::BufferInterface< T >::shared_ptr
inherited

Definition at line 63 of file BufferInterface.hpp.

template<class T >
typedef BufferInterface<T>::size_type RTT::base::BufferUnSync< T >::size_type

Definition at line 65 of file BufferUnSync.hpp.

template<class T >
typedef T RTT::base::BufferUnSync< T >::value_t

Definition at line 66 of file BufferUnSync.hpp.

Constructor & Destructor Documentation

template<class T >
RTT::base::BufferUnSync< T >::BufferUnSync ( size_type  size,
const Options options = Options() 
)
inline

Create an uninitialized buffer of size size.

Definition at line 71 of file BufferUnSync.hpp.

template<class T >
RTT::base::BufferUnSync< T >::BufferUnSync ( size_type  size,
param_t  initial_value,
const Options options = Options() 
)
inline

Create a buffer of size size.

Definition at line 79 of file BufferUnSync.hpp.

References RTT::base::BufferUnSync< T >::data_sample().

template<class T >
RTT::base::BufferUnSync< T >::~BufferUnSync ( )
inline

Destructor.

Definition at line 104 of file BufferUnSync.hpp.

Member Function Documentation

template<class T >
size_type RTT::base::BufferUnSync< T >::capacity ( ) const
inlinevirtual

Returns the maximum number of items that can be stored in the buffer.

Returns
maximum number of items.

Implements RTT::base::BufferBase.

Definition at line 197 of file BufferUnSync.hpp.

template<class T >
void RTT::base::BufferUnSync< T >::clear ( )
inlinevirtual

Clears all contents of this buffer.

Implements RTT::base::BufferBase.

Definition at line 205 of file BufferUnSync.hpp.

template<class T >
virtual bool RTT::base::BufferUnSync< T >::data_sample ( param_t  sample,
bool  reset = true 
)
inlinevirtual

Initializes this buffer with a data sample, such that for dynamical allocated types T, the buffer can reserve place to hold these elements.

Parameters
samplethe data sample
resetenforce reinitialization even if this operation clears all data.
Returns
true if the buffer was successfully (re)initialized.
Postcondition
Calling this function causes all data in the buffer to be lost and the size being reset to zero.

Implements RTT::base::BufferInterface< T >.

Definition at line 85 of file BufferUnSync.hpp.

template<class T >
virtual value_t RTT::base::BufferUnSync< T >::data_sample ( ) const
inlinevirtual

Reads back a data sample.

Implements RTT::base::BufferInterface< T >.

Definition at line 96 of file BufferUnSync.hpp.

Referenced by RTT::base::BufferUnSync< T >::BufferUnSync().

template<class T >
virtual size_type RTT::base::BufferUnSync< T >::dropped ( ) const
inlinevirtual

Returns the number of dropped samples, because the buffer was full.

Implements RTT::base::BufferBase.

Definition at line 217 of file BufferUnSync.hpp.

template<class T >
bool RTT::base::BufferUnSync< T >::empty ( ) const
inlinevirtual

Check if this buffer is empty.

Returns
true if size() == 0

Implements RTT::base::BufferBase.

Definition at line 209 of file BufferUnSync.hpp.

template<class T >
bool RTT::base::BufferUnSync< T >::full ( ) const
inlinevirtual

Check if this buffer is full.

Returns
true if size() == capacity()

Implements RTT::base::BufferBase.

Definition at line 213 of file BufferUnSync.hpp.

template<class T >
FlowStatus RTT::base::BufferUnSync< T >::Pop ( reference_t  item)
inlinevirtual

Read the oldest value from the buffer.

Parameters
itemis to be set with a value from the buffer.
Returns
true if something was read.

Implements RTT::base::BufferInterface< T >.

Definition at line 155 of file BufferUnSync.hpp.

References RTT::NewData, and RTT::NoData.

template<class T >
size_type RTT::base::BufferUnSync< T >::Pop ( std::vector< value_t > &  items)
inlinevirtual

Read the whole buffer.

Parameters
itemsis to be filled with all values in the buffer, with items.begin() the oldest value.
Returns
the number of items read.

Implements RTT::base::BufferInterface< T >.

Definition at line 165 of file BufferUnSync.hpp.

template<class T >
value_t* RTT::base::BufferUnSync< T >::PopWithoutRelease ( )
inlinevirtual

Returns a pointer to the first element in the buffer.

The pointer is only garanteed to stay valid until the next pop operation.

Note the pointer needs the be released by calling Release on the buffer.

Returns
a pointer to a sample or Zero if buffer is empty

Implements RTT::base::BufferInterface< T >.

Definition at line 177 of file BufferUnSync.hpp.

template<class T >
bool RTT::base::BufferUnSync< T >::Push ( param_t  item)
inlinevirtual

Write a single value to the buffer.

Parameters
itemthe value to write
Returns
false if the buffer is full.

Implements RTT::base::BufferInterface< T >.

Definition at line 106 of file BufferUnSync.hpp.

template<class T >
size_type RTT::base::BufferUnSync< T >::Push ( const std::vector< value_t > &  items)
inlinevirtual

Write a sequence of values to the buffer.

Parameters
itemsthe values to write
Returns
the number of values written (may be less than items.size())

Implements RTT::base::BufferInterface< T >.

Definition at line 124 of file BufferUnSync.hpp.

template<class T >
void RTT::base::BufferUnSync< T >::Release ( value_t item)
inlinevirtual

Releases the pointer.

Parameters
itempointer aquired using PopWithoutRelease()

Implements RTT::base::BufferInterface< T >.

Definition at line 190 of file BufferUnSync.hpp.

template<class T >
size_type RTT::base::BufferUnSync< T >::size ( ) const
inlinevirtual

Returns the actual number of items that are stored in the buffer.

Returns
number of items.

Implements RTT::base::BufferBase.

Definition at line 201 of file BufferUnSync.hpp.


The documentation for this class was generated from the following file: