QtPdCom  1.5.2
QtPdCom::ValueRing< T > Class Template Reference

Time/Value ring buffer. More...

#include <ValueRing.h>

Public Types

typedef QPair< std::chrono::nanoseconds, T > TimeValuePair

Public Member Functions

 ValueRing ()
 Constructor.
 ~ValueRing ()
 Destructor.
void setRange (std::chrono::nanoseconds)
 Sets the range.
std::chrono::nanoseconds getRange () const
void append (std::chrono::nanoseconds time, const T &value)
 Appends a value to the ring.
void copyUntil (const ValueRing< T > &, std::chrono::nanoseconds)
 Copies data from another ring, up to a specific time.
void clear ()
 Clears the ring.
unsigned int getLength () const
TimeValuePairoperator[] (unsigned int index)
 Index operator.
const TimeValuePairoperator[] (unsigned int index) const
 Constant index operator.
TimeValuePairoperator[] (int index)
 Index operator with int argument.
const TimeValuePairoperator[] (int index) const
 Constant index operator with int argument.

Private Member Functions

void removeDeprecated ()
 Remove values that exceed the time range.
void reshape ()
 Reshape the ring to move the offset to zero.

Private Attributes

QList< TimeValuePairring
 Time/Value ring.
unsigned int offset
 Ring offset.
unsigned int length
 Number of valid elements at offset.
std::chrono::nanoseconds range
 Time range covered by the ring.

Detailed Description

template<class T>
class QtPdCom::ValueRing< T >

Time/Value ring buffer.

Member Typedef Documentation

◆ TimeValuePair

template<class T>
typedef QPair<std::chrono::nanoseconds, T> QtPdCom::ValueRing< T >::TimeValuePair

Constructor & Destructor Documentation

◆ ValueRing()

template<class T>
QtPdCom::ValueRing< T >::ValueRing ( )

Constructor.

References length, and offset.

Referenced by copyUntil().

◆ ~ValueRing()

template<class T>
QtPdCom::ValueRing< T >::~ValueRing ( )

Destructor.

Member Function Documentation

◆ append()

template<class T>
void QtPdCom::ValueRing< T >::append ( std::chrono::nanoseconds time,
const T & value )

Appends a value to the ring.

References length, offset, removeDeprecated(), reshape(), and ring.

◆ clear()

template<class T>
void QtPdCom::ValueRing< T >::clear ( )

Clears the ring.

References length, offset, and ring.

Referenced by copyUntil().

◆ copyUntil()

template<class T>
void QtPdCom::ValueRing< T >::copyUntil ( const ValueRing< T > & other,
std::chrono::nanoseconds time )

Copies data from another ring, up to a specific time.

References clear(), length, ring, and ValueRing().

◆ getLength()

template<class T>
unsigned int QtPdCom::ValueRing< T >::getLength ( ) const
inline
Returns
The length.

References length.

◆ getRange()

template<class T>
std::chrono::nanoseconds QtPdCom::ValueRing< T >::getRange ( ) const
inline

References range.

◆ operator[]() [1/4]

template<class T>
ValueRing< T >::TimeValuePair & QtPdCom::ValueRing< T >::operator[] ( int index)
inline

Index operator with int argument.

Allows to specify negative indices (from the end).

References length, offset, and ring.

◆ operator[]() [2/4]

template<class T>
const ValueRing< T >::TimeValuePair & QtPdCom::ValueRing< T >::operator[] ( int index) const
inline

Constant index operator with int argument.

Allows to specify negative indices (from the end).

References length, offset, and ring.

◆ operator[]() [3/4]

template<class T>
ValueRing< T >::TimeValuePair & QtPdCom::ValueRing< T >::operator[] ( unsigned int index)
inline

Index operator.

References offset, and ring.

◆ operator[]() [4/4]

template<class T>
const ValueRing< T >::TimeValuePair & QtPdCom::ValueRing< T >::operator[] ( unsigned int index) const
inline

Constant index operator.

References offset, and ring.

◆ removeDeprecated()

template<class T>
void QtPdCom::ValueRing< T >::removeDeprecated ( )
private

Remove values that exceed the time range.

References length, offset, range, and ring.

Referenced by append(), and setRange().

◆ reshape()

template<class T>
void QtPdCom::ValueRing< T >::reshape ( )
private

Reshape the ring to move the offset to zero.

References length, offset, and ring.

Referenced by append().

◆ setRange()

template<class T>
void QtPdCom::ValueRing< T >::setRange ( std::chrono::nanoseconds r)

Sets the range.

References range, and removeDeprecated().

Member Data Documentation

◆ length

template<class T>
unsigned int QtPdCom::ValueRing< T >::length
private

◆ offset

template<class T>
unsigned int QtPdCom::ValueRing< T >::offset
private

◆ range

template<class T>
std::chrono::nanoseconds QtPdCom::ValueRing< T >::range
private

Time range covered by the ring.

Used to remove values from the end.

Referenced by getRange(), removeDeprecated(), and setRange().

◆ ring

template<class T>
QList<TimeValuePair> QtPdCom::ValueRing< T >::ring
private

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