51 template<
typename NUMERIC_TYPE,
typename SIGNED_TYPE>
99 operator NUMERIC_TYPE ()
const
215 static const NUMERIC_TYPE maxValue = std::numeric_limits<NUMERIC_TYPE>::max ();
216 static const NUMERIC_TYPE halfMaxValue = std::numeric_limits<NUMERIC_TYPE>::max () / 2;
220 if (diff < halfMaxValue)
222 return static_cast<SIGNED_TYPE
> (diff);
230 return -(
static_cast<SIGNED_TYPE
> (maxValue -
m_value + 1 + other.
m_value));
236 if (diff < halfMaxValue)
242 return -(
static_cast<SIGNED_TYPE
> (diff));
250 return static_cast<SIGNED_TYPE
> (maxValue - other.
m_value + 1 +
m_value);
269 static const NUMERIC_TYPE halfMaxValue = std::numeric_limits<NUMERIC_TYPE>::max () / 2;
300 bool operator <= (const SequenceNumber<NUMERIC_TYPE, SIGNED_TYPE> &other)
const
302 return (!this->
operator> (other));
312 return (this->
operator> (other) || this->
operator== (other));
320 bool operator < (const SequenceNumber<NUMERIC_TYPE, SIGNED_TYPE> &other)
const
331 template<
typename NUMERIC_TYPE2,
typename SIGNED_TYPE2>
332 friend std::ostream & operator<< (std::ostream& os, const SequenceNumber<NUMERIC_TYPE2, SIGNED_TYPE2> &val);
340 template<
typename NUMERIC_TYPE2,
typename SIGNED_TYPE2>
365 template<
typename NUMERIC_TYPE,
typename SIGNED_TYPE>
367 operator<< (std::ostream& os, const SequenceNumber<NUMERIC_TYPE, SIGNED_TYPE> &val)
373 template<
typename NUMERIC_TYPE,
typename SIGNED_TYPE>
bool operator!=(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
Inequality operator for comparing sequence numbers.
std::istream & operator>>(std::istream &is, Angles &a)
initialize a struct Angles from input
NUMERIC_TYPE GetValue() const
Extracts the numeric value of the sequence number.
bool operator&&(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &b) const
bool operator||(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &b) const
bool operator==(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
Equality operator for comparing sequence number.
bool operator>(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
Here is the critical part, how the comparison is made taking into account wrap-around.
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator/(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &b) const
SequenceNumber< uint32_t, int32_t > SequenceNumber32
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator&(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &b) const
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator^(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &b) const
bool operator>=(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
Greater than or equal operator for comparing sequence numbers.
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator+(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
Operator defining addition of two sequence numbers.
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > & operator=(NUMERIC_TYPE value)
Constructs a SequenceNumber from an assignment of given value.
SequenceNumber(SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > const &value)
Constructs a SequenceNumber from a copy.
Generic "sequence number" class.
SequenceNumber< uint16_t, int16_t > SequenceNumber16
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > & operator+=(SIGNED_TYPE value)
Plus equals operator.
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator|(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &b) const
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator%(const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &b) const
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator++()
Prefix increment operator.
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator~() const
friend std::istream & operator>>(std::istream &is, const SequenceNumber< NUMERIC_TYPE2, SIGNED_TYPE2 > &val)
For loading sequence number from input streams.
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator--()
Prefix decrement operator.
SequenceNumber(NUMERIC_TYPE value)
Constructs a SequenceNumber with the given value.
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > & operator-=(SIGNED_TYPE value)
Minus equals operator.
SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > operator-(SIGNED_TYPE delta) const
Subtraction operator for subtracting numeric value from sequence number.