mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
mx::sigproc::circularBufferIndex< _storedT, _indexT > Class Template Reference

template<typename _storedT, typename _indexT>
class mx::sigproc::circularBufferIndex< _storedT, _indexT >

Circular buffer which wraps with a pre-populated indices array [generally fastest].

Definition at line 456 of file circularBuffer.hpp.

#include <sigproc/circularBuffer.hpp>

+ Inheritance diagram for mx::sigproc::circularBufferIndex< _storedT, _indexT >:

Public Types

typedef _storedT storedT
 The maximum number of entries to allow in the buffer before wrapping. More...
 
typedef _indexT indexT
 The index type, also used for sizes. More...
 
- Public Types inherited from mx::sigproc::circularBufferBase< circularBufferIndex< _storedT, _indexT >, _storedT, _indexT >
typedef circularBufferIndex< _storedT, _indexT > derivedT
 The child class. More...
 
typedef _storedT storedT
 The type stored in the circular buffer. More...
 
typedef _indexT indexT
 The index type, also used for sizes. More...
 

Public Member Functions

 circularBufferIndex ()
 Default c'tor. More...
 
 circularBufferIndex (indexT maxEnt)
 Sizing constructor. More...
 
void setMaxEntries (indexT maxEnt)
 Interface implementation for maxEntries. More...
 
void setWrapStartup ()
 Interface implementation for wrapping setup during the startup phase. More...
 
void setWrap ()
 Interface implementation for wrapping setup after the startup phase. More...
 
storedTat (indexT refEntry, indexT idx)
 Interface implementation for entry access. More...
 
const storedTat (indexT refEntry, indexT idx) const
 Interface implementation for entry access, const version. More...
 
- Public Member Functions inherited from mx::sigproc::circularBufferBase< circularBufferIndex< _storedT, _indexT >, _storedT, _indexT >
 circularBufferBase ()
 Default c'tor. More...
 
 circularBufferBase (indexT maxEnt)
 Sizing constructor. More...
 
void maxEntries (indexT maxEnt)
 Set the maximum size of the buffer. More...
 
indexT maxEntries ()
 Get the maximum size of the buffer. More...
 
indexT size () const
 Get the number of entries. More...
 
void nextEntry (const storedT &newEnt)
 Add the next entry to the circular buffer. More...
 
indexT earliest ()
 Returns the index of the earliest entry. More...
 
indexT latest ()
 Returns the index of the latest entry. More...
 
storedToperator[] (indexT idx)
 Get the entry at a given index. More...
 
const storedToperator[] (indexT idx) const
 
storedTat (indexT refEntry, indexT idx)
 Get the entry at a given index relative a fixed reference entry. More...
 
const storedTat (indexT refEntry, indexT idx) const
 Get the entry at a given index relative a fixed start entry, const version. More...
 

Protected Attributes

std::vector< size_t > m_indices
 Vector of indices for fast indexing into parent's m_buffer. More...
 
- Protected Attributes inherited from mx::sigproc::circularBufferBase< circularBufferIndex< _storedT, _indexT >, _storedT, _indexT >
std::vector< storedTm_buffer
 The circular buffer storage. More...
 
indexT m_maxEntries
 The maximum number of entries to allow in the buffer before wrapping. More...
 
indexT m_nextEntry
 Index into m_buffer of the next entry. This is the oldest entry in the buffer. More...
 
indexT m_latest
 Index into m_buff of the latest entry. This is the newest entry in the buffer. More...
 
uint64_t m_mono
 A monotonic counter, which is incremented for each new entry, and reset on call to maxEntries. More...
 

Member Typedef Documentation

◆ indexT

template<typename _storedT , typename _indexT >
typedef _indexT mx::sigproc::circularBufferIndex< _storedT, _indexT >::indexT

The index type, also used for sizes.

Definition at line 460 of file circularBuffer.hpp.

◆ storedT

template<typename _storedT , typename _indexT >
typedef _storedT mx::sigproc::circularBufferIndex< _storedT, _indexT >::storedT

