F´ Flight Software - C/C++ Documentation  devel
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 NATIVE_UINT_TYPE size)
 
void setup (U8 *const buffer, const NATIVE_UINT_TYPE size)
 
Fw::SerializeStatus serialize (const U8 *const buffer, const NATIVE_UINT_TYPE size)
 
Fw::SerializeStatus peek (char &value, NATIVE_UINT_TYPE offset=0) const
 
Fw::SerializeStatus peek (U8 &value, NATIVE_UINT_TYPE offset=0) const
 
Fw::SerializeStatus peek (U32 &value, NATIVE_UINT_TYPE offset=0) const
 
Fw::SerializeStatus peek (U8 *buffer, NATIVE_UINT_TYPE size, NATIVE_UINT_TYPE offset=0) const
 
Fw::SerializeStatus rotate (NATIVE_UINT_TYPE amount)
 
NATIVE_UINT_TYPE get_allocated_size () const
 
NATIVE_UINT_TYPE get_free_size () const
 
NATIVE_UINT_TYPE get_capacity () const
 
NATIVE_UINT_TYPE get_high_water_mark () const
 
void clear_high_water_mark ()
 

Detailed Description

Definition at line 27 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 25 of file CircularBuffer.cpp.

◆ CircularBuffer() [2/2]

Types::CircularBuffer::CircularBuffer ( U8 *const  buffer,
const NATIVE_UINT_TYPE  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 35 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 165 of file CircularBuffer.cpp.

◆ get_allocated_size()

NATIVE_UINT_TYPE Types::CircularBuffer::get_allocated_size ( ) const

Get the number of bytes allocated in the buffer

Returns
number of bytes

Definition at line 58 of file CircularBuffer.cpp.

◆ get_capacity()

NATIVE_UINT_TYPE 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 156 of file CircularBuffer.cpp.

◆ get_free_size()

NATIVE_UINT_TYPE 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 62 of file CircularBuffer.cpp.

◆ get_high_water_mark()

NATIVE_UINT_TYPE Types::CircularBuffer::get_high_water_mark ( ) const

Return the largest tracked allocated size

Definition at line 161 of file CircularBuffer.cpp.

◆ peek() [1/4]

Fw::SerializeStatus Types::CircularBuffer::peek ( char &  value,
NATIVE_UINT_TYPE  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 93 of file CircularBuffer.cpp.

◆ peek() [2/4]

Fw::SerializeStatus Types::CircularBuffer::peek ( U32 &  value,
NATIVE_UINT_TYPE  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 110 of file CircularBuffer.cpp.

◆ peek() [3/4]

Fw::SerializeStatus Types::CircularBuffer::peek ( U8 value,
NATIVE_UINT_TYPE  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 98 of file CircularBuffer.cpp.

◆ peek() [4/4]

Fw::SerializeStatus Types::CircularBuffer::peek ( U8 buffer,
NATIVE_UINT_TYPE  size,
NATIVE_UINT_TYPE  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 128 of file CircularBuffer.cpp.

◆ rotate()

Fw::SerializeStatus Types::CircularBuffer::rotate ( NATIVE_UINT_TYPE  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 145 of file CircularBuffer.cpp.

◆ serialize()

Fw::SerializeStatus Types::CircularBuffer::serialize ( const U8 *const  buffer,
const NATIVE_UINT_TYPE  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 73 of file CircularBuffer.cpp.

◆ setup()

void Types::CircularBuffer::setup ( U8 *const  buffer,
const NATIVE_UINT_TYPE  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 45 of file CircularBuffer.cpp.


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