ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TUUID Class Reference

This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDentifier).

A UUID is 128 bits long, and if generated according to this algorithm, is either guaranteed to be different from all other UUIDs/GUIDs generated until 3400 A.D. or extremely likely to be different. UUIDs were originally used in the Network Computing System (NCS) and later in the Open Software Foundation's (OSF) Distributed Computing Environment (DCE).

Structure of universal unique IDs (UUIDs).

Depending on the network data representation, the multi- octet unsigned integer fields are subject to byte swapping when communicated between dissimilar endian machines.

+-----------------------------------+
| low 32 bits of time | 0-3 .fTimeLow
+-------------------------------+----
| mid 16 bits of time | 4-5 .fTimeMid
+-------+-----------------------+
| vers. | hi 12 bits of time | 6-7 .fTimeHiAndVersion
+-------+-------+---------------+
|Res | clkSeqHi | 8 .fClockSeqHiAndReserved
+---------------+
| clkSeqLow | 9 .fClockSeqLow
+---------------+------------------+
| node ID | 10-15 .fNode
+----------------------------------+

The adjusted time stamp is split into three fields, and the clockSeq is split into two fields.

The timestamp is a 60-bit value. For UUID version 1, this is represented by Coordinated Universal Time (UTC/GMT) as a count of 100-nanosecond intervals since 00:00:00.00, 15 October 1582 (the date of Gregorian reform to the Christian calendar).

The version number is multiplexed in the 4 most significant bits of the 'fTimeHiAndVersion' field. There are two defined versions:

MSB <---
Version 4-Bit Code Description
------------------------------------------------------------
| 1 0 0 0 1 DCE version, as specified herein.
| 2 0 0 1 0 DCE Security version, with
| embedded POSIX UIDs.
| 3 0 0 1 1 node id is a random value
------------------------------------------------------------

Clock Sequence

The clock sequence value must be changed whenever:

The UUID generator detects that the local value of UTC has gone backward; this may be due to re-syncing of the system clock.

While a node is operational, the UUID service always saves the last UTC used to create a UUID. Each time a new UUID is created, the current UTC is compared to the saved value and if either the current value is less or the saved value was lost, then the clock sequence is incremented modulo 16,384, thus avoiding production of duplicated UUIDs.

The clock sequence must be initialized to a random number to minimize the correlation across system. This provides maximum protection against node identifiers that may move or switch from system to system rapidly.

Clock Adjustment

UUIDs may be created at a rate greater than the system clock resolution. Therefore, the system must also maintain an adjustment value to be added to the lower-order bits of the time. Logically, each time the system clock ticks, the adjustment value is cleared. Every time a UUID is generated, the current adjustment value is read and incremented, and then added to the UTC time field of the UUID.

Clock Overrun

The 100-nanosecond granularity of time should prove sufficient even for bursts of UUID production in the next generation of high-performance multiprocessors. If a system overruns the clock adjustment by requesting too many UUIDs within a single system clock tick, the UUID generator will stall until the system clock catches up.

Definition at line 44 of file TUUID.h.

Classes

struct  uuid_time_t
 

Public Member Functions

 TUUID ()
 
 TUUID (const char *uuid_str)
 Initialize a TUUID with uuid (which must be in TUUID::AsString() format). More...
 
virtual ~TUUID ()
 delete this TUUID More...
 
const char * AsString () const
 Return UUID as string. Copy string immediately since it will be reused. More...
 
Int_t Compare (const TUUID &u) const
 Compare two UUIDs "lexically" and return. More...
 
UShort_t Hash () const
 Compute 16-bit hash value of the UUID. More...
 
void Print () const
 Print UUID. More...
 
TInetAddress GetHostAddress () const
 Get address of host encoded in UUID. More...
 
TDatime GetTime () const
 Get time from UUID. More...
 
void GetUUID (UChar_t uuid[16]) const
 Return uuid in specified buffer (16 byte = 128 bits). More...
 
void SetUUID (const char *uuid_str)
 Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format). More...
 
UInt_t GetUUIDNumber () const
 
void SetUUIDNumber (UInt_t index)
 
void StreamerV1 (TBuffer &b)
 Stream UUID from input buffer. More...
 
void FillBuffer (char *&buffer)
 Stream UUID into output buffer. More...
 
void ReadBuffer (char *&buffer)
 Stream UUID from input buffer. More...
 
Int_t Sizeof () const
 

Protected Member Functions

Int_t CmpTime (uuid_time_t *t1, uuid_time_t *t2)
 Compare two time values. More...
 
void Format (UShort_t clockseq, uuid_time_t ts)
 Make a UUID from timestamp, clockseq and node id. More...
 
void GetNodeIdentifier ()
 Get node identifier. More...
 
void GetCurrentTime (uuid_time_t *timestamp)
 Get current time as 60 bit 100ns ticks since whenever. More...
 
void GetSystemTime (uuid_time_t *timestamp)
 Get system time with 100ns precision. Time is since Oct 15, 1582. More...
 
void GetRandomInfo (UChar_t seed[16])
 Get random info based on some machine parameters. More...
 
void SetFromString (const char *uuid_str)
 Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format). More...
 

Protected Attributes

UInt_t fUUIDIndex
 
UInt_t fTimeLow
 index in the list of UUIDs in TProcessUUID More...
 
UShort_t fTimeMid
 
UShort_t fTimeHiAndVersion
 
UChar_t fClockSeqHiAndReserved
 
UChar_t fClockSeqLow
 
UChar_t fNode [6]
 

