Fixposition SDK 0.0.0-heads/main-0-g90a51ff
Collection of c++ libraries and apps for use with Fixposition products
Loading...
Searching...
No Matches
fpsdk::common::utils::CircularBuffer Class Reference

#include <utils.hpp>

Public Member Functions

 CircularBuffer (const std::size_t size)
 Constructor.
 
void Reset ()
 Reset buffer, discard all data.
 
std::size_t Size () const
 Get size (capacity) of buffer.
 
bool Empty () const
 Check if empty.
 
bool Full () const
 Check if full.
 
std::size_t Used () const
 Get size used.
 
std::size_t Avail () const
 Get size available.
 
bool Write (const uint8_t *data, const std::size_t size)
 Write chunk of data to buffer.
 
bool Read (uint8_t *data, const std::size_t size)
 Read chunk of data from buffer.
 
bool Peek (uint8_t *data, const std::size_t size)
 Read chunk of data from buffer (but don't remove it from the buffer)
 

Detailed Description

Circular buffer for chunks of data (bytes, memory). For objects use use boost::circular_buffer or std::deque.

Definition at line 64 of file utils.hpp.

Constructor & Destructor Documentation

◆ CircularBuffer()

fpsdk::common::utils::CircularBuffer::CircularBuffer ( const std::size_t size)

Constructor.

Parameters
[in]sizeSize of buffer [bytes]

Member Function Documentation

◆ Size()

std::size_t fpsdk::common::utils::CircularBuffer::Size ( ) const

Get size (capacity) of buffer.

Returns
the size (capacity) of the buffer

◆ Empty()

bool fpsdk::common::utils::CircularBuffer::Empty ( ) const

Check if empty.

Returns
true if the buffer is empty, false otherwise

◆ Full()

bool fpsdk::common::utils::CircularBuffer::Full ( ) const

Check if full.

Returns
true if the buffer is completely full

◆ Used()

std::size_t fpsdk::common::utils::CircularBuffer::Used ( ) const

Get size used.

Returns
the size of the used part of the buffer

◆ Avail()

std::size_t fpsdk::common::utils::CircularBuffer::Avail ( ) const

Get size available.

Returns
the size of the unused part of the buffer

◆ Write()

bool fpsdk::common::utils::CircularBuffer::Write ( const uint8_t * data,
const std::size_t size )

Write chunk of data to buffer.

Parameters
[in]dataPointer to the data
[in]sizeSize of the data (> 0)
Returns
true if data was copied to the buffer, false otherwise (not enough free space, bad params)

◆ Read()

bool fpsdk::common::utils::CircularBuffer::Read ( uint8_t * data,
const std::size_t size )

Read chunk of data from buffer.

Parameters
[in]dataPointer to the data
[out]sizeSize of the data (> 0)
Returns
true if data was copied from the buffer, false otherwise (not enough available data, bad params)

◆ Peek()

bool fpsdk::common::utils::CircularBuffer::Peek ( uint8_t * data,
const std::size_t size )

Read chunk of data from buffer (but don't remove it from the buffer)

Parameters
[in]dataPointer to the data
[out]sizeSize of the data (> 0)
Returns
true if data was copied from the buffer, false otherwise (not enough available data, bad params)

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