ROOT logo
ROOT » CORE » BASE » TUUID

class TUUID


TUUID

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 duplicted 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.


Function Members (Methods)

public:
TUUID()
TUUID(const char* uuid_str)
TUUID(const TUUID&)
virtual~TUUID()
const char*AsString() const
static TClass*Class()
Int_tCompare(const TUUID& u) const
voidFillBuffer(char*& buffer)
TInetAddressGetHostAddress() const
TDatimeGetTime() const
voidGetUUID(UChar_t* uuid) const
UInt_tGetUUIDNumber() const
UShort_tHash() const
virtual TClass*IsA() const
TUUID&operator=(const TUUID&)
voidPrint() const
voidReadBuffer(char*& buffer)
voidSetUUID(const char* uuid_str)
voidSetUUIDNumber(UInt_t index)
virtual voidShowMembers(TMemberInspector& insp, char* parent)
Int_tSizeof() const
virtual voidStreamer(TBuffer& b)
voidStreamerNVirtual(TBuffer& b)
voidStreamerV1(TBuffer& b)
protected:
Int_tCmpTime(TUUID::uuid_time_t* t1, TUUID::uuid_time_t* t2)
voidFormat(UShort_t clockseq, TUUID::uuid_time_t ts)
voidGetCurrentTime(TUUID::uuid_time_t* timestamp)
voidGetNodeIdentifier()
voidGetRandomInfo(UChar_t* seed)
voidGetSystemTime(TUUID::uuid_time_t* timestamp)
voidSetFromString(const char* uuid_str)

Data Members

protected:
UChar_tfClockSeqHiAndReservedhigh 6 clock bits + 2 bits reserved
UChar_tfClockSeqLowlow 8 clock bits
UChar_tfNode[6]6 node id bytes
UShort_tfTimeHiAndVersionhigh 12 time bits + 4 UUID version bits
UInt_tfTimeLow60 bit time, lower 32 bits
UShort_tfTimeMidmiddle 16 time bits
UInt_tfUUIDIndex!index in the list of UUIDs in TProcessUUID

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TUUID()
 Create a UUID.
~TUUID()
 delete this TUUID
Int_t CmpTime(TUUID::uuid_time_t* t1, TUUID::uuid_time_t* t2)
 Compare two time values.
void SetFromString(const char* uuid_str)
 Set this UUID to the value specified in uuid ((which must be in
 TUUID::AsString() format).
TUUID(const char *uuid)
 Initialize a TUUID with uuid (which must be in TUUID::AsString() format).
void FillBuffer(char*& buffer)
 Stream UUID into output buffer.
void ReadBuffer(char*& buffer)
 Stream UUID from input buffer.
void 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.
void Format(UShort_t clockseq, TUUID::uuid_time_t ts)
 Make a UUID from timestamp, clockseq and node id.
void GetCurrentTime(TUUID::uuid_time_t* timestamp)
 Get current time as 60 bit 100ns ticks since whenever.
 Compensate for the fact that real clock resolution is less
 than 100ns.
void GetSystemTime(TUUID::uuid_time_t* timestamp)
 Get system time with 100ns precision. Time is since Oct 15, 1582.
void GetNodeIdentifier()
 Get node identifier. Try first to get network address, if no
 network interface try random info based on some machine parameters.
void GetRandomInfo(UChar_t* seed)
 Get random info based on some machine parameters.
void Print() const
 Print UUID.
const char * AsString() const
 Return UUID as string. Copy string immediately since it will be reused.
UShort_t Hash() const
 Compute 16-bit hash value of the UUID.
Int_t 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
TInetAddress 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.
TDatime GetTime() const
 Get time from UUID.
void GetUUID(UChar_t* uuid) const
 Return uuid in specified buffer (16 byte = 128 bits).
void SetUUID(const char* uuid_str)
 Set this UUID to the value specified in uuid ((which must be in
 TUUID::AsString() format).
TUUID()
UInt_t GetUUIDNumber() const
{ return fUUIDIndex; }
void SetUUIDNumber(UInt_t index)
{ fUUIDIndex = index; }
Int_t Sizeof() const
{ return 18; }