Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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).

Note
In the way this UUID is constructed, when used outside of their original concept (NCS), they are actually not Globally unique and indeed multiple distinct concurrent processes are actually likely to generate the same UUID. Technically this is because the UUID is constructed only from the node information and time information. To make a globally unique number, this needs to be combined with TProcessUUID.

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
+----------------------------------+
#define hi

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
------------------------------------------------------------
#define a(i)
Definition RSha256.hxx:99
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void 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 42 of file TUUID.h.

Classes

struct  uuid_time_t
 

Public Member Functions

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

Static Public Member Functions

static TClassClass ()
 
static const char * Class_Name ()
 
static constexpr Version_t Class_Version ()
 
static const char * DeclFileName ()
 

Protected Member Functions

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

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
 
UShort_t fTimeMid
 
UInt_t fUUIDIndex
 

#include <TUUID.h>

Constructor & Destructor Documentation

◆ TUUID() [1/2]

TUUID::TUUID ( )

Create a UUID.

Definition at line 153 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 256 of file TUUID.cxx.

◆ ~TUUID()

TUUID::~TUUID ( )
virtual

delete this TUUID

Definition at line 198 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 571 of file TUUID.cxx.

◆ Class()

static TClass * TUUID::Class ( )
static
Returns
TClass describing this class

◆ Class_Name()

static const char * TUUID::Class_Name ( )
static
Returns
Name of this class

◆ Class_Version()

static constexpr Version_t TUUID::Class_Version ( )
inlinestaticconstexpr
Returns
Version of this class

Definition at line 87 of file TUUID.h.

◆ CmpTime()

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

Compare two time values.

Definition at line 206 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 636 of file TUUID.cxx.

◆ DeclFileName()

static const char * TUUID::DeclFileName ( )
inlinestatic
Returns
Name of the file containing the class declaration

Definition at line 87 of file TUUID.h.

◆ FillBuffer()

void TUUID::FillBuffer ( char *&  buffer)

Stream UUID into output buffer.

Definition at line 275 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 324 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 341 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 657 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 426 of file TUUID.cxx.

◆ GetRandomInfo()

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

Get random info based on some machine parameters.

Definition at line 511 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 393 of file TUUID.cxx.

◆ GetTime()

TDatime TUUID::GetTime ( ) const

Get time from UUID.

Definition at line 670 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 695 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 586 of file TUUID.cxx.

◆ IsA()

virtual TClass * TUUID::IsA ( ) const
inlinevirtual
Returns
TClass describing current object

Definition at line 87 of file TUUID.h.

◆ Print()

void TUUID::Print ( ) const

Print UUID.

Definition at line 563 of file TUUID.cxx.

◆ ReadBuffer()

void TUUID::ReadBuffer ( char *&  buffer)

Stream UUID from input buffer.

Definition at line 291 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 219 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 704 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.

◆ Streamer()

virtual void TUUID::Streamer ( TBuffer )
virtual

◆ StreamerNVirtual()

void TUUID::StreamerNVirtual ( TBuffer ClassDef_StreamerNVirtual_b)
inline

Definition at line 87 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 309 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.

Libraries for TUUID:

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