|
RAVENNAKIT
|
Represents sequence numbers with rollover (wraparound) semantics. More...
#include <wrapping_uint.hpp>
Public Member Functions | |
| WrappingUint ()=default | |
| Default construct a sequence number with the value 0. | |
| WrappingUint (const T value) | |
| Construct a sequence number with the given value. | |
| std::optional< T > | update (const T value) |
| Updates the value in the sequence. | |
| operator T () const | |
| T | value () const |
| WrappingUint & | operator= (const T value) |
| Assigns a new value to the sequence number. | |
| WrappingUint & | operator+= (const T value) |
| Increments the sequence number by 1 using modulo arithmetic. | |
| WrappingUint & | operator-= (const T value) |
| Decrements the sequence number by 1 using modulo arithmetic. | |
| WrappingUint | operator+ (const T value) const |
| Increments the sequence number by the given value. | |
| WrappingUint | operator- (const T value) const |
| Decrements the sequence number by the given value. | |
| bool | operator== (T other) |
| Compares the sequence number with the given value. | |
| bool | operator!= (T other) |
| Compares the sequence number with the given value. | |
| std::make_signed_t< T > | diff (const WrappingUint &other) const |
| Calculates the difference between two sequence numbers, taking into account wraparound. | |
| std::make_signed_t< T > | diff (T other) const |
| Calculates the difference between two sequence numbers, taking into account wraparound. | |
Friends | |
| bool | operator== (const WrappingUint &lhs, const WrappingUint &rhs) |
| Compares the sequence number with the given value. | |
| bool | operator!= (const WrappingUint &lhs, const WrappingUint &rhs) |
| Compares the sequence number with the given value. | |
| bool | operator< (const WrappingUint &lhs, const WrappingUint &rhs) |
| Compares the sequence number with the given value. | |
| bool | operator<= (const WrappingUint &lhs, const WrappingUint &rhs) |
| Compares the sequence number with the given value. | |
| bool | operator> (const WrappingUint &lhs, const WrappingUint &rhs) |
| Compares the sequence number with the given value. | |
| bool | operator>= (const WrappingUint &lhs, const WrappingUint &rhs) |
| Compares the sequence number with the given value. | |
Represents sequence numbers with rollover (wraparound) semantics.
This class is designed to work with any unsigned integer type that wraps around to 0 after reaching its maximum value. It also supports handling gaps, making it suitable for scenarios involving packet loss. Use this class for the sequence id in PTP, sequence number in RTP, timestamp in RTP, etc.
Definition at line 41 of file wrapping_uint.hpp.
|
default |
Default construct a sequence number with the value 0.
|
inlineexplicit |
Construct a sequence number with the given value.
| value | The initial value of the sequence number. |
Definition at line 55 of file wrapping_uint.hpp.
|
inlinenodiscard |
Calculates the difference between two sequence numbers, taking into account wraparound.
The value will be positive if the other sequence number is newer than this one, and negative if this one is newer.
| other | The other sequence number. |
Definition at line 224 of file wrapping_uint.hpp.
|
inlinenodiscard |
Calculates the difference between two sequence numbers, taking into account wraparound.
The value will be positive if the other sequence number is newer than this one, and negative if this one is newer.
| other | The other sequence number. |
Definition at line 235 of file wrapping_uint.hpp.
|
inlineexplicitnodiscard |
Definition at line 80 of file wrapping_uint.hpp.
|
inlinenodiscard |
Compares the sequence number with the given value.
| other | The value to compare with. |
Definition at line 153 of file wrapping_uint.hpp.
|
inlinenodiscard |
Increments the sequence number by the given value.
| value | The value to increment by. |
Definition at line 126 of file wrapping_uint.hpp.
|
inline |
Increments the sequence number by 1 using modulo arithmetic.
| value | The value to increment by. |
Definition at line 106 of file wrapping_uint.hpp.
|
inlinenodiscard |
Decrements the sequence number by the given value.
| value | The value to decrement by. |
Definition at line 135 of file wrapping_uint.hpp.
|
inline |
Decrements the sequence number by 1 using modulo arithmetic.
| value | The value to decrement by. |
Definition at line 116 of file wrapping_uint.hpp.
|
inline |
Assigns a new value to the sequence number.
| value | The new value of the sequence number. |
Definition at line 96 of file wrapping_uint.hpp.
|
inlinenodiscard |
Compares the sequence number with the given value.
| other | The value to compare with. |
Definition at line 144 of file wrapping_uint.hpp.
|
inline |
Updates the value in the sequence.
The number of steps taken from the previous value to given value will be returned, taking into account wraparound. The current (internal) value will only progress forward, if the value is older than the current value, it will return std::nullopt. The returned value can be used to detect gaps (when value > 1).
| value | The value to set. |
Definition at line 67 of file wrapping_uint.hpp.
|
inlinenodiscard |
Definition at line 87 of file wrapping_uint.hpp.
|
friend |
Compares the sequence number with the given value.
| lhs | Left hand side. |
| rhs | Right hand side. |
Definition at line 173 of file wrapping_uint.hpp.
|
friend |
Compares the sequence number with the given value.
| lhs | Left hand side. |
| rhs | Right hand side. |
Definition at line 183 of file wrapping_uint.hpp.
|
friend |
Compares the sequence number with the given value.
| lhs | Left hand side. |
| rhs | Right hand side. |
Definition at line 193 of file wrapping_uint.hpp.
|
friend |
Compares the sequence number with the given value.
| lhs | Left hand side. |
| rhs | Right hand side. |
Definition at line 163 of file wrapping_uint.hpp.
|
friend |
Compares the sequence number with the given value.
| lhs | Left hand side. |
| rhs | Right hand side. |
Definition at line 203 of file wrapping_uint.hpp.
|
friend |
Compares the sequence number with the given value.
| lhs | Left hand side. |
| rhs | Right hand side. |
Definition at line 213 of file wrapping_uint.hpp.