F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Types::CircularBuffer Class Reference

#include <Utils/Types/CircularBuffer.hpp>

Public Member Functions

 CircularBuffer ()
 
 CircularBuffer (U8 *const buffer, const FwSizeType size)
 
void setup (U8 *const buffer, const FwSizeType size)
 
Fw::SerializeStatus serialize (const U8 *const buffer, const FwSizeType size)
 
Fw::SerializeStatus peek (char &value, FwSizeType offset=0) const
 
Fw::SerializeStatus peek (U8 &value, FwSizeType offset=0) const
 
Fw::SerializeStatus peek (U32 &value, FwSizeType offset=0) const
 
Fw::SerializeStatus peek (U8 *buffer, FwSizeType size, FwSizeType offset=0) const
 
Fw::SerializeStatus rotate (FwSizeType amount)
 
FwSizeType get_allocated_size () const
 
FwSizeType get_free_size () const
 
FwSizeType get_capacity () const
 
FwSizeType get_high_water_mark () const
 
void clear_high_water_mark ()
 

Detailed Description

Definition at line 25 of file CircularBuffer.hpp.

Constructor & Destructor Documentation

◆ CircularBuffer() [1/2]

Types::CircularBuffer::CircularBuffer ( )

Circular buffer constructor. Wraps the supplied buffer as the new data store. Buffer size is supplied in the 'size' argument.

Note: specification of storage buffer must be done using setup before use.

Definition at line 21 of file CircularBuffer.cpp.

◆ CircularBuffer() [2/2]

Types::CircularBuffer::CircularBuffer ( U8 *const  buffer,
const FwSizeType  size 
)

Circular buffer constructor. Wraps the supplied buffer as the new data store. Buffer size is supplied in the 'size' argument. This is equivalent to calling the no-argument constructor followed by setup(buffer, size).

Note: ownership of the supplied buffer is held until the circular buffer is deallocated

Parameters
buffersupplied buffer used as a data store.
sizethe of the supplied data store.

Definition at line 31 of file CircularBuffer.cpp.

Member Function Documentation

◆ clear_high_water_mark()

void Types::CircularBuffer::clear_high_water_mark ( )

Clear tracking of the largest allocated size

Definition at line 161 of file CircularBuffer.cpp.

◆ get_allocated_size()

FwSizeType Types::CircularBuffer::get_allocated_size ( ) const

Get the number of bytes allocated in the buffer

Returns
number of bytes

Definition at line 54 of file CircularBuffer.cpp.

◆ get_capacity()

FwSizeType Types::CircularBuffer::get_capacity ( ) const

Get the logical capacity of the buffer, i.e., the number of available bytes when the buffer is empty

Definition at line 152 of file CircularBuffer.cpp.

◆ get_free_size()

FwSizeType Types::CircularBuffer::get_free_size ( ) const

Get the number of free bytes, i.e., the number of bytes that may be stored in the buffer without deleting data and without exceeding the buffer capacity

Definition at line 58 of file CircularBuffer.cpp.

◆ get_high_water_mark()

FwSizeType Types::CircularBuffer::get_high_water_mark ( ) const

Return the largest tracked allocated size

Definition at line 157 of file CircularBuffer.cpp.

◆ peek() [1/4]

Fw::SerializeStatus Types::CircularBuffer::peek ( char &  value,
FwSizeType  offset = 0 
) const

Deserialize data into the given variable without moving the head index

Parameters
valuevalue to fill
offsetoffset from head to start peak. Default: 0
Returns
Fw::FW_SERIALIZE_OK on success or something else on error

Definition at line 89 of file CircularBuffer.cpp.

◆ peek() [2/4]

Fw::SerializeStatus Types::CircularBuffer::peek ( U8 value,
FwSizeType  offset = 0 
) const

Deserialize data into the given variable without moving the head index

Parameters
valuevalue to fill
offsetoffset from head to start peak. Default: 0
Returns
Fw::FW_SERIALIZE_OK on success or something else on error

Definition at line 94 of file CircularBuffer.cpp.

◆ peek() [3/4]

Fw::SerializeStatus Types::CircularBuffer::peek ( U32 &  value,
FwSizeType  offset = 0 
) const

Deserialize data into the given variable without moving the head index

Parameters
valuevalue to fill
offsetoffset from head to start peak. Default: 0
Returns
Fw::FW_SERIALIZE_OK on success or something else on error

Definition at line 106 of file CircularBuffer.cpp.

◆ peek() [4/4]

Fw::SerializeStatus Types::CircularBuffer::peek ( U8 buffer,
FwSizeType  size,
FwSizeType  offset = 0 
) const

Deserialize data into the given buffer without moving the head variable.

Parameters
bufferbuffer to fill with data of the peek
sizesize in bytes to peek at
offsetoffset from head to start peak. Default: 0
Returns
Fw::FW_SERIALIZE_OK on success or something else on error

Definition at line 124 of file CircularBuffer.cpp.

◆ rotate()

Fw::SerializeStatus Types::CircularBuffer::rotate ( FwSizeType  amount)

Rotate the head index, deleting data from the circular buffer and making space. Cannot rotate more than the available space.

Parameters
amountamount to rotate by (in bytes)
Returns
Fw::FW_SERIALIZE_OK on success or something else on error

Definition at line 141 of file CircularBuffer.cpp.

◆ serialize()

Fw::SerializeStatus Types::CircularBuffer::serialize ( const U8 *const  buffer,
const FwSizeType  size 
)

Serialize a given buffer into this circular buffer. Will not accept more data than space available. This means it will not overwrite existing data.

Parameters
buffersupplied buffer to be serialized.
sizesize of the supplied buffer.
Returns
Fw::FW_SERIALIZE_OK on success or something else on error

Definition at line 69 of file CircularBuffer.cpp.

◆ setup()

void Types::CircularBuffer::setup ( U8 *const  buffer,
const FwSizeType  size 
)

Wraps the supplied buffer as the new data store. Buffer size is supplied in the 'size' argument. Cannot be called after successful setup.

Note: ownership of the supplied buffer is held until the circular buffer is deallocated

Parameters
buffersupplied buffer used as a data store.
sizethe of the supplied data store.

Definition at line 41 of file CircularBuffer.cpp.


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