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... | |
ROSaicNodeBase * | node_ |
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... | |
Class for creating, writing to and reading from a circular buffer.
Definition at line 52 of file circular_buffer.hpp.
|
explicit |
Constructor of CircularBuffer.
Definition at line 39 of file circular_buffer.cpp.
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.
|
inline |
Returns capacity_.
Definition at line 62 of file circular_buffer.hpp.
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.
|
inline |
Returns size_.
Definition at line 60 of file circular_buffer.hpp.
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.
|
private |
Capacity of the circular buffer.
Definition at line 78 of file circular_buffer.hpp.
|
private |
Pointer that always points to the same memory address, hence could be const pointer
Definition at line 81 of file circular_buffer.hpp.
|
private |
Specifies where we start writing.
Definition at line 72 of file circular_buffer.hpp.
|
private |
Pointer to the node.
Definition at line 70 of file circular_buffer.hpp.
|
private |
Number of bytes that have been written but not yet read.
Definition at line 76 of file circular_buffer.hpp.
|
private |
Specifies where we start reading.
Definition at line 74 of file circular_buffer.hpp.