OpenWareLaboratory
CircularBuffer< DataType, IndexType > Class Template Reference
Inheritance diagram for CircularBuffer< DataType, IndexType >:

Public Member Functions

 CircularBuffer ()
 
 CircularBuffer (DataType *data, IndexType size)
 
void clear ()
 
void delay (DataType *in, DataType *out, IndexType len, int delay_samples)
 Write to buffer and read with a delay. More...
 
IndexType getContiguousReadCapacity () const
 
IndexType getContiguousWriteCapacity () const
 
DataType * getData ()
 
IndexType getDelay () const
 Get the read index expressed as delay behind the write index. More...
 
IndexType getReadCapacity () const
 
DataType * getReadHead ()
 
IndexType getReadIndex ()
 
IndexType getSize () const
 
IndexType getWriteCapacity () const
 
DataType * getWriteHead ()
 
IndexType getWriteIndex ()
 
bool isEmpty () const
 
bool isFull () const
 
void moveReadHead (int32_t samples)
 
void moveWriteHead (int32_t samples)
 
void overdub (DataType c)
 
void overdubAt (IndexType index, DataType value)
 
DataType read ()
 
void read (DataType *dst, IndexType len)
 
DataType readAt (IndexType index)
 
void reset ()
 
void setAll (const DataType value)
 
void setData (DataType *data, IndexType len)
 
void setDelay (int samples)
 Set the read index. More...
 
void setReadIndex (IndexType pos)
 
void setWriteIndex (IndexType pos)
 
void skipUntilLast (char c)
 
void write (DataType *source, IndexType len)
 
void write (DataType c)
 
void writeAt (IndexType index, DataType value)
 

Static Public Member Functions

static CircularBuffer< DataType > * create (IndexType len)
 
static void destroy (CircularBuffer< DataType > *obj)
 

Protected Attributes

DataType * data
 
bool empty = true
 
IndexType readpos = 0
 
IndexType size
 
IndexType writepos = 0
 

Detailed Description

template<typename DataType, typename IndexType = size_t>
class CircularBuffer< DataType, IndexType >

Definition at line 12 of file CircularBuffer.h.

Constructor & Destructor Documentation

◆ CircularBuffer() [1/2]

template<typename DataType , typename IndexType = size_t>
CircularBuffer< DataType, IndexType >::CircularBuffer ( )
inline

Definition at line 20 of file CircularBuffer.h.

◆ CircularBuffer() [2/2]

template<typename DataType , typename IndexType = size_t>
CircularBuffer< DataType, IndexType >::CircularBuffer ( DataType *  data,
IndexType  size 
)
inline

Definition at line 21 of file CircularBuffer.h.

Member Function Documentation

◆ clear()

◆ create()

template<typename DataType , typename IndexType = size_t>
static CircularBuffer<DataType>* CircularBuffer< DataType, IndexType >::create ( IndexType  len)
inlinestatic

Definition at line 224 of file CircularBuffer.h.

References CircularBuffer< DataType, IndexType >::clear().

◆ delay()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::delay ( DataType *  in,
DataType *  out,
IndexType  len,
int  delay_samples 
)
inline

◆ destroy()

template<typename DataType , typename IndexType = size_t>
static void CircularBuffer< DataType, IndexType >::destroy ( CircularBuffer< DataType > *  obj)
inlinestatic

Definition at line 230 of file CircularBuffer.h.

References CircularBuffer< DataType, IndexType >::data.

◆ getContiguousReadCapacity()

template<typename DataType , typename IndexType = size_t>
IndexType CircularBuffer< DataType, IndexType >::getContiguousReadCapacity ( ) const
inline

◆ getContiguousWriteCapacity()

template<typename DataType , typename IndexType = size_t>
IndexType CircularBuffer< DataType, IndexType >::getContiguousWriteCapacity ( ) const
inline

◆ getData()

template<typename DataType , typename IndexType = size_t>
DataType* CircularBuffer< DataType, IndexType >::getData ( )
inline

◆ getDelay()

template<typename DataType , typename IndexType = size_t>
IndexType CircularBuffer< DataType, IndexType >::getDelay ( ) const
inline

Get the read index expressed as delay behind the write index.

Definition at line 175 of file CircularBuffer.h.

References CircularBuffer< DataType, IndexType >::readpos, CircularBuffer< DataType, IndexType >::size, and CircularBuffer< DataType, IndexType >::writepos.

◆ getReadCapacity()

template<typename DataType , typename IndexType = size_t>
IndexType CircularBuffer< DataType, IndexType >::getReadCapacity ( ) const
inline

◆ getReadHead()

template<typename DataType , typename IndexType = size_t>
DataType* CircularBuffer< DataType, IndexType >::getReadHead ( )
inline

◆ getReadIndex()

template<typename DataType , typename IndexType = size_t>
IndexType CircularBuffer< DataType, IndexType >::getReadIndex ( )
inline

Definition at line 147 of file CircularBuffer.h.

References CircularBuffer< DataType, IndexType >::readpos.

◆ getSize()

template<typename DataType , typename IndexType = size_t>
IndexType CircularBuffer< DataType, IndexType >::getSize ( ) const
inline

◆ getWriteCapacity()

◆ getWriteHead()

template<typename DataType , typename IndexType = size_t>
DataType* CircularBuffer< DataType, IndexType >::getWriteHead ( )
inline

◆ getWriteIndex()

template<typename DataType , typename IndexType = size_t>
IndexType CircularBuffer< DataType, IndexType >::getWriteIndex ( )
inline

Definition at line 129 of file CircularBuffer.h.

References CircularBuffer< DataType, IndexType >::writepos.

◆ isEmpty()

template<typename DataType , typename IndexType = size_t>
bool CircularBuffer< DataType, IndexType >::isEmpty ( ) const
inline

Definition at line 36 of file CircularBuffer.h.

References CircularBuffer< DataType, IndexType >::empty.

◆ isFull()

template<typename DataType , typename IndexType = size_t>
bool CircularBuffer< DataType, IndexType >::isFull ( ) const
inline

◆ moveReadHead()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::moveReadHead ( int32_t  samples)
inline

◆ moveWriteHead()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::moveWriteHead ( int32_t  samples)
inline

◆ overdub()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::overdub ( DataType  c)
inline

◆ overdubAt()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::overdubAt ( IndexType  index,
DataType  value 
)
inline

◆ read() [1/2]

◆ read() [2/2]

◆ readAt()

template<typename DataType , typename IndexType = size_t>
DataType CircularBuffer< DataType, IndexType >::readAt ( IndexType  index)
inline

◆ reset()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::reset ( )
inline

◆ setAll()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::setAll ( const DataType  value)
inline

◆ setData()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::setData ( DataType *  data,
IndexType  len 
)
inline

◆ setDelay()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::setDelay ( int  samples)
inline

◆ setReadIndex()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::setReadIndex ( IndexType  pos)
inline

◆ setWriteIndex()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::setWriteIndex ( IndexType  pos)
inline

◆ skipUntilLast()

◆ write() [1/2]

◆ write() [2/2]

◆ writeAt()

template<typename DataType , typename IndexType = size_t>
void CircularBuffer< DataType, IndexType >::writeAt ( IndexType  index,
DataType  value 
)
inline

Field Documentation

◆ data

◆ empty

◆ readpos

◆ size

◆ writepos


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