FancySafeBot 0.0.1
A safe robotics library
Loading...
Searching...
No Matches
Circular buffer

Circular buffer. More...

Classes

class  fsb::CircularBuffer< BufferType, BufferSize >
 Circular Buffer. More...
 

Enumerations

enum class  fsb::CircularBufferStatus : uint8_t { CircularBufferStatus::SUCCESS = 0 , CircularBufferStatus::FULL , CircularBufferStatus::EMPTY , CircularBufferStatus::OVERWRITE }
 

Functions

CircularBufferStatus fsb::CircularBuffer< BufferType, BufferSize >::push (BufferType push_value)
 Add value to the buffer if there is space available.
 
CircularBufferStatus fsb::CircularBuffer< BufferType, BufferSize >::force_push (BufferType push_value)
 Add value to buffer and overwrite oldest value if buffer is full.
 
CircularBufferStatus fsb::CircularBuffer< BufferType, BufferSize >::pop (BufferType &popped_value)
 Get oldest value from buffer.
 
CircularBufferStatus fsb::CircularBuffer< BufferType, BufferSize >::pop_all (std::array< BufferType, BufferSize > &popped_values, size_t &num_popped)
 Pop all values from the buffer into an array.
 
void fsb::CircularBuffer< BufferType, BufferSize >::reset ()
 Reset buffer to empty state.
 
size_t fsb::CircularBuffer< BufferType, BufferSize >::get_filled () const
 Get number of filled buffer positions.
 
size_t fsb::CircularBuffer< BufferType, BufferSize >::get_remaining () const
 Get number of remaining buffer positions.
 
static size_t fsb::CircularBuffer< BufferType, BufferSize >::get_size ()
 Get total buffer size.
 

Detailed Description

Circular buffer.

Enumeration Type Documentation

◆ CircularBufferStatus

enum class fsb::CircularBufferStatus : uint8_t
strong
Enumerator
SUCCESS 

Successful operation.

FULL 

Operation failed, buffer is full.

EMPTY 

Operation failed, buffer is empty.

OVERWRITE 

Adding to buffer overwrote existing data.

Function Documentation

◆ force_push()

template<typename BufferType , size_t BufferSize>
CircularBufferStatus fsb::CircularBuffer< BufferType, BufferSize >::force_push ( BufferType  push_value)
inline

Add value to buffer and overwrite oldest value if buffer is full.

Parameters
push_valueNew value to add to buffer.
Returns
Status of operation.

◆ get_filled()

template<typename BufferType , size_t BufferSize>
size_t fsb::CircularBuffer< BufferType, BufferSize >::get_filled ( ) const
inline

Get number of filled buffer positions.

Returns
Number of filled buffer positions.

◆ get_remaining()

template<typename BufferType , size_t BufferSize>
size_t fsb::CircularBuffer< BufferType, BufferSize >::get_remaining ( ) const
inline

Get number of remaining buffer positions.

Returns
Number of remaining buffer positions.

◆ get_size()

template<typename BufferType , size_t BufferSize>
static size_t fsb::CircularBuffer< BufferType, BufferSize >::get_size ( )
inlinestatic

Get total buffer size.

Returns
Total buffer size.

◆ pop()

template<typename BufferType , size_t BufferSize>
CircularBufferStatus fsb::CircularBuffer< BufferType, BufferSize >::pop ( BufferType &  popped_value)
inline

Get oldest value from buffer.

Parameters
popped_valueOldest value in buffer.
Returns
Status of operation.

◆ pop_all()

template<typename BufferType , size_t BufferSize>
CircularBufferStatus fsb::CircularBuffer< BufferType, BufferSize >::pop_all ( std::array< BufferType, BufferSize > &  popped_values,
size_t &  num_popped 
)

Pop all values from the buffer into an array.

Copies up to BufferSize oldest values into popped_values in order from oldest to newest. The actual number of values copied is stored in num_popped.

Parameters
[out]popped_valuesArray to receive popped values (oldest at index 0).
[out]num_poppedNumber of values written into popped_values.
Returns
CircularBufferStatus::SUCCESS on success (this function always returns SUCCESS).

◆ push()

template<typename BufferType , size_t BufferSize>
CircularBufferStatus fsb::CircularBuffer< BufferType, BufferSize >::push ( BufferType  push_value)
inline

Add value to the buffer if there is space available.

Parameters
push_valueNew value to add to buffer.
Returns
Status of operation.