Some useful stuff

Dependents:   FtEncoder FtControlSet

Embed: (wiki syntax)

« Back to documentation index

BufferOnStack< T, N > Class Template Reference

BufferOnStack< T, N > Class Template Reference

Concrete Buffer class template that implements the element's storage as simple C-array on stack or global memory. More...

#include <Buffer.h>

Inherits Buffer< T, N >.

Public Member Functions

 BufferOnStack ()
 Creates a Buffer class with storage on stack, static or global memory.
 BufferOnStack (const Buffer< T, N > &buf)
 generic "copy constructor" that does not care about the concrete type of the source Buffer as long as T and N template parameters are identical.
 BufferOnStack (const BufferOnStack &buf)
 The real copy constructor.
bool push (const T &element)
 If used as queue or stack, use this function to insert new element to the buffer.
void pushCircular (const T &element)
 If used as ring buffer, use this function to insert new elements to the Buffer.
const T & popLatest ()
 Pop the latest element from buffer. Returns a default instance of type T if empty.
const T & popOldest ()
 Pop the oldest element from buffer. Returns a default instance of type T if empty.
bool empty () const
 Returns true if buffer is empty.
bool full () const
 Returns true if buffer is full.
uint32_t size () const
 Retuns number of currently stored elements.
uint32_t maxSize () const
 returns maximum number of storable elements
void clear ()
 Clear the Buffer.
const T & operator[] (uint32_t idx)
 Read only access operator: Element with index 0 is the oldest and the one with index size()-1 the latest.

Protected Attributes

T * elements
 The buffer for the stored elements, initialized in the concrete specializations.

Detailed Description

template<typename T, uint32_t N>
class BufferOnStack< T, N >

Concrete Buffer class template that implements the element's storage as simple C-array on stack or global memory.

Definition at line 148 of file Buffer.h.


Constructor & Destructor Documentation

Creates a Buffer class with storage on stack, static or global memory.

Definition at line 155 of file Buffer.h.

BufferOnStack ( const Buffer< T, N > &  buf )

generic "copy constructor" that does not care about the concrete type of the source Buffer as long as T and N template parameters are identical.

Utilizes the assignment operator of the base class.

Definition at line 161 of file Buffer.h.

BufferOnStack ( const BufferOnStack< T, N > &  buf )

The real copy constructor.

If this is not defined the compiler rather creates a non working implicit one than using the generic one. Utilizes the assignment operator of the base class.

Definition at line 168 of file Buffer.h.


Member Function Documentation

void clear (  ) [inherited]

Clear the Buffer.

Definition at line 116 of file Buffer.h.

bool empty (  ) const [inherited]

Returns true if buffer is empty.

Definition at line 96 of file Buffer.h.

bool full (  ) const [inherited]

Returns true if buffer is full.

Definition at line 101 of file Buffer.h.

uint32_t maxSize (  ) const [inherited]

returns maximum number of storable elements

Definition at line 111 of file Buffer.h.

const T& operator[] ( uint32_t  idx ) [inherited]

Read only access operator: Element with index 0 is the oldest and the one with index size()-1 the latest.

Definition at line 123 of file Buffer.h.

const T& popLatest (  ) [inherited]

Pop the latest element from buffer. Returns a default instance of type T if empty.

Definition at line 79 of file Buffer.h.

const T& popOldest (  ) [inherited]

Pop the oldest element from buffer. Returns a default instance of type T if empty.

Definition at line 87 of file Buffer.h.

bool push ( const T &  element ) [inherited]

If used as queue or stack, use this function to insert new element to the buffer.

Returns true on success and false if Buffer is full

Definition at line 56 of file Buffer.h.

void pushCircular ( const T &  element ) [inherited]

If used as ring buffer, use this function to insert new elements to the Buffer.

If buffer is full, this function overwrites the oldest element.

Definition at line 68 of file Buffer.h.

uint32_t size (  ) const [inherited]

Retuns number of currently stored elements.

Definition at line 106 of file Buffer.h.


Field Documentation

T* elements [protected, inherited]

The buffer for the stored elements, initialized in the concrete specializations.

Definition at line 15 of file Buffer.h.