93#ifndef _RING_BUFFER_H_
94#define _RING_BUFFER_H_
258 #define INVALID_RING_REF (uint16_t)(-1)
260 #define INVALID_PRIORITY_REF (uint8_t)(-1)
337 static uint32_t
getMemSize(uint16_t _size, uint8_t _maxPriorities=1);
375 bool add(
const T &val, uint8_t _priority=0);
447#include "RingBuffer.tpp"
#define INVALID_RING_REF
Constant for an invalid index reference for the buffer.
Template Class that holds values with given priorities in a ring buffer.
bool isEmpty(uint8_t _priority=0xff) const
Check is ring buffer empty.
tPriorityRef * priorityReferencies
Pointer to priority references in buffer.
uint16_t size
Number of values that can be stored in the ring buffer.
void clean()
This function does nothing at the moment!
uint16_t getSize() const
Get the size of the ring buffer.
uint8_t maxPriorities
highest priority possible
void clear()
Clears the whole ring buffer.
tValueSlot * buffer
Pointer to the ring puffer in memory.
virtual ~tPriorityRingBuffer()
Destroy the priority ring buffer object Frees all memory.
uint16_t count()
Returns the number of values in the ring buffer.
bool add(const T &val, uint8_t _priority=0)
Add a value to the ring buffer with a given priority.
T * getAddRef(uint8_t _priority=0)
Get the pointer to new value added to the ring buffer.
const T * getReadRef(uint8_t _priority)
Get the pointer to value with given priority read out from the ring buffer.
uint16_t tail
Index of the last occupied index in the ring buffer.
static uint32_t getMemSize(uint16_t _size, uint8_t _maxPriorities=1)
Get the size of memory required by ring buffer.
uint16_t head
Index of the first free index in the ring buffer.
bool read(T &val)
Reads highest priority value out from the ring buffer.
const T * getReadRef(uint8_t *_priority=0)
Get pointer to highest priority value read out from the the ring buffer.
tPriorityRingBuffer(uint16_t _size, uint8_t _maxPriorities=1)
Construct a new Priority ring buffer object.
Template Class that holds values in a ring buffer.
uint16_t getSize() const
Get the size of the ring buffer.
bool add(const T &val)
Adds a new value to the ring buffer.
bool read(T &val)
Reads a value out from the ring buffer.
T * getAddRef()
Get the pointer to new value added to the ring buffer.
uint16_t tail
Index of the last value in the ring buffer.
bool isEmpty() const
Checks if the ring buffer is empty.
uint16_t count()
Returns the number of values in the ring buffer.
uint16_t size
Number of values that can be stored in the ring buffer.
virtual ~tRingBuffer()
Destroy the ring buffer object.
T * buffer
Pointer to the ring buffer of values in memory.
uint16_t head
Index of the first value in the ring buffer.
T * peek()
Get pointer to next value to be read out from the ring buffer. Function does not read value out from ...
const T * getReadRef()
Get the pointer to value read out from the ring buffer.
void clear()
Clears the whole ring buffer.
tRingBuffer(uint16_t _size)
Construct a new ring buffer object.
Structure handles meta data for each priority.
void clear()
Initialize all attributes to default.
uint16_t next
Index of the next value for this priority in the ring buffer.
uint16_t last
Index of the last value for this priority in the ring buffer.
tPriorityRef()
Initialize all attributes to default.
Structure that holds the actual value and meta data.
uint16_t next
Index of the next value in the ring buffer (???)
T Value
Value stored in ring buffer.
uint8_t priority
Priority of this value.