Public Member Functions | Friends

ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > Class Template Reference

Generic "sequence number" class. More...

#include <sequence-number.h>

Collaboration diagram for ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 SequenceNumber (NUMERIC_TYPE value)
 Constructs a SequenceNumber with the given value.
 SequenceNumber (SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > const &value)
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > & 
operator= (NUMERIC_TYPE value)
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > & 
operator= (SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > const &value)
NUMERIC_TYPE GetValue () const
 Extracts the numeric value of the sequence number.
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > 
operator++ ()
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > 
operator++ (int)
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > 
operator-- ()
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > 
operator-- (int)
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > & 
operator+= (SIGNED_TYPE value)
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > & 
operator-= (SIGNED_TYPE value)
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > 
operator+ (const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > 
operator+ (SIGNED_TYPE delta) const
SequenceNumber< NUMERIC_TYPE,
SIGNED_TYPE > 
operator- (SIGNED_TYPE delta) const
SIGNED_TYPE operator- (const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
bool operator> (const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
bool operator== (const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
bool operator!= (const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
bool operator<= (const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
bool operator>= (const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const
bool operator< (const SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE > &other) const

Friends

template<typename NUMERIC_TYPE2 , typename SIGNED_TYPE2 >
std::ostream & operator<< (std::ostream &os, const SequenceNumber< NUMERIC_TYPE2, SIGNED_TYPE2 > &val)
template<typename NUMERIC_TYPE2 , typename SIGNED_TYPE2 >
std::istream & operator>> (std::istream &is, const SequenceNumber< NUMERIC_TYPE2, SIGNED_TYPE2 > &val)

Detailed Description

template<typename NUMERIC_TYPE, typename SIGNED_TYPE>
class ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >

Generic "sequence number" class.

This class can be used to handle sequence numbers. In networking protocols, sequence numbers are fixed precision integer numbers that are used to order events relative to each other. A sequence number is expected to increase over time but, since it has a limited number of bits, the number will "wrap around" from the maximum value that can represented with the given number of bits back to zero. For this reason, comparison of two sequence numbers, and subtraction, is non-trivial. The SequenceNumber class behaves like a number, with the usual arythmetic operators implemented, but knows how to correctly compare and subtract sequence numbers.

This is a templated class. To use it you need to supply two fundamental types as template parameters: NUMERIC_TYPE and SIGNED_TYPE. For instance, SequenceNumber<uint32_t, int32_t> gives you a 32-bit sequence number, while SequenceNumber<uint16_t, int16_t> is a 16-bit one. For your convenience, these are typedef'ed as SequenceNumber32 and SequenceNumber16, respectively.


Constructor & Destructor Documentation

template<typename NUMERIC_TYPE, typename SIGNED_TYPE>
ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >::SequenceNumber ( NUMERIC_TYPE  value  )  [inline, explicit]

Constructs a SequenceNumber with the given value.

Parameters:
value the sequence number value

Member Function Documentation

template<typename NUMERIC_TYPE, typename SIGNED_TYPE>
NUMERIC_TYPE ns3::SequenceNumber< NUMERIC_TYPE, SIGNED_TYPE >::GetValue (  )  const [inline]

Extracts the numeric value of the sequence number.

Returns:
the sequence number value

The documentation for this class was generated from the following file: