libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::RingBuffer< T, size > Class Template Reference

Detailed Description

template<typename T, size_t size>
class daisy::RingBuffer< T, size >

Utility Ring Buffer
imported from pichenettes/stmlib

#include <ringbuffer.h>

Public Member Functions

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

Constructor & Destructor Documentation

◆ RingBuffer()

template<typename T , size_t size>
daisy::RingBuffer< T, size >::RingBuffer ( )
inline

Member Function Documentation

◆ Advance()

template<typename T , size_t size>
void daisy::RingBuffer< T, size >::Advance ( size_t  num_elements)
inline

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

◆ capacity()

template<typename T , size_t size>
size_t daisy::RingBuffer< T, size >::capacity ( ) const
inline
Returns
The total size of the ring buffer

◆ Flush()

template<typename T , size_t size>
void daisy::RingBuffer< T, size >::Flush ( )
inline

Flushes unread elements from the ring buffer

◆ GetMutableBuffer()

template<typename T , size_t size>
T * daisy::RingBuffer< T, size >::GetMutableBuffer ( )
inline

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

◆ ImmediateRead() [1/2]

template<typename T , size_t size>
T daisy::RingBuffer< T, size >::ImmediateRead ( )
inline

Reads next element from ring buffer immediately

Returns
read value

◆ ImmediateRead() [2/2]

template<typename T , size_t size>
void daisy::RingBuffer< T, size >::ImmediateRead ( T *  destination,
size_t  num_elements 
)
inline

Reads a number of elements into a buffer immediately

Parameters
destinationbuffer to write to
num_elementsnumber of elements in buffer

◆ Init()

template<typename T , size_t size>
void daisy::RingBuffer< T, size >::Init ( )
inline

Initializes the Ring Buffer

◆ isEmpty()

template<typename T , size_t size>
bool daisy::RingBuffer< T, size >::isEmpty ( ) const
inline
Returns
True, if the buffer is empty.

◆ Overwrite() [1/2]

template<typename T , size_t size>
void daisy::RingBuffer< T, size >::Overwrite ( const T *  source,
size_t  num_elements 
)
inline

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

Parameters
sourceInput buffer
num_elementsNumber of elements in source

◆ Overwrite() [2/2]

template<typename T , size_t size>
void daisy::RingBuffer< T, size >::Overwrite ( v)
inline

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

Parameters
vValue to overwrite

◆ Read()

template<typename T , size_t size>
T daisy::RingBuffer< T, size >::Read ( )
inline

Reads the first available element from the ring buffer

Returns
read value

◆ readable()

template<typename T , size_t size>
size_t daisy::RingBuffer< T, size >::readable ( ) const
inline
Returns
number of unread elements in ring buffer

◆ Swallow()

template<typename T , size_t size>
void daisy::RingBuffer< T, size >::Swallow ( size_t  n)
inline

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

Parameters
nSize of T ?

◆ writable()

template<typename T , size_t size>
size_t daisy::RingBuffer< T, size >::writable ( ) const
inline
Returns
the number of samples that can be written to ring buffer without overwriting unread data.

◆ Write()

template<typename T , size_t size>
void daisy::RingBuffer< T, size >::Write ( v)
inline

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

Parameters
vValue to write

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