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)
 Get oldest value from buffer.
 
void fsb::CircularBuffer< BufferType, BufferSize >::Reset ()
 Reset buffer to empty state.
 
size_t fsb::CircularBuffer< BufferType, BufferSize >::GetFilled () const
 Get number of filled buffer positions.
 
size_t fsb::CircularBuffer< BufferType, BufferSize >::GetRemaining () const
 Get number of remaining buffer positions.
 
size_t fsb::CircularBuffer< BufferType, BufferSize >::GetSize () const
 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.

◆ GetFilled()

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

Get number of filled buffer positions.

Returns
Number of filled buffer positions.

◆ GetRemaining()

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

Get number of remaining buffer positions.

Returns
Number of remaining buffer positions.

◆ GetSize()

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

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 
)

Get oldest value from buffer.

Parameters
popped_valuesAll values in buffer.
Returns
Status of operation.

◆ 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.