Red Bird Racing VCU v2
 
Loading...
Searching...
No Matches
RingBuffer< T, size > Class Template Reference

RingBuffer (circular buffer) template class A small circular queue to hold a fixed number of elements. More...

#include <Queue.hpp>

Collaboration diagram for RingBuffer< T, size >:

Public Member Functions

constexpr RingBuffer ()
 
void push (T val)
 Pushes a new value into the ring buffer. This will overwrite the oldest value if the buffer is full.
 
void getLinearBuffer (T *out)
 Returns the elements in the buffer in linear order.
 

Public Attributes

buffer [size]
 
uint8_t head
 
uint8_t count
 

Detailed Description

template<typename T, uint8_t size>
class RingBuffer< T, size >

RingBuffer (circular buffer) template class A small circular queue to hold a fixed number of elements.

Template Parameters
TType of elements stored in the buffer
sizeCapacity of the buffer

Definition at line 24 of file Queue.hpp.

Constructor & Destructor Documentation

◆ RingBuffer()

template<typename T , uint8_t size>
constexpr RingBuffer< T, size >::RingBuffer ( )
inlineconstexpr

Definition at line 29 of file Queue.hpp.

Member Function Documentation

◆ getLinearBuffer()

template<typename T , uint8_t size>
void RingBuffer< T, size >::getLinearBuffer ( T *  out)
inline

Returns the elements in the buffer in linear order.

Parameters
outPointer to an array where the linear buffer will be stored. This array shall be created by the caller and must have at least 'size' elements.
Note
The order of elements in the output array will be from oldest to newest.

Definition at line 51 of file Queue.hpp.

References RingBuffer< T, size >::buffer, RingBuffer< T, size >::count, and RingBuffer< T, size >::head.

◆ push()

template<typename T , uint8_t size>
void RingBuffer< T, size >::push ( val)
inline

Pushes a new value into the ring buffer. This will overwrite the oldest value if the buffer is full.

Parameters
valThe value to be added to the buffer.

Definition at line 37 of file Queue.hpp.

References RingBuffer< T, size >::buffer, RingBuffer< T, size >::count, and RingBuffer< T, size >::head.

Member Data Documentation

◆ buffer

template<typename T , uint8_t size>
T RingBuffer< T, size >::buffer[size]

◆ count

template<typename T , uint8_t size>
uint8_t RingBuffer< T, size >::count

◆ head

template<typename T , uint8_t size>
uint8_t RingBuffer< T, size >::head

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