Dataflow Runtime API  3.1.1.0
Public Types | Public Member Functions | List of all members
imt::base::core::util::RingBuffer< ElementType, BufferSize > Class Template Reference

This template class implements a FIFO ringbuffer. More...

#include <Imt.Base.Core.Util/RingBuffer.h>

Public Types

enum  Constants { Constants_BufferSize = BufferSize }
 Constants. More...
 
typedef ElementType ValueType
 The type of the values/elements in this buffer. More...
 

Public Member Functions

 RingBuffer (void)
 Constructor. More...
 
virtual ~RingBuffer (void)
 Destructor not virtual. More...
 
void push (const ValueType &newValue)
 Add a value to the buffer (overwrite oldest if full) More...
 
const ValueTypetop (void) const
 The value on the top of the buffer. More...
 
const ValueTypetop (uint16_t offset) const
 The value on the top of the buffer. More...
 
ValueTypetop (void)
 The value on the top of the buffer. More...
 
ValueTypetop (uint16_t offset)
 The value on the top of the buffer. More...
 
ValueType pop (void)
 The value on the top of the buffer. More...
 
const ValueTypebottom (void) const
 Get the last recently added value. More...
 
const ValueTypebottomAndClearAll (void)
 Get the last recently added value. More...
 
const ValueTypebottom (uint16_t offset) const
 Get the last recently added value. More...
 
bool isEmpty (void) const
 Checks if the buffer is empty. More...
 
bool isFull (void) const
 Checks if the buffer is full. More...
 
uint16_t getSizeUsed (void) const
 Get the number of items in the buffer. More...
 

Detailed Description

template<typename ElementType, uint16_t BufferSize>
class imt::base::core::util::RingBuffer< ElementType, BufferSize >

This template class implements a FIFO ringbuffer.

Parameters
ElementTypeThe types of the elements in the buffer.
BufferSizeSize of the buffer. Hint: The maximal number of items is one smaller than this value.

Member Typedef Documentation

◆ ValueType

template<typename ElementType , uint16_t BufferSize>
typedef ElementType imt::base::core::util::RingBuffer< ElementType, BufferSize >::ValueType

The type of the values/elements in this buffer.

Member Enumeration Documentation

◆ Constants

template<typename ElementType , uint16_t BufferSize>
enum imt::base::core::util::RingBuffer::Constants

Constants.

Enumerator
Constants_BufferSize 

The size of the buffer.

Constructor & Destructor Documentation

◆ RingBuffer()

template<typename ElementType , uint16_t BufferSize>
imt::base::core::util::RingBuffer< ElementType, BufferSize >::RingBuffer ( void  )
inline

Constructor.

◆ ~RingBuffer()

template<typename ElementType , uint16_t BufferSize>
virtual imt::base::core::util::RingBuffer< ElementType, BufferSize >::~RingBuffer ( void  )
inlinevirtual

Destructor not virtual.

Member Function Documentation

◆ bottom() [1/2]

template<typename ElementType , uint16_t BufferSize>
const ValueType& imt::base::core::util::RingBuffer< ElementType, BufferSize >::bottom ( uint16_t  offset) const
inline

Get the last recently added value.

The value will not be removed.

Parameters
offsetThe offset from the last inserted value. offset = 0: The same as bottom() -> The last inserted value.
Returns
Reference to the requested value.

◆ bottom() [2/2]

template<typename ElementType , uint16_t BufferSize>
const ValueType& imt::base::core::util::RingBuffer< ElementType, BufferSize >::bottom ( void  ) const
inline

Get the last recently added value.

The value will not be removed.

Returns
Reference to the last recently added value.

◆ bottomAndClearAll()

template<typename ElementType , uint16_t BufferSize>
const ValueType& imt::base::core::util::RingBuffer< ElementType, BufferSize >::bottomAndClearAll ( void  )
inline

Get the last recently added value.

All values will be removed.

Returns
Reference to the last recently added value.

◆ getSizeUsed()

template<typename ElementType , uint16_t BufferSize>
uint16_t imt::base::core::util::RingBuffer< ElementType, BufferSize >::getSizeUsed ( void  ) const
inline

Get the number of items in the buffer.

Returns
The number of items in the buffer.

◆ isEmpty()

template<typename ElementType , uint16_t BufferSize>
bool imt::base::core::util::RingBuffer< ElementType, BufferSize >::isEmpty ( void  ) const
inline

Checks if the buffer is empty.

Returns
True if buffer is empty.

◆ isFull()

template<typename ElementType , uint16_t BufferSize>
bool imt::base::core::util::RingBuffer< ElementType, BufferSize >::isFull ( void  ) const
inline

Checks if the buffer is full.

Returns
True if buffer is full.

◆ pop()

template<typename ElementType , uint16_t BufferSize>
ValueType imt::base::core::util::RingBuffer< ElementType, BufferSize >::pop ( void  )
inline

The value on the top of the buffer.

The value will be removed from the buffer. There is no check if the value is valid. To check this use isEmpty.

Returns
The oldest value which is on the top of the buffer.

◆ push()

template<typename ElementType , uint16_t BufferSize>
void imt::base::core::util::RingBuffer< ElementType, BufferSize >::push ( const ValueType newValue)
inline

Add a value to the buffer (overwrite oldest if full)

Parameters
newValueThe value to be added

◆ top() [1/4]

template<typename ElementType , uint16_t BufferSize>
ValueType& imt::base::core::util::RingBuffer< ElementType, BufferSize >::top ( uint16_t  offset)
inline

The value on the top of the buffer.

The value will not be removed from the buffer. There is no check if the value is valid. To check this use isEmpty.

Parameters
offsetThe offset from the value on the top of the buffer. offset = 0: The same as top() -> The last inserted value.
Returns
The oldest value which is on the top of the buffer.

◆ top() [2/4]

template<typename ElementType , uint16_t BufferSize>
const ValueType& imt::base::core::util::RingBuffer< ElementType, BufferSize >::top ( uint16_t  offset) const
inline

The value on the top of the buffer.

The value will not be removed from the buffer. There is no check if the value is valid. To check this use isEmpty.

Parameters
offsetThe offset from the value on the top of the buffer. offset = 0: The same as top() -> The last inserted value.
Returns
The oldest value which is on the top of the buffer.

◆ top() [3/4]

template<typename ElementType , uint16_t BufferSize>
ValueType& imt::base::core::util::RingBuffer< ElementType, BufferSize >::top ( void  )
inline

The value on the top of the buffer.

The value will not be removed from the buffer. There is no check if the value is valid. To check this use isEmpty.

Returns
The oldest value which is on the top of the buffer.

◆ top() [4/4]

template<typename ElementType , uint16_t BufferSize>
const ValueType& imt::base::core::util::RingBuffer< ElementType, BufferSize >::top ( void  ) const
inline

The value on the top of the buffer.

The value will not be removed from the buffer. There is no check if the value is valid. To check this use isEmpty.

Returns
The oldest value which is on the top of the buffer.

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