Public Member Functions | Private Attributes | List of all members
CircularBuffer Class Reference

Class for creating, writing to and reading from a circular buffer. More...

#include <circular_buffer.hpp>

Public Member Functions

std::size_t capacity () const
 Returns capacity_. More...
 
 CircularBuffer (ROSaicNodeBase *node, std::size_t capacity)
 Constructor of CircularBuffer. More...
 
std::size_t read (uint8_t *data, std::size_t bytes)
 Returns number of bytes read. More...
 
std::size_t size () const
 Returns size_. More...
 
std::size_t write (const uint8_t *data, std::size_t bytes)
 Returns number of bytes written. More...
 
 ~CircularBuffer ()
 Destructor of CircularBuffer. More...
 

Private Attributes

std::size_t capacity_
 Capacity of the circular buffer. More...
 
uint8_t * data_
 
std::size_t head_
 Specifies where we start writing. More...
 
ROSaicNodeBasenode_
 Pointer to the node. More...
 
std::size_t size_
 Number of bytes that have been written but not yet read. More...
 
std::size_t tail_
 Specifies where we start reading. More...
 

Detailed Description

Class for creating, writing to and reading from a circular buffer.

Definition at line 52 of file circular_buffer.hpp.

Constructor & Destructor Documentation

◆ CircularBuffer()

CircularBuffer::CircularBuffer ( ROSaicNodeBase node,
std::size_t  capacity 
)
explicit

Constructor of CircularBuffer.

Definition at line 39 of file circular_buffer.cpp.

◆ ~CircularBuffer()

CircularBuffer::~CircularBuffer ( )

Destructor of CircularBuffer.

The destructor frees memory (first line) and points the dangling pointer to NULL (second line).

Definition at line 47 of file circular_buffer.cpp.

Member Function Documentation

◆ capacity()

std::size_t CircularBuffer::capacity ( ) const
inline

Returns capacity_.

Definition at line 62 of file circular_buffer.hpp.

◆ read()

std::size_t CircularBuffer::read ( uint8_t *  data,
std::size_t  bytes 
)

Returns number of bytes read.

Definition at line 90 of file circular_buffer.cpp.

◆ size()

std::size_t CircularBuffer::size ( ) const
inline

Returns size_.

Definition at line 60 of file circular_buffer.hpp.

◆ write()

std::size_t CircularBuffer::write ( const uint8_t *  data,
std::size_t  bytes 
)

Returns number of bytes written.

Definition at line 53 of file circular_buffer.cpp.

Member Data Documentation

◆ capacity_

std::size_t CircularBuffer::capacity_
private

Capacity of the circular buffer.

Definition at line 78 of file circular_buffer.hpp.

◆ data_

uint8_t* CircularBuffer::data_
private

Pointer that always points to the same memory address, hence could be const pointer

Definition at line 81 of file circular_buffer.hpp.

◆ head_

std::size_t CircularBuffer::head_
private

Specifies where we start writing.

Definition at line 72 of file circular_buffer.hpp.

◆ node_

ROSaicNodeBase* CircularBuffer::node_
private

Pointer to the node.

Definition at line 70 of file circular_buffer.hpp.

◆ size_

std::size_t CircularBuffer::size_
private

Number of bytes that have been written but not yet read.

Definition at line 76 of file circular_buffer.hpp.

◆ tail_

std::size_t CircularBuffer::tail_
private

Specifies where we start reading.

Definition at line 74 of file circular_buffer.hpp.


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


septentrio_gnss_driver
Author(s): Tibor Dome
autogenerated on Sat Mar 11 2023 03:12:56