GestureRecognitionToolkit  Version: 0.2.5
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
CircularBuffer< T > Class Template Reference

Public Member Functions

 CircularBuffer ()
 
 CircularBuffer (const CircularBuffer &rhs)
 
 CircularBuffer (unsigned int bufferSize)
 
virtual ~CircularBuffer ()
 
CircularBufferoperator= (const CircularBuffer &rhs)
 
T & operator[] (const unsigned int &index)
 
const T & operator[] (const unsigned int &index) const
 
T & operator() (const unsigned int &index)
 
const T & operator() (const unsigned int &index) const
 
bool resize (const unsigned int newBufferSize)
 
bool resize (const unsigned int newBufferSize, const T &defaultValue)
 
bool push_back (const T &value)
 
bool setAllValues (const T &value)
 
bool reset ()
 
void clear ()
 
 GRT_DEPRECATED_MSG ("Use getData() instead!", std::vector< T > getDataAsVector() const )
 
Vector< T > getData (const bool rawBuffer=false) const
 
bool getInit () const
 
bool getBufferFilled () const
 
unsigned int getSize () const
 
unsigned int getNumValuesInBuffer () const
 
unsigned int getReadPointerPosition () const
 
unsigned int getWritePointerPosition () const
 
getBack () const
 

Protected Attributes

bool bufferInit
 
unsigned int bufferSize
 
unsigned int numValuesInBuffer
 
unsigned int readPtr
 
unsigned int writePtr
 
Vector< T > buffer
 
ErrorLog errorLog
 

Detailed Description

template<class T>
class CircularBuffer< T >

Definition at line 45 of file CircularBuffer.h.

Constructor & Destructor Documentation

template<class T>
CircularBuffer< T >::CircularBuffer ( )
inline

Default Constructor

Definition at line 51 of file CircularBuffer.h.

template<class T>
CircularBuffer< T >::CircularBuffer ( const CircularBuffer< T > &  rhs)
inline

Copy Constructor. Deep copies the data from the rhs instance to this instance

Parameters
constCircularBuffer &rhs: ths instance the data and settings will be copied from

Definition at line 65 of file CircularBuffer.h.

template<class T>
CircularBuffer< T >::CircularBuffer ( unsigned int  bufferSize)
inline

Init Constructor. Resizes the buffer to the size set by bufferSize.

Parameters
unsignedint bufferSize: sets the size of the buffer

Definition at line 91 of file CircularBuffer.h.

template<class T>
virtual CircularBuffer< T >::~CircularBuffer ( )
inlinevirtual

Default Destructor. Cleans up any memory assigned by the buffer.

Definition at line 100 of file CircularBuffer.h.

Member Function Documentation

template<class T>
void CircularBuffer< T >::clear ( )
inline

Clears the buffer, setting the size to 0.

Definition at line 272 of file CircularBuffer.h.

template<class T>
T CircularBuffer< T >::getBack ( ) const
inline

Returns the most recent value added to the buffer.

Returns
returns the most recent value added to the buffer

Definition at line 358 of file CircularBuffer.h.

template<class T>
bool CircularBuffer< T >::getBufferFilled ( ) const
inline

Returns true if the buffer has been filled. If the buffer has not been initialized then this function will always return false.

Returns
returns true if the buffer has been filled, false otherwise

Definition at line 323 of file CircularBuffer.h.

template<class T>
Vector< T > CircularBuffer< T >::getData ( const bool  rawBuffer = false) const
inline

Gets the data in the CircularBuffer's internal buffer as a std::vector. The argument, rawBuffer, controls if the function returns (if rawBuffer = true ) the entire contents of the internal buffer (with unsorted values and a constant size regardless on whether it is filled), or the current contents of the Circular Buffer in order from oldest to newest (if rawBuffer = false).

Returns
returns a std::vector with the data in the buffer

Definition at line 295 of file CircularBuffer.h.

template<class T>
bool CircularBuffer< T >::getInit ( ) const
inline

Returns true if the buffer has been initialized.

Returns
returns true if the buffer has been initialized, false otherwise

Definition at line 316 of file CircularBuffer.h.

template<class T>
unsigned int CircularBuffer< T >::getNumValuesInBuffer ( ) const
inline

Returns the number of values in the buffer.

Returns
returns the number of values in the buffer

Definition at line 337 of file CircularBuffer.h.

template<class T>
unsigned int CircularBuffer< T >::getReadPointerPosition ( ) const
inline