#include <TUUID.h>

Constructor & Destructor Documentation

TUUID::TUUID ( )
TUUID::TUUID ( const char *  uuid_str)

Initialize a TUUID with uuid (which must be in TUUID::AsString() format).

Definition at line 246 of file TUUID.cxx.

TUUID::~TUUID ( )
virtual

delete this TUUID

Definition at line 188 of file TUUID.cxx.

Member Function Documentation

const char * TUUID::AsString ( ) const
Int_t TUUID::CmpTime ( uuid_time_t t1,
uuid_time_t t2 
)
protected

Compare two time values.

Definition at line 196 of file TUUID.cxx.

Referenced by GetCurrentTime().

Int_t TUUID::Compare ( const TUUID u) const

Compare two UUIDs "lexically" and return.

  • -1 this is lexically before u
  • 0 this is equal to u
  • 1 this is lexically after u

Definition at line 601 of file TUUID.cxx.

Referenced by operator==().

void TUUID::FillBuffer ( char *&  buffer)

Stream UUID into output buffer.

Definition at line 265 of file TUUID.cxx.

Referenced by TDirectoryFile::FillBuffer(), and TFile::WriteHeader().

void TUUID::Format ( UShort_t  clockseq,
uuid_time_t  ts 
)
protected

Make a UUID from timestamp, clockseq and node id.

Definition at line 314 of file TUUID.cxx.

void TUUID::GetCurrentTime ( uuid_time_t timestamp)
protected

Get current time as 60 bit 100ns ticks since whenever.

Compensate for the fact that real clock resolution is less than 100ns.

Definition at line 331 of file TUUID.cxx.

TInetAddress TUUID::GetHostAddress ( ) const

Get address of host encoded in UUID.

If host id is not an ethernet address, but random info, then the returned TInetAddress is not valid.

Definition at line 622 of file TUUID.cxx.

void TUUID::GetNodeIdentifier ( )
protected

Get node identifier.

Try first to get network address, if no network interface try random info based on some machine parameters.

Definition at line 416 of file TUUID.cxx.

Referenced by Format().

void TUUID::GetRandomInfo ( UChar_t  seed[16])
protected

Get random info based on some machine parameters.

Definition at line 476 of file TUUID.cxx.

Referenced by GetNodeIdentifier().

void TUUID::GetSystemTime ( uuid_time_t timestamp)
protected

Get system time with 100ns precision. Time is since Oct 15, 1582.

Definition at line 383 of file TUUID.cxx.

Referenced by GetCurrentTime().

TDatime TUUID::GetTime ( ) const

Get time from UUID.

Definition at line 635 of file TUUID.cxx.

void TUUID::GetUUID ( UChar_t  uuid[16]) const

Return uuid in specified buffer (16 byte = 128 bits).

Definition at line 660 of file TUUID.cxx.

Referenced by TRandom2::SetSeed(), and TRandom::SetSeed().

UInt_t TUUID::GetUUIDNumber ( ) const
inline

Definition at line 81 of file TUUID.h.

UShort_t TUUID::Hash ( ) const

Compute 16-bit hash value of the UUID.

Definition at line 551 of file TUUID.cxx.

void TUUID::Print ( ) const

Print UUID.

Definition at line 528 of file TUUID.cxx.

void TUUID::ReadBuffer ( char *&  buffer)

Stream UUID from input buffer.

Definition at line 281 of file TUUID.cxx.

Referenced by TFile::Init().

void TUUID::SetFromString ( const char *  uuid)
protected

Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).

Definition at line 209 of file TUUID.cxx.

Referenced by SetUUID(), and TUUID().

void TUUID::SetUUID ( const char *  uuid)

Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).

Definition at line 669 of file TUUID.cxx.

void TUUID::SetUUIDNumber ( UInt_t  index)
inline

Definition at line 82 of file TUUID.h.

Referenced by TProcessUUID::AddUUID().

Int_t TUUID::Sizeof ( ) const
inline

Definition at line 87 of file TUUID.h.

Referenced by TDirectoryFile::Sizeof().

void TUUID::StreamerV1 ( TBuffer b)

Stream UUID from input buffer.

This function is for the exclusive use of TDirectory::Streamer() to read a non-versioned version of TUUID.

Definition at line 299 of file TUUID.cxx.

Member Data Documentation

UChar_t TUUID::fClockSeqHiAndReserved
protected

Definition at line 51 of file TUUID.h.

Referenced by AsString(), Compare(), FillBuffer(), Format(), ReadBuffer(), SetFromString(), StreamerV1(), and TUUID().

UChar_t TUUID::fClockSeqLow
protected

Definition at line 52 of file TUUID.h.

Referenced by AsString(), Compare(), FillBuffer(), Format(), ReadBuffer(), SetFromString(), StreamerV1(), and TUUID().

UChar_t TUUID::fNode[6]
protected
UShort_t TUUID::fTimeHiAndVersion
protected
UInt_t TUUID::fTimeLow
protected

index in the list of UUIDs in TProcessUUID

Definition at line 48 of file TUUID.h.

Referenced by AsString(), Compare(), FillBuffer(), Format(), GetTime(), GetUUID(), Hash(), ReadBuffer(), SetFromString(), StreamerV1(), and TUUID().

UShort_t TUUID::fTimeMid
protected
UInt_t TUUID::fUUIDIndex
protected

Definition at line 47 of file TUUID.h.

Referenced by GetUUIDNumber(), SetFromString(), SetUUIDNumber(), and TUUID().


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