Orocos Real-Time Toolkit
2.9.0
|
Implements a very simple blocking thread-safe buffer, using mutexes (locks). More...
#include <rtt/base/BufferLocked.hpp>
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 | |
BufferLocked (size_type size, const Options &options=Options()) | |
Create an unitialized buffer of size size, with preallocated data storage. More... | |
BufferLocked (size_type size, param_t initial_value, const Options &options=Options()) | |
Create a buffer of size size, with preallocated data storage. 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... | |
~BufferLocked () | |
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_t * | PopWithoutRelease () |
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... | |
size_type | dropped () const |
Returns the number of dropped samples, because the buffer was full. More... | |
Implements a very simple blocking thread-safe buffer, using mutexes (locks).
Definition at line 61 of file BufferLocked.hpp.
typedef BufferBase::Options RTT::base::BufferLocked< T >::Options |
Definition at line 65 of file BufferLocked.hpp.
typedef BufferInterface<T>::param_t RTT::base::BufferLocked< T >::param_t |
Definition at line 67 of file BufferLocked.hpp.
typedef BufferInterface<T>::reference_t RTT::base::BufferLocked< T >::reference_t |
Definition at line 66 of file BufferLocked.hpp.
|
inherited |
Definition at line 63 of file BufferInterface.hpp.
typedef BufferInterface<T>::size_type RTT::base::BufferLocked< T >::size_type |
Definition at line 68 of file BufferLocked.hpp.
typedef T RTT::base::BufferLocked< T >::value_t |
Definition at line 69 of file BufferLocked.hpp.
|
inline |
Create an unitialized buffer of size size, with preallocated data storage.
size | The number of elements this buffer can hold. |
Definition at line 75 of file BufferLocked.hpp.
|
inline |
Create a buffer of size size, with preallocated data storage.
size | The number of elements this buffer can hold. |
initial_value | A data sample with which each preallocated data element is initialized. |
Definition at line 85 of file BufferLocked.hpp.
References RTT::base::BufferLocked< T >::data_sample().
|
inline |
Destructor.
Definition at line 113 of file BufferLocked.hpp.
|
inlinevirtual |
Returns the maximum number of items that can be stored in the buffer.
Implements RTT::base::BufferBase.
Definition at line 212 of file BufferLocked.hpp.
|
inlinevirtual |
Clears all contents of this buffer.
Implements RTT::base::BufferBase.
Definition at line 222 of file BufferLocked.hpp.
|
inlinevirtual |
Initializes this buffer with a data sample, such that for dynamical allocated types T, the buffer can reserve place to hold these elements.
sample | the data sample |
reset | enforce reinitialization even if this operation clears all data. |
Implements RTT::base::BufferInterface< T >.
Definition at line 91 of file BufferLocked.hpp.
|
inlinevirtual |
Reads back a data sample.
Implements RTT::base::BufferInterface< T >.
Definition at line 105 of file BufferLocked.hpp.
Referenced by RTT::base::BufferLocked< T >::BufferLocked().
|
inlinevirtual |
Returns the number of dropped samples, because the buffer was full.
Implements RTT::base::BufferBase.
Definition at line 237 of file BufferLocked.hpp.
|
inlinevirtual |
Check if this buffer is empty.
Implements RTT::base::BufferBase.
Definition at line 227 of file BufferLocked.hpp.
|
inlinevirtual |
Check if this buffer is full.
Implements RTT::base::BufferBase.
Definition at line 232 of file BufferLocked.hpp.
|
inlinevirtual |
Read the oldest value from the buffer.
item | is to be set with a value from the buffer. |
Implements RTT::base::BufferInterface< T >.
Definition at line 167 of file BufferLocked.hpp.
References RTT::NewData, and RTT::NoData.
|
inlinevirtual |
Read the whole buffer.
items | is to be filled with all values in the buffer, with items.begin() the oldest value. |
Implements RTT::base::BufferInterface< T >.
Definition at line 178 of file BufferLocked.hpp.
|
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.
Implements RTT::base::BufferInterface< T >.
Definition at line 191 of file BufferLocked.hpp.
|
inlinevirtual |
Write a single value to the buffer.
item | the value to write |
Implements RTT::base::BufferInterface< T >.
Definition at line 115 of file BufferLocked.hpp.
|
inlinevirtual |
Write a sequence of values to the buffer.
items | the values to write |
Implements RTT::base::BufferInterface< T >.
Definition at line 132 of file BufferLocked.hpp.
|
inlinevirtual |
Releases the pointer.
item | pointer aquired using PopWithoutRelease() |
Implements RTT::base::BufferInterface< T >.
Definition at line 205 of file BufferLocked.hpp.
|
inlinevirtual |
Returns the actual number of items that are stored in the buffer.
Implements RTT::base::BufferBase.
Definition at line 217 of file BufferLocked.hpp.