Returns the current position of the read pointer.

Returns
returns the current position of the read pointer

Definition at line 344 of file CircularBuffer.h.

template<class T>
unsigned int CircularBuffer< T >::getSize ( ) const
inline

Returns the size of the buffer.

Returns
returns the size of the bufer

Definition at line 330 of file CircularBuffer.h.

template<class T>
unsigned int CircularBuffer< T >::getWritePointerPosition ( ) const
inline

Returns the current position of the write pointer.

Returns
returns the current position of the write pointer

Definition at line 351 of file CircularBuffer.h.

template<class T>
CircularBuffer< T >::GRT_DEPRECATED_MSG ( "Use getData() instead!"  ,
std::vector< T > getDataAsVector()  const 
)
Deprecated:
This function is now deprecated, you should use getData instead! Gets all the data in the buffer as a std::vector.
Returns
returns a vector will all the data in the buffer
template<class T>
T& CircularBuffer< T >::operator() ( const unsigned int &  index)
inline

This is a special access operator that will return the value at the specific index (regardless of the position of the read pointer).

Parameters
constunsigned int &index: the index of the element you want access to, should be in the range [0 bufferSize-1]
Returns
returns a reference to the element at the index

Definition at line 157 of file CircularBuffer.h.

template<class T>
const T& CircularBuffer< T >::operator() ( const unsigned int &  index) const
inline

This is a special const access operator that will return the value at the specific index (regardless of the position of the read pointer).

Parameters
constunsigned int &index: the index of the element you want access to, should be in the range [0 bufferSize-1]
Returns
returns a const reference to the element at the index

Definition at line 167 of file CircularBuffer.h.

template<class T>
CircularBuffer& CircularBuffer< T >::operator= ( const CircularBuffer< T > &  rhs)
inline

Sets the equals operator. Defines how the data will be copied from the rhs instance to this instance.

Parameters
constCircularBuffer &rhs: the instance the data will be copied from
Returns
returns a reference to this instance

Definition at line 112 of file CircularBuffer.h.

template<class T>
T& CircularBuffer< T >::operator[] ( const unsigned int &  index)
inline

This is the main access operator and will return a value relative to the current read pointer.

Parameters
constunsigned int &index: the index of the element you want access to, should be in the range [0 bufferSize-1]
Returns
returns a reference to the element at the index

Definition at line 137 of file CircularBuffer.h.

template<class T>
const T& CircularBuffer< T >::operator[] ( const unsigned int &  index) const
inline

This is the constant access operator and will return a value relative to the current read pointer.

Parameters
constunsigned int &index: the index of the element you want access to, should be in the range [0 bufferSize-1]
Returns
returns a const reference to the element at the index

Definition at line 147 of file CircularBuffer.h.

template<class T>
bool CircularBuffer< T >::push_back ( const T &  value)
inline

Push the new value into the end of the buffer, this will move both the read and write pointers.

Parameters
constT &value: the value that should be added to the end of the buffer
Returns
returns true if the value was pushed, false otherwise

Definition at line 214 of file CircularBuffer.h.

template<class T>
bool CircularBuffer< T >::reset ( )
inline

Resets the numValuesInBuffer, read and write pointers to 0.

Returns
returns true if the buffer was reset, false otherwise

Definition at line 262 of file CircularBuffer.h.

template<class T>
bool CircularBuffer< T >::resize ( const unsigned int  newBufferSize)
inline

Resizes the buffer to the newBufferSize, which must be greater than zero.

Parameters
constunsigned int newBufferSize: the new size of the buffer
Returns
returns true if the buffer was resized

Definition at line 177 of file CircularBuffer.h.

template<class T>
bool CircularBuffer< T >::resize ( const unsigned int  newBufferSize,
const T &  defaultValue 
)
inline

Resizes the buffer to the newBufferSize, which must be greater than zero, and sets all the values to the default value.

Parameters
constunsigned int newBufferSize: the new size of the buffer
constT &defaultValue: the default value that will be copied to every element
Returns
returns true if the buffer was resized

Definition at line 188 of file CircularBuffer.h.

template<class T>
bool CircularBuffer< T >::setAllValues ( const T &  value)
inline

Sets all the values in the buffer to the value.

Parameters
constT &value: the value that will be copied to all the elements in the buffer
Returns
returns true if the buffer was updated, false otherwise

Definition at line 246 of file CircularBuffer.h.


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