Skip to content

Class daisy::RingBuffer

template <typename T, size_t size>

ClassList > daisy > RingBuffer

More...

  • #include <ringbuffer.h>

Public Functions

Type Name
void Advance (size_t num_elements)
void Flush ()
T * GetMutableBuffer ()
T ImmediateRead ()
void ImmediateRead (T * destination, size_t num_elements)
void Init ()
void Overwrite (T v)
void Overwrite (const T * source, size_t num_elements)
T Read ()
RingBuffer ()
void Swallow (size_t n)
void Write (T v)
size_t capacity () const
bool isEmpty () const
size_t readable () const
size_t writable () const

Detailed Description

Utility Ring Buffer imported from pichenettes/stmlib

Public Functions Documentation

function Advance

inline void daisy::RingBuffer::Advance (
    size_t num_elements
) 

Advances the write pointer, for when a peripheral is writing to the buffer.


function Flush

inline void daisy::RingBuffer::Flush () 

Flushes unread elements from the ring buffer


function GetMutableBuffer

inline T * daisy::RingBuffer::GetMutableBuffer () 

Returns a pointer to the actual Ring Buffer Useful for when a peripheral needs direct access to the buffer.


function ImmediateRead [½]

inline T daisy::RingBuffer::ImmediateRead () 

Reads next element from ring buffer immediately

Returns:

read value


function ImmediateRead [2/2]

inline void daisy::RingBuffer::ImmediateRead (
    T * destination,
    size_t num_elements
) 

Reads a number of elements into a buffer immediately

Parameters:

  • destination buffer to write to
  • num_elements number of elements in buffer

function Init

inline void daisy::RingBuffer::Init () 

Initializes the Ring Buffer


function Overwrite [½]

inline void daisy::RingBuffer::Overwrite (
    T v
) 

Writes the new element to the ring buffer, overwriting unread data if necessary.

Parameters:

  • v Value to overwrite

function Overwrite [2/2]

inline void daisy::RingBuffer::Overwrite (
    const  T * source,
    size_t num_elements
) 

Overwrites a number of elements using the source buffer as input.

Parameters:

  • source Input buffer
  • num_elements Number of elements in source

function Read

inline T daisy::RingBuffer::Read () 

Reads the first available element from the ring buffer

Returns:

read value


function RingBuffer

inline daisy::RingBuffer::RingBuffer () 

function Swallow

inline void daisy::RingBuffer::Swallow (
    size_t n
) 

Read enough samples to make it possible to read 1 sample.

Parameters:

  • n Size of T ?

function Write

inline void daisy::RingBuffer::Write (
    T v
) 

Writes the value to the next available position in the ring buffer

Parameters:

  • v Value to write

function capacity

inline size_t daisy::RingBuffer::capacity () const

Returns:

The total size of the ring buffer


function isEmpty

inline bool daisy::RingBuffer::isEmpty () const

Returns:

True, if the buffer is empty.


function readable

inline size_t daisy::RingBuffer::readable () const

Returns:

number of unread elements in ring buffer


function writable

inline size_t daisy::RingBuffer::writable () const

Returns:

the number of samples that can be written to ring buffer without overwriting unread data.



The documentation for this class was generated from the following file external-docs/libDaisy/src/util/ringbuffer.h