The Sparta Modeling Framework
|
A data structure allowing appending at the end, beginning, or insert in the middle, but erase anywhere with collapse. More...
#include <CircularBuffer.hpp>
Public Types | |
typedef CircularBuffer< DataT > | CircularBufferType |
typedef DataT | value_type |
typedef uint32_t | size_type |
typedef CircularBufferIterator< false > | iterator |
Typedef for regular iterator. | |
typedef CircularBufferIterator< true > | const_iterator |
Typedef for constant iterator. | |
typedef CircularBufferReverseIterator< const_iterator > | const_reverse_iterator |
Typedef for regular reverse iterator. | |
typedef CircularBufferReverseIterator< iterator > | reverse_iterator |
Typedef for constant reverse iterator. | |
Public Member Functions | |
CircularBuffer (const std::string &name, const uint32_t max_size, const Clock *clk, StatisticSet *statset=nullptr, InstrumentationNode::visibility_t stat_vis_general=InstrumentationNode::AUTO_VISIBILITY, InstrumentationNode::visibility_t stat_vis_detailed=InstrumentationNode::VIS_HIDDEN, InstrumentationNode::visibility_t stat_vis_max=InstrumentationNode::AUTO_VISIBILITY, InstrumentationNode::visibility_t stat_vis_avg=InstrumentationNode::AUTO_VISIBILITY) | |
Construct a CircularBuffer. | |
CircularBuffer (const CircularBuffer< value_type > &)=delete | |
No copies allowed for CircularBuffer. | |
CircularBuffer & | operator= (const CircularBuffer< value_type > &)=delete |
No copies, no moves allowed for CircularBuffer. | |
void | enableCollection (TreeNode *parent) |
Request that this queue begin collecting its contents for pipeline collection. | |
std::string | getName () const |
Get this CircularBuffer's name. | |
bool | isValid (uint32_t idx) const |
Determine if data at the index is valid. | |
size_type | capacity () const |
Return the fixed size of this CircularBuffer. | |
size_type | size () const |
Return the number of valid entries. | |
size_type | numFree () const |
Return the number of free entries. | |
void | push_back (const value_type &dat) |
Append data to the end of CircularBuffer, and return a CircularBufferIterator. | |
void | push_back (value_type &&dat) |
Append data to the end of CircularBuffer, and return a CircularBufferIterator. | |
iterator | insert (const iterator &entry, const value_type &dat) |
Insert the given data before the given iterator. | |
iterator | insert (const iterator &entry, value_type &&dat) |
Insert the given data before the given iterator. | |
iterator | insert (const const_iterator &entry, const value_type &dat) |
Insert the given data before the given iterator. | |
iterator | insert (const const_iterator &entry, value_type &&dat) |
Insert the given data before the given iterator. | |
void | erase (const_iterator entry) |
erase the index at which the entry exists in the CircularBuffer. | |
void | erase (const_reverse_iterator entry) |
erase the index at which the entry exists in the CircularBuffer. | |
void | erase (reverse_iterator entry) |
void | clear () |
Empty the contents of the CircularBuffer. | |
iterator | begin () |
Get the iterator pointing to the oldest entry of CircularBuffer. | |
iterator | end () |
Returns an iterator referring to past-the-end of the newest element in the CircularBuffer. | |
const_iterator | begin () const |
Get the iterator pointing to the oldest entry of CircularBuffer. | |
const_iterator | end () const |
Returns an iterator referring to past-the-end of the newest element in the CircularBuffer. | |
reverse_iterator | rbegin () |
Get the iterator pointing to the oldest entry of CircularBuffer. | |
reverse_iterator | rend () |
Returns an iterator referring to past-the-end of the newest element in the CircularBuffer. | |
const_reverse_iterator | rbegin () const |
Get the iterator pointing to the oldest entry of CircularBuffer. | |
const_reverse_iterator | rend () const |
Returns an iterator referring to past-the-end of the newest element in the CircularBuffer. | |
value_type | operator[] (const uint32_t idx) |
Returns the data at the given index. Will assert if out of range. | |
A data structure allowing appending at the end, beginning, or insert in the middle, but erase anywhere with collapse.
The CircularBuffer allows a user to append data to the end or the beginning of the buffer, or insert into the middle of the CircularBuffer, and erase anywhere. The CircularBuffer will collapse on empty entries unlike the sparta::Array.
The CircularBuffer acks like a standard container via public push_back, insert, and erase methods. The CircularBufferIterator can be used as an index into the CircularBuffer, and maintains knowledge internally of its location in the CircularBuffer, as well whether or not it still represents a valid entry.
Where the CircularBuffer differs from the standard Buffer is that the CircularBuffer has no concept of "full", meaning it will wrap around and overwrite older entries. For example, if the CircularBuffer is 10 entries in size, the user can append to the CircularBuffer 11 times without error as the 11th append will simply overwrite the original first entry. Buffer, on the other hand, will assert.
Iterator behavior:
Example:
DataT | The data type contained in the CircularBuffer. |
Definition at line 85 of file CircularBuffer.hpp.
typedef CircularBuffer<DataT> sparta::CircularBuffer< DataT >::CircularBufferType |
Definition at line 91 of file CircularBuffer.hpp.
typedef CircularBufferIterator<true> sparta::CircularBuffer< DataT >::const_iterator |
Typedef for constant iterator.
Definition at line 376 of file CircularBuffer.hpp.
typedef CircularBufferReverseIterator<const_iterator> sparta::CircularBuffer< DataT >::const_reverse_iterator |
Typedef for regular reverse iterator.
Definition at line 379 of file CircularBuffer.hpp.
typedef CircularBufferIterator<false> sparta::CircularBuffer< DataT >::iterator |
Typedef for regular iterator.
Definition at line 373 of file CircularBuffer.hpp.
typedef CircularBufferReverseIterator<iterator> sparta::CircularBuffer< DataT >::reverse_iterator |
Typedef for constant reverse iterator.
Definition at line 382 of file CircularBuffer.hpp.
typedef uint32_t sparta::CircularBuffer< DataT >::size_type |
Definition at line 97 of file CircularBuffer.hpp.
typedef DataT sparta::CircularBuffer< DataT >::value_type |
Definition at line 94 of file CircularBuffer.hpp.
sparta::CircularBuffer< DataT >::CircularBuffer | ( | const std::string & | name, |
const uint32_t | max_size, | ||
const Clock * | clk, | ||
StatisticSet * | statset = nullptr , |
||
InstrumentationNode::visibility_t | stat_vis_general = InstrumentationNode::AUTO_VISIBILITY , |
||
InstrumentationNode::visibility_t | stat_vis_detailed = InstrumentationNode::VIS_HIDDEN , |
||
InstrumentationNode::visibility_t | stat_vis_max = InstrumentationNode::AUTO_VISIBILITY , |
||
InstrumentationNode::visibility_t | stat_vis_avg = InstrumentationNode::AUTO_VISIBILITY |
||
) |
Construct a CircularBuffer.
name | The name of the CircularBuffer |
max_size | The number of entries this CircularBuffer can hold before wrapping |
clk | The clock this CircularBuffer is associated with – used for CycleCounter |
statset | Pointer to the counter set to register utilization counts; default nullptr. This works for timed and untimed. |
stat_vis_general | Sets the visibility of the stat counters for the 0th and last index of the utilization counts, so the empty and full counts. |
stat_vis_detailed | Sets the visibility of the stat counts between 0 and the last index. i.e. more detailed than the general stats, default VIS_HIDDEN |
stat_vis_max | Sets the visibility for a stat that contains the maximum utilization for this buffer. The default is AUTO_VISIBILITY. |
stat_vis_avg | Sets the visibility for a stat that contains the weighted utilization average for this buffer. The default is AUTO_VISIBILITY. |
Definition at line 797 of file CircularBuffer.hpp.
|
inline |
Get the iterator pointing to the oldest entry of CircularBuffer.
Definition at line 602 of file CircularBuffer.hpp.
|
inline |
Get the iterator pointing to the oldest entry of CircularBuffer.
Definition at line 625 of file CircularBuffer.hpp.
|
inline |
Return the fixed size of this CircularBuffer.
Definition at line 469 of file CircularBuffer.hpp.
|
inline |
Empty the contents of the CircularBuffer.
Definition at line 588 of file CircularBuffer.hpp.
|
inline |
Request that this queue begin collecting its contents for pipeline collection.
parent | A pointer to the parent treenode for which to add Collectable objects under. |
Definition at line 444 of file CircularBuffer.hpp.
|
inline |
Returns an iterator referring to past-the-end of the newest element in the CircularBuffer.
Definition at line 615 of file CircularBuffer.hpp.
|
inline |
Returns an iterator referring to past-the-end of the newest element in the CircularBuffer.
Definition at line 638 of file CircularBuffer.hpp.
|
inline |
erase the index at which the entry exists in the CircularBuffer.
entry | a reference to the entry to be erased. |
Definition at line 563 of file CircularBuffer.hpp.
|
inline |
erase the index at which the entry exists in the CircularBuffer.
entry | a reference to the entry to be erased. |
Definition at line 574 of file CircularBuffer.hpp.
|
inline |
Definition at line 580 of file CircularBuffer.hpp.
|
inline |
Get this CircularBuffer's name.
Definition at line 451 of file CircularBuffer.hpp.
|
inline |
Insert the given data before the given iterator.
entry | The interator to insert the data before |
dat | The data to insert |
Definition at line 544 of file CircularBuffer.hpp.
|
inline |
Insert the given data before the given iterator.
entry | The interator to insert the data before |
dat | The data to insert |
Definition at line 554 of file CircularBuffer.hpp.
|
inline |
Insert the given data before the given iterator.
entry | The interator to insert the data before |
dat | The data to insert |
Definition at line 524 of file CircularBuffer.hpp.
|
inline |
Insert the given data before the given iterator.
entry | The interator to insert the data before |
dat | The data to insert |
Definition at line 534 of file CircularBuffer.hpp.
|
inline |
Determine if data at the index is valid.
idx | The index to determine validity |
Definition at line 461 of file CircularBuffer.hpp.
|
inline |
Return the number of free entries.
Does not take into account the number of erased entries this cycle
Definition at line 487 of file CircularBuffer.hpp.
|
inline |
Returns the data at the given index. Will assert if out of range.
Definition at line 681 of file CircularBuffer.hpp.
|
inline |
Append data to the end of CircularBuffer, and return a CircularBufferIterator.
dat | Data to be pushed back into the CircularBuffer |
Append data to the end of CircularBuffer, and return a CircularBufferIterator for the location appeneded. Untimed CircularBuffers will have the data become valid immediately.
Definition at line 500 of file CircularBuffer.hpp.
|
inline |
Append data to the end of CircularBuffer, and return a CircularBufferIterator.
dat | Data to be pushed back into the CircularBuffer |
Append data to the end of CircularBuffer, and return a CircularBufferIterator for the location appeneded. Untimed CircularBuffers will have the data become valid immediately.
Definition at line 514 of file CircularBuffer.hpp.
|
inline |
Get the iterator pointing to the oldest entry of CircularBuffer.
Definition at line 648 of file CircularBuffer.hpp.
|
inline |
Get the iterator pointing to the oldest entry of CircularBuffer.
Definition at line 664 of file CircularBuffer.hpp.
|
inline |
Returns an iterator referring to past-the-end of the newest element in the CircularBuffer.
Definition at line 656 of file CircularBuffer.hpp.
|
inline |
Returns an iterator referring to past-the-end of the newest element in the CircularBuffer.
Definition at line 672 of file CircularBuffer.hpp.
|
inline |
Return the number of valid entries.
Definition at line 477 of file CircularBuffer.hpp.