RTT::base::BufferLocked< T > Class Template Reference
[Data Storage and Buffering classes.]

#include <BufferLocked.hpp>

Inheritance diagram for RTT::base::BufferLocked< T >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef BufferInterface< T >
::param_t 
param_t
typedef BufferInterface< T >
::param_t 
param_t
typedef BufferInterface< T >
::reference_t 
reference_t
typedef BufferInterface< T >
::reference_t 
reference_t
typedef BufferInterface< T >
::size_type 
size_type
typedef BufferInterface< T >
::size_type 
size_type
typedef T value_t
typedef T value_t

Public Member Functions

 BufferLocked (size_type size, const T &initial_value=T())
 BufferLocked (size_type size, const T &initial_value=T())
size_type capacity () const
size_type capacity () const
void clear ()
void clear ()
virtual void data_sample (const T &sample)
virtual void data_sample (const T &sample)
bool empty () const
bool empty () const
bool full () const
bool full () const
size_type Pop (std::vector< T > &items)
bool Pop (reference_t item)
size_type Pop (std::vector< T > &items)
bool Pop (reference_t item)
value_tPopWithoutRelease ()
value_tPopWithoutRelease ()
size_type Push (const std::vector< T > &items)
bool Push (param_t item)
size_type Push (const std::vector< T > &items)
bool Push (param_t item)
void Release (value_t *item)
void Release (value_t *item)
size_type size () const
size_type size () const
 ~BufferLocked ()
 ~BufferLocked ()

Private Attributes

std::deque< T > buf
size_type cap
value_t lastSample
os::Mutex lock

Detailed Description

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

Implements a very simple blocking thread-safe buffer, using mutexes (locks).

See also:
BufferLockFree

Definition at line 61 of file install/include/rtt/base/BufferLocked.hpp.


Member Typedef Documentation

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

Reimplemented from RTT::base::BufferInterface< T >.

Definition at line 67 of file rtt/base/BufferLocked.hpp.

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

Reimplemented from RTT::base::BufferInterface< T >.

Definition at line 67 of file install/include/rtt/base/BufferLocked.hpp.

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

Reimplemented from RTT::base::BufferInterface< T >.

Definition at line 66 of file rtt/base/BufferLocked.hpp.

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

Reimplemented from RTT::base::BufferInterface< T >.

Definition at line 66 of file install/include/rtt/base/BufferLocked.hpp.

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

Reimplemented from RTT::base::BufferInterface< T >.

Definition at line 68 of file rtt/base/BufferLocked.hpp.

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

Reimplemented from RTT::base::BufferInterface< T >.

Definition at line 68 of file install/include/rtt/base/BufferLocked.hpp.

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

Reimplemented from RTT::base::BufferInterface< T >.

Definition at line 69 of file rtt/base/BufferLocked.hpp.

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

Reimplemented from RTT::base::BufferInterface< T >.

Definition at line 69 of file install/include/rtt/base/BufferLocked.hpp.


Constructor & Destructor Documentation

template<class T >
RTT::base::BufferLocked< T >::BufferLocked ( size_type  size,
const T &  initial_value = T() 
) [inline]

Create a buffer of size size.

Definition at line 74 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
RTT::base::BufferLocked< T >::~BufferLocked (  )  [inline]

Destructor

Definition at line 89 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
RTT::base::BufferLocked< T >::BufferLocked ( size_type  size,
const T &  initial_value = T() 
) [inline]

Create a buffer of size size.

Definition at line 74 of file rtt/base/BufferLocked.hpp.

template<class T >
RTT::base::BufferLocked< T >::~BufferLocked (  )  [inline]

Destructor

Definition at line 89 of file rtt/base/BufferLocked.hpp.


Member Function Documentation

template<class T >
size_type RTT::base::BufferLocked< T >::capacity (  )  const [inline, virtual]

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 156 of file rtt/base/BufferLocked.hpp.

template<class T >
size_type RTT::base::BufferLocked< T >::capacity (  )  const [inline, virtual]

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 156 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
void RTT::base::BufferLocked< T >::clear (  )  [inline, virtual]

Clears all contents of this buffer.

Implements RTT::base::BufferBase.

Definition at line 166 of file rtt/base/BufferLocked.hpp.

template<class T >
void RTT::base::BufferLocked< T >::clear (  )  [inline, virtual]

Clears all contents of this buffer.

Implements RTT::base::BufferBase.

Definition at line 166 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
virtual void RTT::base::BufferLocked< T >::data_sample ( const T &  sample  )  [inline, virtual]

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

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 80 of file rtt/base/BufferLocked.hpp.