The maximum number of entries to allow in the buffer before wrapping.

Definition at line 459 of file circularBuffer.hpp.

Constructor & Destructor Documentation

◆ circularBufferIndex() [1/2]

template<typename _storedT , typename _indexT >
mx::sigproc::circularBufferIndex< _storedT, _indexT >::circularBufferIndex ( )
inline

Default c'tor.

Definition at line 469 of file circularBuffer.hpp.

◆ circularBufferIndex() [2/2]

template<typename _storedT , typename _indexT >
mx::sigproc::circularBufferIndex< _storedT, _indexT >::circularBufferIndex ( indexT  maxEnt)
inlineexplicit

Sizing constructor.

Sets the maximum size of the buffer. Note that this will not be the size until a full set of entries have been added to the buffer.

Parameters
[in]maxEntthe maximum number of entries this buffer will hold

Definition at line 477 of file circularBuffer.hpp.

Member Function Documentation

◆ at() [1/2]

template<typename _storedT , typename _indexT >
storedT& mx::sigproc::circularBufferIndex< _storedT, _indexT >::at ( indexT  refEntry,
indexT  idx 
)
inline

Interface implementation for entry access.

Accesses the idx-th element relative to refEntry, using the pre-populated indices to wrap

Returns
a reference to the idx-th element
Parameters
[in]refEntrythe entry to start counting from
[in]idxthe index of the entry to access

Definition at line 513 of file circularBuffer.hpp.

References mx::sigproc::circularBufferBase< circularBufferIndex< _storedT, _indexT >, _storedT, _indexT >::m_buffer.

◆ at() [2/2]

template<typename _storedT , typename _indexT >
const storedT& mx::sigproc::circularBufferIndex< _storedT, _indexT >::at ( indexT  refEntry,
indexT  idx 
) const
inline

Interface implementation for entry access, const version.

Accesses the idx-th element relative to refEntry, using the pre-populated indices to wrap

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Returns
a const reference to the idx-th element
Parameters
[in]refEntrythe entry to start counting from
[in]idxthe index of the entry to access

Definition at line 527 of file circularBuffer.hpp.

References mx::sigproc::circularBufferBase< circularBufferIndex< _storedT, _indexT >, _storedT, _indexT >::m_buffer.

◆ setMaxEntries()

template<typename _storedT , typename _indexT >
void mx::sigproc::circularBufferIndex< _storedT, _indexT >::setMaxEntries ( indexT  maxEnt)
inline

Interface implementation for maxEntries.

Resizes and populates the indices array.

Parameters
[in]maxEntthe maximum number of entries this buffer will hold

Definition at line 484 of file circularBuffer.hpp.

References mx::sigproc::circularBufferIndex< _storedT, _indexT >::m_indices, and mx::sigproc::circularBufferBase< circularBufferIndex< _storedT, _indexT >, _storedT, _indexT >::m_maxEntries.

◆ setWrap()

template<typename _storedT , typename _indexT >
void mx::sigproc::circularBufferIndex< _storedT, _indexT >::setWrap ( )
inline

Interface implementation for wrapping setup after the startup phase.

This is called after maxEntries have been added.

Definition at line 504 of file circularBuffer.hpp.

◆ setWrapStartup()

template<typename _storedT , typename _indexT >
void mx::sigproc::circularBufferIndex< _storedT, _indexT >::setWrapStartup ( )
inline

Interface implementation for wrapping setup during the startup phase.

This is called before maxEntries have been added.

Definition at line 497 of file circularBuffer.hpp.

Member Data Documentation

◆ m_indices

template<typename _storedT , typename _indexT >
std::vector<size_t> mx::sigproc::circularBufferIndex< _storedT, _indexT >::m_indices
protected

Vector of indices for fast indexing into parent's m_buffer.

Definition at line 464 of file circularBuffer.hpp.

Referenced by mx::sigproc::circularBufferIndex< _storedT, _indexT >::setMaxEntries().


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