Base Module  VST 3.6.5
SDK for developing VST Plug-in
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
TRingBuffer< T > Class Template Reference

RingBuffer template. More...

#include <tringbuffer.h>

Public Member Functions

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

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)

Default constructor.

RingBuffer constructor.

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

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 ( )
virtual

Destructor.

RingBuffer destructor.

Member Function Documentation

bool setBuffer ( T *  data,
int32  n 
)

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)

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

tells if the buffer is empty

Tells if the buffer is empty.

int32 countFree ( ) const

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)

write count items to buffer

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

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)

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 
)

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)

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

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

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 ( )

remove all items from buffer

Remove all items from buffer.

int32 trash ( int32  count)

remove count items from buffer

Remove count items from buffer.

Parameters
[in]count: number of items to be removed
Returns
: number of removed items
Empty

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