WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
clockwerk::CircularBuffer< T, L > Class Template Reference

Simple Circular Buffer for data storage. More...

#include <CircularBuffer.hpp>

Inheritance diagram for clockwerk::CircularBuffer< T, L >:

Public Member Functions

 CircularBuffer ()
int16 write (const T &instance)
 Write a single data item into the buffer.
int16 writeBuffer (const T *buffer, uint32 size)
 Write a buffer of data items into the buffer.
Public Member Functions inherited from clockwerk::Queue< T, L >
 Queue ()
int16 write (const T &instance)
 Write a single data item into the queue.
int16 writeBuffer (const T *buffer, uint32 size)
 Write a buffer of data items into the queue.
int16 read (T &instance)
 Read item from the queue and increment the read pointer.
int16 readBuffer (T *buffer, uint32 max_vals, uint32 &num_vals_read)
 Read items from the queue into buffer and increment read pointer.
int16 pop ()
 Function to pop one value from the queue and discard it.
int16 popBuffer (uint32 max_vals, uint32 &num_vals_popped)
 Function to pop a specified number of values from the queue.
int16 peek (T &instance)
 Read item from the queue without incrementing the read pointer.
int16 peekIndex (uint32 index, T &instance)
 Peek index relative to the read pointer without incrementing the read pointer.
int16 peekBuffer (T *buffer, uint32 max_vals, uint32 &num_vals_read)
 Read items from the queue without incrementing the read pointer.
void clear ()
 Clear the queue entirely.
uint32 valsAvailable ()
 Get number of spaces in queue.
uint32 valsHeld ()
 Get the number of values held by the queue.

Additional Inherited Members

Protected Attributes inherited from clockwerk::Queue< T, L >
uint32 _write_idx = 0
 Index to which new data should write.
uint32 _read_idx = 0
 Index from which data should be read.
uint32 _vals_available = L
 Number of values available in the queue.
_buffer [L]
 Data buffer to hold everything stored in the Queue.

Detailed Description

template<typename T, uint32 L>
class clockwerk::CircularBuffer< T, L >

Simple Circular Buffer for data storage.

The Circular Buffer class is a simple, templated, first in first out buffer with modifiable type and size that overwrites when it reaches its max.

Constructor & Destructor Documentation

◆ CircularBuffer()

template<typename T, uint32 L>
clockwerk::CircularBuffer< T, L >::CircularBuffer ( )
inline

Member Function Documentation

◆ write()

template<typename T, uint32 L>
int16 clockwerk::CircularBuffer< T, L >::write ( const T & instance)

Write a single data item into the buffer.

Parameters
instanceThe instance to write into the buffer
Returns
Error code corresponding to success/failure

◆ writeBuffer()

template<typename T, uint32 L>
int16 clockwerk::CircularBuffer< T, L >::writeBuffer ( const T * buffer,
uint32 size )

Write a buffer of data items into the buffer.

Parameters
bufferThe buffer of data to write into the buffer
sizeThe number of items to write into the buffer
Returns
Error code corresponding to success/failure
Note
writeBuffer will outright reject a packet if it is larger than the remaining space. It will not write partial packets.

The documentation for this class was generated from the following file:
  • /Users/mickey/Documents/Projects/warptwin/warpos/clockwerk/src/architecture/CircularBuffer.hpp