GestureRecognitionToolkit  Version: 0.1.0
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 44 of file CircularBuffer.h.

Constructor & Destructor Documentation

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

Default Constructor

Definition at line 50 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 64 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 90 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 99 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 271 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 357 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 322 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 294 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 315 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 336 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 343 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 329 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 350 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 156 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 166 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 111 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 136 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 146 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 213 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 261 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 176 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 187 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 245 of file CircularBuffer.h.


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