template<class T >
virtual void RTT::base::BufferLocked< T >::data_sample ( const T &  sample  )  [inline, virtual]

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

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 80 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
bool RTT::base::BufferLocked< T >::empty (  )  const [inline, virtual]

Check if this buffer is empty.

Returns:
true if size() == 0

Implements RTT::base::BufferBase.

Definition at line 171 of file rtt/base/BufferLocked.hpp.

template<class T >
bool RTT::base::BufferLocked< T >::empty (  )  const [inline, virtual]

Check if this buffer is empty.

Returns:
true if size() == 0

Implements RTT::base::BufferBase.

Definition at line 171 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
bool RTT::base::BufferLocked< T >::full (  )  const [inline, virtual]

Check if this buffer is full.

Returns:
true if size() == capacity()

Implements RTT::base::BufferBase.

Definition at line 176 of file rtt/base/BufferLocked.hpp.

template<class T >
bool RTT::base::BufferLocked< T >::full (  )  const [inline, virtual]

Check if this buffer is full.

Returns:
true if size() == capacity()

Implements RTT::base::BufferBase.

Definition at line 176 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
size_type RTT::base::BufferLocked< T >::Pop ( std::vector< T > &  items  )  [inline, virtual]

Read the whole buffer.

Parameters:
items is 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 123 of file rtt/base/BufferLocked.hpp.

template<class T >
bool RTT::base::BufferLocked< T >::Pop ( reference_t  item  )  [inline, virtual]

Read the oldest value from the buffer.

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

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

Definition at line 112 of file rtt/base/BufferLocked.hpp.

template<class T >
size_type RTT::base::BufferLocked< T >::Pop ( std::vector< T > &  items  )  [inline, virtual]

Read the whole buffer.

Parameters:
items is 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 123 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
bool RTT::base::BufferLocked< T >::Pop ( reference_t  item  )  [inline, virtual]

Read the oldest value from the buffer.

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

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

Definition at line 112 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
value_t* RTT::base::BufferLocked< T >::PopWithoutRelease (  )  [inline, virtual]

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 135 of file rtt/base/BufferLocked.hpp.

template<class T >
value_t* RTT::base::BufferLocked< T >::PopWithoutRelease (  )  [inline, virtual]

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 135 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
size_type RTT::base::BufferLocked< T >::Push ( const std::vector< T > &  items  )  [inline, virtual]

Write a sequence of values to the buffer.

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

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

Definition at line 101 of file rtt/base/BufferLocked.hpp.

template<class T >
bool RTT::base::BufferLocked< T >::Push ( param_t  item  )  [inline, virtual]

Write a single value to the buffer.

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

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

Definition at line 91 of file rtt/base/BufferLocked.hpp.

template<class T >
size_type RTT::base::BufferLocked< T >::Push ( const std::vector< T > &  items  )  [inline, virtual]

Write a sequence of values to the buffer.

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

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

Definition at line 101 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
bool RTT::base::BufferLocked< T >::Push ( param_t  item  )  [inline, virtual]

Write a single value to the buffer.

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

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

Definition at line 91 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
void RTT::base::BufferLocked< T >::Release ( value_t item  )  [inline, virtual]

Releases the pointer

Parameters:
item pointer aquired using PopWithoutRelease()

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

Definition at line 149 of file rtt/base/BufferLocked.hpp.

template<class T >
void RTT::base::BufferLocked< T >::Release ( value_t item  )  [inline, virtual]

Releases the pointer

Parameters:
item pointer aquired using PopWithoutRelease()

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

Definition at line 149 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
size_type RTT::base::BufferLocked< T >::size (  )  const [inline, virtual]

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

Returns:
number of items.

Implements RTT::base::BufferBase.

Definition at line 161 of file rtt/base/BufferLocked.hpp.

template<class T >
size_type RTT::base::BufferLocked< T >::size (  )  const [inline, virtual]

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

Returns:
number of items.

Implements RTT::base::BufferBase.

Definition at line 161 of file install/include/rtt/base/BufferLocked.hpp.


Member Data Documentation

template<class T >
std::deque< T > RTT::base::BufferLocked< T >::buf [private]

Definition at line 182 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
size_type RTT::base::BufferLocked< T >::cap [private]

Definition at line 181 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
value_t RTT::base::BufferLocked< T >::lastSample [private]

Definition at line 183 of file install/include/rtt/base/BufferLocked.hpp.

template<class T >
os::Mutex RTT::base::BufferLocked< T >::lock [mutable, private]

Definition at line 184 of file install/include/rtt/base/BufferLocked.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


rtt
Author(s): RTT Developers
autogenerated on Fri Jan 11 09:49:50 2013