OpenCPN Partial API docs
Loading...
Searching...
No Matches
CircularBuffer< T > Class Template Reference

Fixed size, synchronized FIFO buffer. More...

#include <comm_buffers.h>

Public Member Functions

 CircularBuffer (size_t size)
 
void Reset () noexcept
 Reset internal state, ditch possible contained data.
 
size_t Capacity () const noexcept
 Return buffer max size.
 
size_t Size () const noexcept
 Return actual size.
 
bool IsEmpty () const noexcept
 Return true if buffer is empty.
 
bool IsFull () const noexcept
 Return true if buffer is full.
 
bool SafePut (const T &item) noexcept
 Add item to buffer without throwing exceptions.
 
void Put (const T &item)
 Add item to buffer; throw BufferError if full.
 
Get ()
 Get item from buff; throw BufferError if empty.
 
bool Get (T &item) noexcept
 Retrieve item from buffer without throwing exceptions.
 
const T & Peek () const
 
bool Peek (T &item) const noexcept
 

Detailed Description

template<class T>
class CircularBuffer< T >

Fixed size, synchronized FIFO buffer.

Some methods throws BufferError.

Definition at line 107 of file comm_buffers.h.

Constructor & Destructor Documentation

◆ CircularBuffer()

template<class T >
CircularBuffer< T >::CircularBuffer ( size_t  size)
inlineexplicit

Definition at line 109 of file comm_buffers.h.

Member Function Documentation

◆ Capacity()

template<class T >
size_t CircularBuffer< T >::Capacity ( ) const
inlinenoexcept

Return buffer max size.

Definition at line 125 of file comm_buffers.h.

◆ Get() [1/2]

template<class T >
T CircularBuffer< T >::Get ( )
inline

Get item from buff; throw BufferError if empty.

Definition at line 167 of file comm_buffers.h.

◆ Get() [2/2]

template<class T >
bool CircularBuffer< T >::Get ( T &  item)
inlinenoexcept

Retrieve item from buffer without throwing exceptions.

Returns
true if success i.e., buffer is not empty.

Definition at line 177 of file comm_buffers.h.

◆ IsEmpty()

template<class T >
bool CircularBuffer< T >::IsEmpty ( ) const
inlinenoexcept

Return true if buffer is empty.

Definition at line 137 of file comm_buffers.h.

◆ IsFull()

template<class T >
bool CircularBuffer< T >::IsFull ( ) const
inlinenoexcept

Return true if buffer is full.

Definition at line 143 of file comm_buffers.h.

◆ Peek() [1/2]

template<class T >
const T & CircularBuffer< T >::Peek ( ) const
inline

Definition at line 184 of file comm_buffers.h.

◆ Peek() [2/2]

template<class T >
bool CircularBuffer< T >::Peek ( T &  item) const
inlinenoexcept

Definition at line 190 of file comm_buffers.h.

◆ Put()

template<class T >
void CircularBuffer< T >::Put ( const T &  item)
inline

Add item to buffer; throw BufferError if full.

Definition at line 160 of file comm_buffers.h.

◆ Reset()

template<class T >
void CircularBuffer< T >::Reset ( )
inlinenoexcept

Reset internal state, ditch possible contained data.

Definition at line 117 of file comm_buffers.h.

◆ SafePut()

template<class T >
bool CircularBuffer< T >::SafePut ( const T &  item)
inlinenoexcept

Add item to buffer without throwing exceptions.

Returns
true if success i.e., buffer is not full.

Definition at line 152 of file comm_buffers.h.

◆ Size()

template<class T >
size_t CircularBuffer< T >::Size ( ) const
inlinenoexcept

Return actual size.

Definition at line 128 of file comm_buffers.h.


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