avr-classes
Public Member Functions | List of all members
RingBuffer< BASETYPE, COUNT > Class Template Reference

#include <ringbuffer.h>

Inheritance diagram for RingBuffer< BASETYPE, COUNT >:
SynchronizedRingBuffer< BASETYPE, COUNT >

Public Member Functions

bool enqueue (BASETYPE item)
 
bool dequeue (BASETYPE *item)
 
bool isEmpty (void)
 
bool isFull (void)
 

Detailed Description

template<class BASETYPE, uint16_t COUNT>
class RingBuffer< BASETYPE, COUNT >

Template class that implements a ring buffer with elements of arbitrary type.

Note
This buffer must be used from a single context only. If you are looking for a thread-safe buffer, please use SynchronizedRingBuffer.
Parameters
BASETYPEType of elements in ring buffer
COUNTMaximum count of elements that can be placed in ring buffer

Member Function Documentation

◆ dequeue()

template<class BASETYPE, uint16_t COUNT>
bool RingBuffer< BASETYPE, COUNT >::dequeue ( BASETYPE *  item)
inline

Gets an element from the ring buffer.

Parameters
itemPointer to buffer to receive the element.
Returns
True if element could be retrieved, false otherwise.

◆ enqueue()

template<class BASETYPE, uint16_t COUNT>
bool RingBuffer< BASETYPE, COUNT >::enqueue ( BASETYPE  item)
inline

Adds an element into the ringer buffer.

Parameters
itemItem to add.
Returns
True if element could be added, false otherwise.

◆ isEmpty()

template<class BASETYPE, uint16_t COUNT>
bool RingBuffer< BASETYPE, COUNT >::isEmpty ( void  )
inline

Returns if buffer is empty.

Returns
True if buffer is empty, false otherwise.

◆ isFull()

template<class BASETYPE, uint16_t COUNT>
bool RingBuffer< BASETYPE, COUNT >::isFull ( void  )
inline

Returns if buffer is full.

Returns
True if buffer is full, false otherwise.