Public Types | Public Member Functions | Static Public Attributes | Private Attributes
icl_core::tRingBuffer< T > Class Template Reference

A simple ring buffer implementation based on std::vector. More...

#include <tRingBuffer.h>

List of all members.

Public Types

typedef size_t size_type
typedef T value_type

Public Member Functions

const T & At (size_type pos) const
 Read an arbitrary element from the ring buffer without removing it.
T & At (size_type pos)
 Access an arbitrary element in the ring buffer without removing it.
size_type Capacity () const
 Returns the capacity of the ring buffer.
void Clear ()
 Clears the ring buffer.
tRingBufferoperator= (const tRingBuffer< T > &other)
 Assignment operator.
Read ()
 Removes an element from the ring buffer provided there is one present.
void SetCapacity (size_type capacity)
 Changes the capacity of the ring buffer.
size_type Size () const
 Returns the current number of elements in the ring buffer.
void Skip ()
 Removes an element from the ring buffer without returning it.
 tRingBuffer (size_type capacity=cDEFAULT_CAPACITY)
 Default constructor.
 tRingBuffer (const tRingBuffer< T > &other)
 Copy constructor.
void Write (const T &val, bool overwrite=false)
 Adds an element to the ring buffer provided there is room.
 ~tRingBuffer ()

Static Public Attributes

static const size_type cDEFAULT_CAPACITY = 32

Private Attributes

std::vector< T > m_buffer
size_type m_read
size_type m_write

Detailed Description

template<typename T>
class icl_core::tRingBuffer< T >

A simple ring buffer implementation based on std::vector.

Definition at line 43 of file tRingBuffer.h.


Member Typedef Documentation

template<typename T>
typedef size_t icl_core::tRingBuffer< T >::size_type

Definition at line 47 of file tRingBuffer.h.

template<typename T>
typedef T icl_core::tRingBuffer< T >::value_type

Definition at line 46 of file tRingBuffer.h.


Constructor & Destructor Documentation

template<typename T>
icl_core::tRingBuffer< T >::tRingBuffer ( size_type  capacity = cDEFAULT_CAPACITY) [inline]

Default constructor.

Definition at line 51 of file tRingBuffer.h.

template<typename T>
icl_core::tRingBuffer< T >::tRingBuffer ( const tRingBuffer< T > &  other) [inline]

Copy constructor.

Definition at line 56 of file tRingBuffer.h.

template<typename T>
icl_core::tRingBuffer< T >::~tRingBuffer ( ) [inline]

Destructor documentation which Jan Oberlaender hasn't done till now!

Definition at line 229 of file tRingBuffer.h.


Member Function Documentation

template<typename T>
const T& icl_core::tRingBuffer< T >::At ( size_type  pos) const [inline]

Read an arbitrary element from the ring buffer without removing it.

Throws an exception if the index is out of range.

Parameters:
posThe position into the buffer. 0 is the oldest element currently present.

Definition at line 104 of file tRingBuffer.h.

template<typename T>
T& icl_core::tRingBuffer< T >::At ( size_type  pos) [inline]

Access an arbitrary element in the ring buffer without removing it.

Throws an exception if the index is out of range.

Parameters:
posThe position into the buffer. 0 is the oldest element currently present.

Definition at line 126 of file tRingBuffer.h.

template<typename T>
size_type icl_core::tRingBuffer< T >::Capacity ( ) const [inline]

Returns the capacity of the ring buffer.

Definition at line 189 of file tRingBuffer.h.

template<typename T>
void icl_core::tRingBuffer< T >::Clear ( ) [inline]

Clears the ring buffer.

Definition at line 70 of file tRingBuffer.h.

template<typename T>
tRingBuffer& icl_core::tRingBuffer< T >::operator= ( const tRingBuffer< T > &  other) [inline]

Assignment operator.

Definition at line 61 of file tRingBuffer.h.

template<typename T>
T icl_core::tRingBuffer< T >::Read ( ) [inline]

Removes an element from the ring buffer provided there is one present.

Throws an exception if the buffer is empty.

Definition at line 160 of file tRingBuffer.h.

template<typename T>
void icl_core::tRingBuffer< T >::SetCapacity ( size_type  capacity) [inline]

Changes the capacity of the ring buffer.

If the new capacity is less than the current buffer size, only the latest capacity elements are kept, the rest are destroyed.

Definition at line 196 of file tRingBuffer.h.

template<typename T>
size_type icl_core::tRingBuffer< T >::Size ( ) const [inline]

Returns the current number of elements in the ring buffer.

Definition at line 176 of file tRingBuffer.h.

template<typename T>
void icl_core::tRingBuffer< T >::Skip ( ) [inline]

Removes an element from the ring buffer without returning it.

Definition at line 144 of file tRingBuffer.h.

template<typename T>
void icl_core::tRingBuffer< T >::Write ( const T &  val,
bool  overwrite = false 
) [inline]

Adds an element to the ring buffer provided there is room.

If overwrite == false, throws an exception if the element can not be added. If overwrite == true, old elements are discarded to make room for new ones.

Definition at line 77 of file tRingBuffer.h.


Member Data Documentation

template<typename T>
const size_type icl_core::tRingBuffer< T >::cDEFAULT_CAPACITY = 32 [static]

Definition at line 48 of file tRingBuffer.h.

template<typename T>
std::vector<T> icl_core::tRingBuffer< T >::m_buffer [private]

Definition at line 233 of file tRingBuffer.h.

template<typename T>
size_type icl_core::tRingBuffer< T >::m_read [private]

Definition at line 235 of file tRingBuffer.h.

template<typename T>
size_type icl_core::tRingBuffer< T >::m_write [private]

Definition at line 234 of file tRingBuffer.h.


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


schunk_svh_driver
Author(s): Georg Heppner
autogenerated on Fri Aug 28 2015 12:59:20