Logo ROOT   6.16/01
Reference Guide
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
+----------------------------------+
float type_of_call hi(const int &, const int &)

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
------------------------------------------------------------
TString as(SEXP s)
Definition: RExports.h:71
const char * Version
auto * a
Definition: textangle.C:12

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 42 of file TUUID.h.

Classes

struct  uuid_time_t
 

Public Member Functions

 TUUID ()
 Create a UUID. More...
 
 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...
 
void FillBuffer (char *&buffer)
 Stream UUID into output buffer. 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...
 
UInt_t GetUUIDNumber () const
 
UShort_t Hash () const
 Compute 16-bit hash value of the UUID. More...
 
void Print () const
 Print UUID. More...
 
void ReadBuffer (char *&buffer)
 Stream UUID from input buffer. More...
 
void SetUUID (const char *uuid_str)
 Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format). More...
 
void SetUUIDNumber (UInt_t index)
 
Int_t Sizeof () const
 
void StreamerV1 (TBuffer &b)
 Stream UUID from input buffer. More...
 

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 GetCurrentTime (uuid_time_t *timestamp)
 Get current time as 60 bit 100ns ticks since whenever. More...
 
void GetNodeIdentifier ()
 Get node identifier. More...
 
void GetRandomInfo (UChar_t seed[16])
 Get random info based on some machine parameters. More...
 
void GetSystemTime (uuid_time_t *timestamp)
 Get system time with 100ns precision. Time is since Oct 15, 1582. 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

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

#include <TUUID.h>

Constructor & Destructor Documentation

◆ TUUID() [1/2]

TUUID::TUUID ( )

Create a UUID.

Definition at line 142 of file TUUID.cxx.

◆ TUUID() [2/2]

TUUID::TUUID ( const char *  uuid_str)

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

Definition at line 245 of file TUUID.cxx.

◆ ~TUUID()

TUUID::~TUUID ( )
virtual

delete this TUUID

Definition at line 187 of file TUUID.cxx.

Member Function Documentation

◆ AsString()

const char * TUUID::AsString ( ) const

Return UUID as string. Copy string immediately since it will be reused.

Definition at line 560 of file TUUID.cxx.

◆ CmpTime()

Int_t TUUID::CmpTime ( uuid_time_t t1,
uuid_time_t t2 
)
protected

Compare two time values.

Definition at line 195 of file TUUID.cxx.

◆ Compare()

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 625 of file TUUID.cxx.

◆ FillBuffer()

void TUUID::FillBuffer ( char *&  buffer)

Stream UUID into output buffer.

Definition at line 264 of file TUUID.cxx.

◆ Format()

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

Make a UUID from timestamp, clockseq and node id.

Definition at line 313 of file TUUID.cxx.

◆ GetCurrentTime()

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 330 of file TUUID.cxx.

◆ GetHostAddress()

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 646 of file TUUID.cxx.

◆ GetNodeIdentifier()

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 415 of file TUUID.cxx.

◆ GetRandomInfo()

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

Get random info based on some machine parameters.

Definition at line 500 of file TUUID.cxx.

◆ GetSystemTime()

void TUUID::GetSystemTime ( uuid_time_t timestamp)
protected

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

Definition at line 382 of file TUUID.cxx.

◆ GetTime()

TDatime TUUID::GetTime ( ) const

Get time from UUID.

Definition at line 659 of file TUUID.cxx.

◆ GetUUID()

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

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

Definition at line 684 of file TUUID.cxx.

◆ GetUUIDNumber()

UInt_t TUUID::GetUUIDNumber ( ) const
inline

Definition at line 79 of file TUUID.h.

◆ Hash()

UShort_t TUUID::Hash ( ) const

Compute 16-bit hash value of the UUID.

Definition at line 575 of file TUUID.cxx.

◆ Print()

void TUUID::Print ( ) const

Print UUID.

Definition at line 552 of file TUUID.cxx.

◆ ReadBuffer()

void TUUID::ReadBuffer ( char *&  buffer)

Stream UUID from input buffer.

Definition at line 280 of file TUUID.cxx.

◆ SetFromString()

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

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

Definition at line 208 of file TUUID.cxx.

◆ SetUUID()

void TUUID::SetUUID ( const char *  uuid_str)

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

Definition at line 693 of file TUUID.cxx.

◆ SetUUIDNumber()

void TUUID::SetUUIDNumber ( UInt_t  index)
inline

Definition at line 80 of file TUUID.h.

◆ Sizeof()

Int_t TUUID::Sizeof ( ) const
inline

Definition at line 85 of file TUUID.h.

◆ StreamerV1()

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 298 of file TUUID.cxx.

Member Data Documentation

◆ fClockSeqHiAndReserved

UChar_t TUUID::fClockSeqHiAndReserved
protected

Definition at line 49 of file TUUID.h.

◆ fClockSeqLow

UChar_t TUUID::fClockSeqLow
protected

Definition at line 50 of file TUUID.h.

◆ fNode

UChar_t TUUID::fNode[6]
protected

Definition at line 51 of file TUUID.h.

◆ fTimeHiAndVersion

UShort_t TUUID::fTimeHiAndVersion
protected

Definition at line 48 of file TUUID.h.

◆ fTimeLow

UInt_t TUUID::fTimeLow
protected

index in the list of UUIDs in TProcessUUID

Definition at line 46 of file TUUID.h.

◆ fTimeMid

UShort_t TUUID::fTimeMid
protected

Definition at line 47 of file TUUID.h.

◆ fUUIDIndex

UInt_t TUUID::fUUIDIndex
protected

Definition at line 45 of file TUUID.h.


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