Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::SyncCircularBuffer< T, Size > Class Template Reference

#include <SyncCircularBuffer.h>

Public Member Functions

void put (const T &elem)
 
get (unsigned int i=0)
 Gets an element from the buffer, without removing it.
 
last ()
 Returns the last element added in the buffer.
 
pop ()
 Pops the first element in the buffer.
 
size_t count () const
 Counts the elements in the buffer.
 
bool isEmpty () const
 
bool isFull () const
 
void waitUntilNotEmpty ()
 Waits until the buffer contains at least one element.
 
size_t getSize () const
 Returns the maximum number of elements that can be stored in the buffer.
 

Detailed Description

template<typename T, unsigned int Size>
class Boardcore::SyncCircularBuffer< T, Size >

Implementation of a synchronized circular buffer

Definition at line 42 of file SyncCircularBuffer.h.

Member Function Documentation

◆ count()

template<typename T , unsigned int Size>
size_t Boardcore::SyncCircularBuffer< T, Size >::count ( ) const
inline

Counts the elements in the buffer.

Returns
Number of elements in the buffer.

Definition at line 104 of file SyncCircularBuffer.h.

◆ get()

template<typename T , unsigned int Size>
T Boardcore::SyncCircularBuffer< T, Size >::get ( unsigned int i = 0)
inline

Gets an element from the buffer, without removing it.

Index starts from the oldest element in the buffer. get() returns the first element.

Warning
Remember to catch the exception!
Exceptions
range_errorif index >= count().
Parameters
iIndex of the element to get, starting from the oldest.
Returns
The element.

Definition at line 67 of file SyncCircularBuffer.h.

◆ getSize()

template<typename T , unsigned int Size>
size_t Boardcore::SyncCircularBuffer< T, Size >::getSize ( ) const
inline

Returns the maximum number of elements that can be stored in the buffer.

Returns
Buffer size.

Definition at line 138 of file SyncCircularBuffer.h.

◆ isEmpty()

template<typename T , unsigned int Size>
bool Boardcore::SyncCircularBuffer< T, Size >::isEmpty ( ) const
inline

Definition at line 110 of file SyncCircularBuffer.h.

◆ isFull()

template<typename T , unsigned int Size>
bool Boardcore::SyncCircularBuffer< T, Size >::isFull ( ) const
inline

Definition at line 116 of file SyncCircularBuffer.h.

◆ last()

template<typename T , unsigned int Size>
T Boardcore::SyncCircularBuffer< T, Size >::last ( )
inline

Returns the last element added in the buffer.

Warning
Remember to catch the exception!
Exceptions
range_errorif buffer is empty.
Returns
The element.

Definition at line 80 of file SyncCircularBuffer.h.

◆ pop()

template<typename T , unsigned int Size>
T Boardcore::SyncCircularBuffer< T, Size >::pop ( )
inline

Pops the first element in the buffer.

Warning
Remember to catch the exception!
Exceptions
range_errorif buffer is empty.
Returns
The element that has been popped.

Definition at line 93 of file SyncCircularBuffer.h.

◆ put()

template<typename T , unsigned int Size>
void Boardcore::SyncCircularBuffer< T, Size >::put ( const T & elem)
inline

Puts a copy of the element in the buffer

Parameters
elemelement

Definition at line 49 of file SyncCircularBuffer.h.

◆ waitUntilNotEmpty()

template<typename T , unsigned int Size>
void Boardcore::SyncCircularBuffer< T, Size >::waitUntilNotEmpty ( )
inline

Waits until the buffer contains at least one element.

Definition at line 125 of file SyncCircularBuffer.h.


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