XMM - Probabilistic Models for Motion Recognition and Mapping

Public Member Functions | Protected Attributes | List of all members
xmm::CircularBuffer< T, channels > Class Template Reference

Simple CircularBuffer Class. More...

#include <xmmCircularbuffer.hpp>

Public Member Functions

 CircularBuffer (unsigned int length=1)
 Constructor. More...
 
operator() (unsigned int channel, unsigned int index) const
 Access data by index & channel. More...
 
void clear ()
 Clear the content of the buffer. More...
 
void push (T const value)
 Add an element to the buffer (single-channel method) More...
 
void push (T const *value)
 Add an element to the buffer (multi-channel method) More...
 
void push (std::vector< T > const &value)
 Add an element to the buffer (multi-channel method) More...
 
unsigned int size () const
 Get the size of the CircularBuffer. More...
 
unsigned int size_t () const
 Get the actual size of the CircularBuffer (< size() if the buffer is not full) More...
 
void resize (unsigned int length)
 Resize the buffer to a specific length. More...
 
std::vector< T > mean () const
 Compute the mean of the buffer. More...
 

Protected Attributes

std::vector< T > data_ [channels]
 buffer data More...
 
unsigned int length_
 length of the buffer More...
 
unsigned int current_index_
 current index in the buffer More...
 
bool full_
 Defines if the CircularBuffer is already full. More...
 

Detailed Description

template<typename T, unsigned int channels = 1>
class xmm::CircularBuffer< T, channels >

Simple CircularBuffer Class.

Multichannel Circular Buffer

Template Parameters
TData type
channelsnumber of channels

Constructor & Destructor Documentation

template<typename T, unsigned int channels = 1>
xmm::CircularBuffer< T, channels >::CircularBuffer ( unsigned int  length = 1)
inline

Constructor.

Parameters
lengthlength of the CircularBuffer

Member Function Documentation

template<typename T, unsigned int channels = 1>
void xmm::CircularBuffer< T, channels >::clear ( )
inline

Clear the content of the buffer.

template<typename T, unsigned int channels = 1>
std::vector<T> xmm::CircularBuffer< T, channels >::mean ( ) const
inline

Compute the mean of the buffer.

Returns
vector containing the mean of the buffer
template<typename T, unsigned int channels = 1>
T xmm::CircularBuffer< T, channels >::operator() ( unsigned int  channel,
unsigned int  index 
) const
inline

Access data by index & channel.

Returns
value at the given index and channel
template<typename T, unsigned int channels = 1>
void xmm::CircularBuffer< T, channels >::push ( T const  value)
inline

Add an element to the buffer (single-channel method)

Parameters
valueelement to add to the buffer
Exceptions
invalid_argumentif the buffer is multi-channel
template<typename T, unsigned int channels = 1>
void xmm::CircularBuffer< T, channels >::push ( T const *  value)
inline

Add an element to the buffer (multi-channel method)

Parameters
valueelement to add to the buffer
template<typename T, unsigned int channels = 1>
void xmm::CircularBuffer< T, channels >::push ( std::vector< T > const &  value)
inline

Add an element to the buffer (multi-channel method)

Parameters
valueelement to add to the buffer
template<typename T, unsigned int channels = 1>
void xmm::CircularBuffer< T, channels >::resize ( unsigned int  length)
inline

Resize the buffer to a specific length.

Parameters
lengthtarget length of the CircularBuffer
template<typename T, unsigned int channels = 1>
unsigned int xmm::CircularBuffer< T, channels >::size ( ) const
inline

Get the size of the CircularBuffer.

Returns
size of the CircularBuffer (length)
template<typename T, unsigned int channels = 1>
unsigned int xmm::CircularBuffer< T, channels >::size_t ( ) const
inline

Get the actual size of the CircularBuffer (< size() if the buffer is not full)

Returns
actual size of the CircularBuffer (length)

Member Data Documentation

template<typename T, unsigned int channels = 1>
unsigned int xmm::CircularBuffer< T, channels >::current_index_
protected

current index in the buffer

template<typename T, unsigned int channels = 1>
std::vector<T> xmm::CircularBuffer< T, channels >::data_[channels]
protected

buffer data

template<typename T, unsigned int channels = 1>
bool xmm::CircularBuffer< T, channels >::full_
protected

Defines if the CircularBuffer is already full.

template<typename T, unsigned int channels = 1>
unsigned int xmm::CircularBuffer< T, channels >::length_
protected

length of the buffer


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