41 #ifndef __BASE_SAT_COUNTER_HH__ 42 #define __BASE_SAT_COUNTER_HH__ 74 "Number of bits exceeds counter size");
76 "Saturating counter's Initial value exceeds max value.");
107 if (
this != &other) {
264 #endif // __BASE_SAT_COUNTER_HH__
SatCounter & operator+=(const int &value)
Add-assignment.
double calcSaturation() const
Calculate saturation percentile of the current counter's value with regard to its maximum possible va...
SatCounter & operator-=(const int &value)
Subtract-assignment.
SatCounter(unsigned bits, uint8_t initial_val=0)
Constructor for the counter.
SatCounter & operator++()
Pre-increment operator.
SatCounter & operator--()
Pre-decrement operator.
Implements an n bit saturating counter and provides methods to increment, decrement, and read it.
SatCounter operator--(int)
Post-decrement operator.
void reset()
Reset the counter to its initial value.
#define fatal_if(cond,...)
Conditional fatal macro that checks the supplied condition and only causes a fatal error if the condi...
SatCounter & operator=(SatCounter &&other)
Move assignment.
Defines global host-dependent types: Counter, Tick, and (indirectly) {int,uint}{8,16,32,64}_t.
SatCounter operator++(int)
Post-increment operator.
uint8_t saturate()
Saturate the counter.
bool isSaturated() const
Whether the counter has achieved its maximum value or not.
void swap(SatCounter &other)
Swap the contents of every member of the class.
SatCounter(const SatCounter &other)
Copy constructor.
SatCounter(SatCounter &&other)
Move constructor.
SatCounter & operator<<=(const int &shift)
Shift-left-assignment.
SatCounter & operator=(const SatCounter &other)
Copy assignment.
SatCounter & operator>>=(const int &shift)
Shift-right-assignment.
SatCounter()=delete
The default constructor should never be used.
T bits(T val, int first, int last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it...