Gamma  0.9.5
Generic Synthesis Library
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
Ring< T, A > Class Template Reference

Ring buffer. More...

#include <Containers.h>

Inheritance diagram for Ring< T, A >:
Array< T, A > ArrayBase< T, SizeArray, A > DelayN< Tv > DelayN< T, A > DoubleRing< T, A > RingFill< T, A > MovingAvg< Tv >

List of all members.

Public Member Functions

 Ring (uint32_t size=0, const T &value=T())
T & readBack ()
 Returns reference to backmost (oldest) element.
T & readFront ()
 Returns reference to frontmost (newest) element.
T & read (uint32_t ago)
 Returns reference to element 'ago' indices behind front.
void copy (T *dst, uint32_t len, uint32_t delay) const
 Copies len elements starting from element pos() - delay into dst.
void copyUnwrap (T *dst, uint32_t len) const
 Copy elements starting from last in into dst unwrapping from ring.
uint32_t pos () const
 Return absolute index of frontmost (newest) element.
bool reachedEnd () const
 Returns whether the last element written was at the end of the array.
uint32_t indexBack () const
 Returns absolute index of backmost (oldest) element.
uint32_t indexFront () const
 Returns absolute index of frontmost (newest) element.
uint32_t indexPrev (uint32_t ago) const
 Returns absolute index of a previously written element.
void operator() (const T &v)
 Write new element.
void pos (uint32_t index)
 Set absolute buffer index of writer.
void reset ()
 Reset write position to beginning.
void writeClip (const T &v)
 Writes element unless at end of buffer.
T & operator[] (uint32_t i)
 Get write reference to element.
const T & operator[] (uint32_t i) const
 Get read-only reference to element.
ArrayBaseassign (const T &v)
 Sets all elements to value.
ArrayBaseassign (const T &v, uint32_t end, uint32_t stride=1, uint32_t start=0)
 Sets linear slice of elements to value.
T * elems ()
 Get writable pointer to elements.
const T * elems () const
 Get read-only pointer to elements.
uint32_t size () const
 Returns number of elements in array.
void clear ()
 Destroys all elements and frees memory.
void own ()
 Ensures ownership of elements.
bool isSoleOwner () const
 Returns true if we are the sole owner of data internally allocated.
void resize (uint32_t newSize, const T &c=T())
 Resizes number of elements in array.
void source (ArrayBase< T, SizeArray, A > &src)
 Sets source of array elements to another array.
void source (T *src, uint32_t size)
 Sets source of array elements to another array.

Static Public Member Functions

static int references (T *m)
 Returns number of pointers to memory address being managed.

Detailed Description

template<class T, class A = gam::Allocator<T>>
class gam::Ring< T, A >

Ring buffer.


Constructor & Destructor Documentation

Ring ( uint32_t  size = 0,
const T &  value = T() 
) [explicit]
Parameters:
[in]sizeNumber of elements in ring.
[in]valueInitial value of all elements.

Member Function Documentation

ArrayBase& assign ( const T &  v,
uint32_t  end,
uint32_t  stride = 1,
uint32_t  start = 0 
) [inherited]

Sets linear slice of elements to value.

Parameters:
[in]vvalue to be copied as new content
[in]endend index (exclusive)
[in]strideindex stride amount
[in]startstart index (inclusive)
void own ( ) [inherited]

Ensures ownership of elements.

If the array is not already the sole owner, new memory is allocated and the previously referenced array elements are copied.

void resize ( uint32_t  newSize,
const T &  c = T() 
) [inherited]

Resizes number of elements in array.

If the new size is less than the old size, then elements are truncated. If the new size is greater than the old size, then the argument value is copied into the additional elements.


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