semf
|
The LastInBuffer
class implements a kind of circular buffer.
More...
#include <lastinbuffer.h>
Public Member Functions | |
virtual | ~LastInBuffer ()=default |
virtual void | put (T data) |
Writes data in the buffer. More... | |
void | fill (T data) |
Fills the whole buffer with the same object content. More... | |
virtual T & | operator[] (size_t pos) const |
Returns the entry from a specific position in the buffer. More... | |
void | setPos (size_t pos) |
Sets the write position of the buffer. More... | |
size_t | pos () const |
Returns the current write position. More... | |
Public Member Functions inherited from semf::Buffer< T > | |
Buffer ()=default | |
Buffer (T buffer[], size_t bufferSize) | |
Constructor with data array initialization. More... | |
virtual | ~Buffer ()=default |
void | setBuffer (T buffer[], size_t bufferSize) |
Sets the data array. More... | |
virtual T & | operator[] (size_t pos) const |
Returns the entry from a specific position in the buffer. More... | |
size_t | size () const |
Returns the size of the buffer. More... | |
virtual size_t | count () const |
Returns the number of entries stored in the buffer. More... | |
T * | data () const |
Returns the pointer to the first element of the data array. More... | |
The LastInBuffer
class implements a kind of circular buffer.
Compared to RingBuffer
, LastInBuffer
has no write limitation: Always the oldest data will be overwritten if the buffer is full.
The data base is an array with the data type defined by the template parameter T
. To use the LastInBuffer
set the array in the constructor or by the function setData()
.
The data can be accessed by the functions
data()
to get the pointer to the data array,at()
to get the element on a specific position andThe data can be stored in the buffer by the function put()
.
See also Buffer
, LastInDmaBuffer
RingBuffer
and Average
.
LastInBuffer
a global CriticalSection
object is required.Type | of data to handle. |
Definition at line 39 of file lastinbuffer.h.
|
virtualdefault |
void semf::LastInBuffer< T >::fill | ( | T | data | ) |
Fills the whole buffer with the same object content.
data | The data which should be written into the whole buffer. |
Definition at line 87 of file lastinbuffer.h.
|
virtual |
Returns the entry from a specific position in the buffer.
pos | Position in the buffer. |
Reimplemented from semf::Buffer< T >.
Reimplemented in semf::LastInDmaBuffer< T >.
Definition at line 98 of file lastinbuffer.h.
size_t semf::LastInBuffer< T >::pos |
Returns the current write position.
Definition at line 115 of file lastinbuffer.h.
|
virtual |
Writes data in the buffer.
data | Data to write in the buffer. |
Reimplemented in semf::LastInDmaBuffer< T >.
Definition at line 78 of file lastinbuffer.h.
void semf::LastInBuffer< T >::setPos | ( | size_t | pos | ) |
Sets the write position of the buffer.
pos | Write position. |
Definition at line 109 of file lastinbuffer.h.