MAV'RIC
|
Circular buffer. More...
#include <buffer.hpp>
Public Member Functions | |
Buffer_T (void) | |
Constructor. | |
bool | put_lossy (const T &data) |
Stores data in the buffer even of it overwrites existing data. | |
bool | put (const T &data) |
Stores data in the buffer, until the buffer is full. | |
bool | get (T &data) |
Get the oldest element in the buffer. | |
void | clear (void) |
Clear the buffer. | |
uint32_t | readable (void) const |
Returns the number of available bytes in the buffer. | |
uint32_t | writeable (void) const |
Returns the number of free bytes in the buffer. | |
bool | full (void) const |
Tests whether the buffer is full. | |
bool | empty (void) const |
Tests whether the buffer is empty. | |
bool | get_element (uint32_t index, T &elem) const |
Get value of i-th element in buffer, but does not modify anything. |
Circular buffer.
S | Size of the buffer (256 by default) |
T | Type of buffered data (uint8_t by default) |
Clear the buffer.
This function erases the buffer, note that it does not erase all the bytes one by one so the function call is fast
buffer | Pointer to buffer |
Tests whether the buffer is empty.
Tests whether the buffer is full.
Get the oldest element in the buffer.
data | Data read |
bool Buffer_T< S, T >::get_element | ( | uint32_t | index, |
T & | elem | ||
) | const |
Get value of i-th element in buffer, but does not modify anything.
index | Index of the element to read (input) |
elem | Returned element (output) |
Stores data in the buffer, until the buffer is full.
data | data to write |
Stores data in the buffer even of it overwrites existing data.
data | data to write |
Returns the number of available bytes in the buffer.
Returns the number of free bytes in the buffer.