TRingBuffer< T > Class Template Reference
[Template Containers]

RingBuffer template. More...

#include <tringbuffer.h>

Public Member Functions

 TRingBuffer (int32 n=0)
 Default constructor.
 TRingBuffer (T *data, int32 n)
 construct a RingBuffer with n data objects
virtual ~TRingBuffer ()
 Destructor.
bool setBuffer (T *data, int32 n)
 fills the buffer with n data objects
bool resize (int32 n)
 resize buffer to size n
bool isEmpty () const
 tells if the buffer is empty
int32 countFree () const
 returns the number of free slots in the buffer
int32 countFilled () const
 returns the number of items in the buffer
int32 size () const
 returns the number of slots in the buffer
template<int32 count>
int32 write (const T *data)
 write count items to buffer
int32 write (const T *data, int32 count)
 write count items to buffer
bool write (const T &data)
 write one item to buffer
int32 read (T *data, int32 count)
 read count items from buffer
bool read (T &data)
 read one item from buffer
const T & peek () const
 look at current item in buffer
int32 peek (T *data, int32 count) const
 look at count items in buffer
void flush ()
 remove all items from buffer
int32 trash (int32 count)
 remove count items from buffer

Detailed Description

template<class T>
class Steinberg::TRingBuffer< T >

RingBuffer template.

A RingBuffer is a data structure that uses a fixed-size buffer with circular connections.


Constructor & Destructor Documentation

TRingBuffer ( int32  n = 0  )  [inline]

Default constructor.

RingBuffer constructor.

Parameters:
[in] n : initial size of the buffer
TRingBuffer ( T *  data,
int32  n 
) [inline]

construct a RingBuffer with n data objects

RingBuffer constructor with specified data pointer.

Parameters:
[in] data : pointer to data objects to be held in the buffer
[in] n : initial size of the buffer
~TRingBuffer (  )  [inline, virtual]

Destructor.

RingBuffer destructor.


Member Function Documentation

bool setBuffer ( T *  data,
int32  n 
) [inline]

fills the buffer with n data objects

Sets the RingBuffer to specified data pointer and given size n.

Parameters:
[in] data : pointer to data objects to be held in the buffer
[in] n : size of the buffer
Returns:
: true
bool resize ( int32  n  )  [inline]

resize buffer to size n

Resize buffer to size n, if the buffer is the owner of the data.

Parameters:
[in] n : number of requested slots in the buffer
Returns:
true if successful
bool isEmpty (  )  const [inline]

tells if the buffer is empty

Tells if the buffer is empty.

int32 countFree (  )  const [inline]

returns the number of free slots in the buffer

Returns the number of free slots in the buffer.

int32 countFilled (  )  const [inline]

returns the number of items in the buffer

Returns the number of items in the buffer.

int32 size (  )  const [inline]

returns the number of slots in the buffer

Returns the number of slots in the buffer.

int32 write ( const T *  data  )  [inline]

write count items to buffer

Parameters:
[in] data : pointer to the data structure
[in] count : number of items to be written
Returns:
: number of written items
int32 write ( const T *  data,
int32  count 
) [inline]

write count items to buffer

Write count items to buffer.

Parameters:
[in] data : pointer to the data structure
[in] count : number of items to be written
Returns:
: number of written items
bool write ( const T &  data  )  [inline]

write one item to buffer

Write one item to buffer.

Parameters:
[in] data : reference to the data structure
Returns:
: true if successful / false if overflow
int32 read ( T *  data,
int32  count 
) [inline]

read count items from buffer

Parameters:
[in,out] data : pointer to the data structure
[in] count : number of requested items
Returns:
: number of read items
bool read ( T &  data  )  [inline]

read one item from buffer

Read one item from buffer.

Parameters:
[in,out] data : reference to the data structure
Returns:
: true if successful
const T & peek (  )  const [inline]

look at current item in buffer

look at current item in buffer without changing the read position

Returns:
: peeked item
int32 peek ( T *  data,
int32  count 
) const [inline]

look at count items in buffer

look at count items in buffer without changing the read position

Parameters:
[in,out] data : pointer to the data structure
[in] count : number of requested items
Returns:
: number of peeked items
void flush (  )  [inline]

remove all items from buffer

Remove all items from buffer.

int32 trash ( int32  count  )  [inline]

remove count items from buffer

Remove count items from buffer.

Parameters:
[in] count : number of items to be removed
Returns:
: number of removed items
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
Empty

Copyright ©2013 Steinberg Media Technologies GmbH. All Rights Reserved.