Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

PANA_SerialNumber Class Reference

#include <pana_serial_num.h>

List of all members.

Public Member Functions

 PANA_SerialNumber (ACE_UINT32 seed=0)
ACE_UINT32 operator+ (ACE_UINT32 num)
ACE_UINT32 operator+ (PANA_SerialNumber &num)
ACE_UINT32 operator++ ()
ACE_UINT32 operator== (ACE_UINT32 num)
ACE_UINT32 operator== (PANA_SerialNumber &num)
ACE_UINT32 operator< (ACE_UINT32 num)
ACE_UINT32 operator< (PANA_SerialNumber &num)
ACE_UINT32 operator> (ACE_UINT32 num)
ACE_UINT32 operator> (PANA_SerialNumber &num)
ACE_UINT32 value ()

Static Public Member Functions

ACE_UINT32 generateIsn (ACE_UINT32 seed=0)

Protected Attributes

ACE_UINT32 m_SerialNum


Detailed Description

Serial number implementation as defined in RFC1982

2. Serial Number Arithmetic

Serial numbers are formed from non-negative integers from a finite subset of the range of all integer values. The lowest integer in every subset used for this purpose is zero, the maximum is always one less than a power of two.

When considered as serial numbers however no value has any particular significance, there is no minimum or maximum serial number, every value has a successor and predecessor.

To define a serial number to be used in this way, the size of the serial number space must be given. This value, called "SERIAL_BITS", gives the power of two which results in one larger than the largest integer corresponding to a serial number value. This also specifies the number of bits required to hold every possible value of a serial number of the defined type. The operations permitted upon serial numbers are defined in the following section.

3. Operations upon the serial number

Only two operations are defined upon serial numbers, addition of a positive integer of limited range, and comparison with another serial number.

Definition at line 69 of file pana_serial_num.h.


Constructor & Destructor Documentation

PANA_SerialNumber::PANA_SerialNumber ACE_UINT32  seed = 0  )  [inline]
 

constructor

Definition at line 75 of file pana_serial_num.h.

References m_SerialNum.

00075 : m_SerialNum(seed) { }


Member Function Documentation

ACE_UINT32 PANA_SerialNumber::generateIsn ACE_UINT32  seed = 0  )  [inline, static]
 

ISN generator

Parameters:
seed Seed value

Definition at line 244 of file pana_serial_num.h.

00244                                                                    {
00245             if (seed == 0) {
00246                 ACE_System_Time::get_local_system_time(seed);
00247             }
00248 
00249             // simple time seeded randon number generator
00250             ACE_OS::srand(seed);
00251             return ACE_OS::rand();
00252         }

ACE_UINT32 PANA_SerialNumber::operator+ PANA_SerialNumber num  )  [inline]
 

increments current serial number value by serial number class

Parameters:
num Serial number class

Definition at line 108 of file pana_serial_num.h.

References value().

00108                                                      { 
00109             return ((*this) + num.value()); 
00110         }

ACE_UINT32 PANA_SerialNumber::operator+ ACE_UINT32  num  )  [inline]
 

increments current serial number value by ordinal number

Parameters:
num Ordinal number

Definition at line 99 of file pana_serial_num.h.

References m_SerialNum.

00099                                              {
00100            return (m_SerialNum = (m_SerialNum + num) % (2 ^ sizeof(ACE_UINT32)));
00101         }

ACE_UINT32 PANA_SerialNumber::operator++  )  [inline]
 

Single value incrementor

Definition at line 115 of file pana_serial_num.h.

00115                                 { 
00116             return ((*this) + 1); 
00117         }

ACE_UINT32 PANA_SerialNumber::operator< PANA_SerialNumber num  )  [inline]
 

Less than comparison against serial number class

Parameters:
num serial number class

Definition at line 211 of file pana_serial_num.h.

References value().

00211                                                      { 
00212             return ((*this) < num.value()); 
00213         }

ACE_UINT32 PANA_SerialNumber::operator< ACE_UINT32  num  )  [inline]
 

Less than comparison against ordinal value

Parameters:
num ordinal number

Definition at line 201 of file pana_serial_num.h.

References m_SerialNum.

00201                                              {            
00202             return (((m_SerialNum < num) && ((num - m_SerialNum) < (2^(sizeof(ACE_UINT32) - 1)))) || 
00203                     ((m_SerialNum > num) && ((m_SerialNum - num) > (2^(sizeof(ACE_UINT32) - 1)))));
00204         }

ACE_UINT32 PANA_SerialNumber::operator== PANA_SerialNumber num  )  [inline]
 

Equality against serial number class

Parameters:
num serial number class

Definition at line 192 of file pana_serial_num.h.

References value().

00192                                                       { 
00193            return ((*this) == num.value()); 
00194         }

ACE_UINT32 PANA_SerialNumber::operator== ACE_UINT32  num  )  [inline]
 

Equality against ordinal value

Parameters:
num ordinal number

Definition at line 183 of file pana_serial_num.h.

References m_SerialNum.

00183                                               {
00184            return (m_SerialNum == num);
00185         }

ACE_UINT32 PANA_SerialNumber::operator> PANA_SerialNumber num  )  [inline]
 

Greater than comparison against serial number class

Parameters:
num serial number class

Definition at line 230 of file pana_serial_num.h.

References value().

00230                                                      { 
00231             return ((*this) > num.value()); 
00232         }

ACE_UINT32 PANA_SerialNumber::operator> ACE_UINT32  num  )  [inline]
 

Greater than comparison against ordinal value

Parameters:
num ordinal number

Definition at line 220 of file pana_serial_num.h.

References m_SerialNum.

00220                                              {
00221             return (((m_SerialNum < num) && ( (num - m_SerialNum) > (2^(sizeof(ACE_UINT32) - 1)))) ||
00222                     ((m_SerialNum > num) && ((m_SerialNum - num) < (2^(sizeof(ACE_UINT32) - 1)))));
00223         }

ACE_UINT32 PANA_SerialNumber::value  )  [inline]
 

Access method to serial number value

Definition at line 237 of file pana_serial_num.h.

References m_SerialNum.

Referenced by operator+(), operator<(), operator==(), and operator>().

00237 { return m_SerialNum; }


Member Data Documentation

ACE_UINT32 PANA_SerialNumber::m_SerialNum [protected]
 

serial number value

Definition at line 256 of file pana_serial_num.h.

Referenced by operator+(), operator<(), operator==(), operator>(), PANA_SerialNumber(), and value().


The documentation for this class was generated from the following file:
Generated on Fri Jun 25 19:18:31 2004 for PANA by doxygen 1.3.5