*
* @param bits How many bits the counter will have.
* @param initial_val Starting value for the counter.
+ *
+ * @ingroup api_sat_counter
*/
explicit SatCounter(unsigned bits, uint8_t initial_val = 0)
: initialVal(initial_val), maxVal((1 << bits) - 1),
"Saturating counter's Initial value exceeds max value.");
}
- /** Copy constructor. */
+ /**
+ * Copy constructor.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter(const SatCounter& other)
: initialVal(other.initialVal), maxVal(other.maxVal),
counter(other.counter)
{
}
- /** Copy assignment. */
+ /**
+ * Copy assignment.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter& operator=(const SatCounter& other) {
if (this != &other) {
SatCounter temp(other);
return *this;
}
- /** Move constructor. */
+ /**
+ * Move constructor.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter(SatCounter&& other)
{
initialVal = other.initialVal;
other.swap(temp);
}
- /** Move assignment. */
+ /**
+ * Move assignment.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter& operator=(SatCounter&& other) {
if (this != &other) {
initialVal = other.initialVal;
* copy-assignment created by the compiler.
*
* @param other The other object to swap contents with.
+ *
+ * @ingroup api_sat_counter
*/
void
swap(SatCounter& other)
std::swap(counter, other.counter);
}
- /** Pre-increment operator. */
+ /**
+ * Pre-increment operator.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter&
operator++()
{
return *this;
}
- /** Post-increment operator. */
+ /**
+ * Post-increment operator.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter
operator++(int)
{
return old_counter;
}
- /** Pre-decrement operator. */
+ /**
+ * Pre-decrement operator.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter&
operator--()
{
return *this;
}
- /** Post-decrement operator. */
+ /**
+ * Post-decrement operator.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter
operator--(int)
{
return old_counter;
}
- /** Shift-right-assignment. */
+ /**
+ * Shift-right-assignment.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter&
operator>>=(const int& shift)
{
return *this;
}
- /** Shift-left-assignment. */
+ /**
+ * Shift-left-assignment.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter&
operator<<=(const int& shift)
{
return *this;
}
- /** Add-assignment. */
+ /**
+ * Add-assignment.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter&
operator+=(const int& value)
{
return *this;
}
- /** Subtract-assignment. */
+ /**
+ * Subtract-assignment.
+ *
+ * @ingroup api_sat_counter
+ */
SatCounter&
operator-=(const int& value)
{
/**
* Read the counter's value.
+ *
+ * @ingroup api_sat_counter
*/
operator uint8_t() const { return counter; }
- /** Reset the counter to its initial value. */
+ /**
+ * Reset the counter to its initial value.
+ *
+ * @ingroup api_sat_counter
+ */
void reset() { counter = initialVal; }
/**
*
* @return A value between 0.0 and 1.0 to indicate which percentile of
* the maximum value the current value is.
+ *
+ * @ingroup api_sat_counter
*/
double calcSaturation() const { return (double) counter / maxVal; }
* Whether the counter has achieved its maximum value or not.
*
* @return True if the counter saturated.
+ *
+ * @ingroup api_sat_counter
*/
bool isSaturated() const { return counter == maxVal; }
* Saturate the counter.
*
* @return The value added to the counter to reach saturation.
+ *
+ * @ingroup api_sat_counter
*/
uint8_t saturate()
{