|
fiber
|
An overflow aware integer type for hardware timer/counter that are used as clocks. More...
#include <Tick.hpp>
Public Types | |
| using | rep = UInt |
Public Member Functions | |
| constexpr | Tick ()=default |
| constexpr | Tick (const Tick &)=default |
| constexpr Tick & | operator= (const Tick &)=default |
| template<class T> requires (!is_clocktick<T> && std::is_unsigned_v<T>) | |
| constexpr | Tick (const T v) |
Safely constructs a Tick from the input value, so that the value wraps around after the MAX_TICK. | |
| template<class T> requires (!is_clocktick<T> && std::is_signed_v<T>) | |
| constexpr | Tick (const T v) |
| template<std::integral T> | |
| constexpr Tick & | operator= (const T v) |
| void | operator+= (const Tick other) |
| void | operator-= (const Tick other) |
| void | operator*= (const Tick other) |
| void | operator/= (const Tick other) |
| void | operator%= (const Tick other) |
| template<std::integral Int> | |
| constexpr | operator Int () const |
Static Public Member Functions | |
| static constexpr Tick< UInt, MAX_TICK > | reinterpret (UInt v) |
| Reinterprets the integer value into the clock tick. this assumes that the passed value is smaller or equal than the overflow value. | |
Public Attributes | |
| UInt | value = UInt(0) |
Static Public Attributes | |
| static constexpr UInt | max_tick = MAX_TICK |
| static constexpr UInt | modulo = static_cast<UInt>(max_tick + static_cast<UInt>(1)) |
| static constexpr bool | modulo_is_power_of_two = (max_tick & modulo) == static_cast<UInt>(0) |
| static constexpr bool | max_tick_is_limit = std::numeric_limits<UInt>::max() == max_tick |
Friends | |
| constexpr Tick | operator+ (const Tick lhs, const Tick rhs) |
addition that wrapps around MAX_TICKS | |
| constexpr Tick | operator- (Tick lhs, Tick rhs) |
subtraction that wrapps around MAX_TICKS | |
| constexpr Tick | operator+ (const Tick v) |
| unary + operator is just the identity function | |
| constexpr Tick | operator- (const Tick v) |
negation that wrapps around MAX_TICKS | |
| constexpr Tick | operator* (const Tick lhs, const Tick rhs) |
multiplication that wrapps around MAX_TICKS | |
| constexpr Tick | operator/ (const Tick lhs, const Tick rhs) |
division that wrapps around MAX_TICKS | |
| constexpr Tick | operator% (const Tick lhs, const Tick rhs) |
remainder/modulo opteration thta wraps around MAX_TICKS | |
| constexpr bool | operator== (const Tick lhs, const Tick rhs) |
| constexpr bool | operator!= (const Tick lhs, const Tick rhs) |
| constexpr bool | operator<= (const Tick lhs, const Tick rhs) |
| constexpr bool | operator>= (const Tick lhs, const Tick rhs) |
| constexpr bool | operator< (const Tick lhs, const Tick rhs) |
| constexpr bool | operator> (const Tick lhs, const Tick rhs) |
| OStream & | operator<< (OStream &stream, const Tick tick) |
An overflow aware integer type for hardware timer/counter that are used as clocks.
An overflow aware tick class template to simulate the behaviour of hardware timers in microcontrollers for use in Duration and TimePoint types.
<, <=, >= and > comparisons at and around the overflow point.+, -, *, / and % operations at and around the overflow point.Note: The maximum comparison range is half the
MAX_TICKrange
| UInt | An unsigned integer type |
| MAX_TICK | The maximum tick just before the overflow |
| UInt | The underlieing integer type |
| MAX_TICK | The largest/last value before the overflow. |
| using fiber::Tick< UInt, MAX_TICK >::rep = UInt |
|
constexprdefault |
|
constexprdefault |
|
inlineconstexpr |
Safely constructs a Tick from the input value, so that the value wraps around after the MAX_TICK.
T is fully representable within MAX_TICK: compile to a simple assignment.MAX_TICK + 1 is a power of two: compiles to an bitwise-and in addition to the assignment.T is fully representable within 2 * MAX_TICK: compiles to a conditional subtraction.| T | Generic unsigned integer type |
| v | unsigned integer value |
|
inlineconstexpr |
|
inlineexplicitconstexpr |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineconstexpr |
|
constexprdefault |
|
inlinestaticconstexpr |
Reinterprets the integer value into the clock tick. this assumes that the passed value is smaller or equal than the overflow value.
| v | an integer |
| If | full assertions are enabled, throws if the passed value is larger than the modulo |
|
friend |
|
friend |
remainder/modulo opteration thta wraps around MAX_TICKS
|
friend |
multiplication that wrapps around MAX_TICKS
Supports compile time optimisations
MAX_TICKS is the largest representable number (aka. natural overflow)MAX_TICKS + 1 is a power of two: multiplication and bitwise addition.
|
friend |
addition that wrapps around MAX_TICKS
Supports compile time optimisations
MAX_TICKS is the largest representable number (aka. natural overflow)MAX_TICKS + 1 is a power of two
|
friend |
unary + operator is just the identity function
|
friend |
negation that wrapps around MAX_TICKS
Supports compile time optimisations
MAX_TICKS is the largest representable number (aka. natural overflow)
|
friend |
subtraction that wrapps around MAX_TICKS
Supports compile time optimisations
MAX_TICKS is the largest representable number (aka. natural overflow)
|
friend |
division that wrapps around MAX_TICKS
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
| UInt fiber::Tick< UInt, MAX_TICK >::value = UInt(0) |