#include <pana_serial_num.h>
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 |
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 Definition at line 75 of file pana_serial_num.h. References m_SerialNum.
00075 : m_SerialNum(seed) { } |
|
ISN generator
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 } |
|
increments current serial number value by serial number class
Definition at line 108 of file pana_serial_num.h. References value().
00108 { 00109 return ((*this) + num.value()); 00110 } |
|
increments current serial number value by 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 } |
|
Single value incrementor Definition at line 115 of file pana_serial_num.h.
00115 {
00116 return ((*this) + 1);
00117 }
|
|
Less than comparison against serial number class
Definition at line 211 of file pana_serial_num.h. References value().
00211 { 00212 return ((*this) < num.value()); 00213 } |
|
Less than comparison against ordinal value
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 } |
|
Equality against serial number class
Definition at line 192 of file pana_serial_num.h. References value().
00192 { 00193 return ((*this) == num.value()); 00194 } |
|
Equality against ordinal value
Definition at line 183 of file pana_serial_num.h. References m_SerialNum.
00183 { 00184 return (m_SerialNum == num); 00185 } |
|
Greater than comparison against serial number class
Definition at line 230 of file pana_serial_num.h. References value().
00230 { 00231 return ((*this) > num.value()); 00232 } |
|
Greater than comparison against ordinal value
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 } |
|
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; } |
|
serial number value Definition at line 256 of file pana_serial_num.h. Referenced by operator+(), operator<(), operator==(), operator>(), PANA_SerialNumber(), and value(). |