mxlib
c++ tools for analyzing astronomical data and other tasks by Jared R. Males. [git repo]
|
Circular buffer which wraps with an if statement (branching) [faster than mod, less memory than index].
Definition at line 299 of file circularBuffer.hpp.
#include <sigproc/circularBuffer.hpp>
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< circularBufferBranch< _storedT, _indexT >, _storedT, _indexT > | |
typedef circularBufferBranch< _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 | |
circularBufferBranch () | |
Default c'tor. More... | |
circularBufferBranch (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... | |
storedT & | at (indexT refEntry, indexT idx) |
Interface implementation for entry access. More... | |
const storedT & | at (indexT refEntry, indexT idx) const |
Interface implementation for entry access, const version. More... | |
Public Member Functions inherited from mx::sigproc::circularBufferBase< circularBufferBranch< _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... | |
storedT & | operator[] (indexT idx) |
Get the entry at a given index. More... | |
const storedT & | operator[] (indexT idx) const |
storedT & | at (indexT refEntry, indexT idx) |
Get the entry at a given index relative a fixed reference entry. More... | |
const storedT & | at (indexT refEntry, indexT idx) const |
Get the entry at a given index relative a fixed start entry, const version. More... | |
Additional Inherited Members | |
Protected Attributes inherited from mx::sigproc::circularBufferBase< circularBufferBranch< _storedT, _indexT >, _storedT, _indexT > | |
std::vector< storedT > | m_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... | |
typedef _indexT mx::sigproc::circularBufferBranch< _storedT, _indexT >::indexT |
The index type, also used for sizes.
Definition at line 304 of file circularBuffer.hpp.
typedef _storedT mx::sigproc::circularBufferBranch< _storedT, _indexT >::storedT |
The maximum number of entries to allow in the buffer before wrapping.
Definition at line 303 of file circularBuffer.hpp.
|
inline |
Default c'tor.
Definition at line 312 of file circularBuffer.hpp.
|
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.
[in] | maxEnt | the maximum number of entries this buffer will hold |
Definition at line 320 of file circularBuffer.hpp.
|
inline |
Interface implementation for entry access.
Accesses the idx-th element relative to refEntry, using a branch (if-statement) to wrap
[in] | refEntry | the entry to start counting from |
[in] | idx | the index of the entry to access |
Definition at line 353 of file circularBuffer.hpp.
References mx::sigproc::circularBufferBase< circularBufferBranch< _storedT, _indexT >, _storedT, _indexT >::m_buffer.
|
inline |
Interface implementation for entry access, const version.
Accesses the idx-th element relative to refEntry, using a branch (if-statement) to wrap
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
[in] | refEntry | the entry to start counting from |
[in] | idx | the index of the entry to access |
Definition at line 368 of file circularBuffer.hpp.
References mx::sigproc::circularBufferBase< circularBufferBranch< _storedT, _indexT >, _storedT, _indexT >::m_buffer.
|
inline |
Interface implementation for maxEntries.
Resets the wrap entry to 0.
[in] | maxEnt | the maximum number of entries this buffer will hold |
Definition at line 327 of file circularBuffer.hpp.
|
inline |
Interface implementation for wrapping setup after the startup phase.
This is called after maxEntries have been added.
Definition at line 343 of file circularBuffer.hpp.
References mx::sigproc::circularBufferBase< circularBufferBranch< _storedT, _indexT >, _storedT, _indexT >::m_maxEntries, and mx::sigproc::circularBufferBase< circularBufferBranch< _storedT, _indexT >, _storedT, _indexT >::m_nextEntry.
|
inline |
Interface implementation for wrapping setup during the startup phase.
This is called before maxEntries have been added.
Definition at line 335 of file circularBuffer.hpp.
References mx::sigproc::circularBufferBase< circularBufferBranch< _storedT, _indexT >, _storedT, _indexT >::m_buffer.