ROOT
6.07/01
Reference Guide
|
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.
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:
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.
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.
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.
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>
TUUID::TUUID | ( | ) |
TUUID::TUUID | ( | const char * | uuid_str | ) |
Initialize a TUUID with uuid (which must be in TUUID::AsString() format).
const char * TUUID::AsString | ( | ) | const |
Return UUID as string. Copy string immediately since it will be reused.
Definition at line 536 of file TUUID.cxx.
Referenced by TFileMerger::AddFile(), TProcessID::AddProcessID(), TProcessUUID::AddUUID(), RooSharedProperties::asString(), TSQLFile::DirWriteHeader(), TFileCollection::GetFilesOnServer(), TFileCollection::GetFilesPerServer(), TAlienCollection::Open(), TFileMerger::OpenExcessFiles(), RooSharedProperties::Print(), Print(), TSelEventGen::Process(), TProofPlayer::ReinitSelector(), TFileCollection::RemoveDuplicates(), TXMLFile::SaveToFile(), TDataSetManager::ScanFile(), TLinearMinimizer::SetFunction(), and TFileInfo::TFileInfo().
|
protected |
Compare two UUIDs "lexically" and return.
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().
|
protected |
|
protected |
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.
|
protected |
Get random info based on some machine parameters.
Definition at line 476 of file TUUID.cxx.
Referenced by GetNodeIdentifier().
|
protected |
Get system time with 100ns precision. Time is since Oct 15, 1582.
Definition at line 383 of file TUUID.cxx.
Referenced by GetCurrentTime().
Return uuid in specified buffer (16 byte = 128 bits).
Definition at line 660 of file TUUID.cxx.
Referenced by TRandom2::SetSeed(), and TRandom::SetSeed().
UShort_t TUUID::Hash | ( | ) | const |
void TUUID::ReadBuffer | ( | char *& | buffer | ) |
Stream UUID from input buffer.
Definition at line 281 of file TUUID.cxx.
Referenced by TFile::Init().
|
protected |
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).
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 82 of file TUUID.h.
Referenced by TProcessUUID::AddUUID().
|
inline |
Definition at line 87 of file TUUID.h.
Referenced by TDirectoryFile::Sizeof().
|
protected |
Definition at line 51 of file TUUID.h.
Referenced by AsString(), Compare(), FillBuffer(), Format(), ReadBuffer(), SetFromString(), StreamerV1(), and TUUID().
|
protected |
Definition at line 52 of file TUUID.h.
Referenced by AsString(), Compare(), FillBuffer(), Format(), ReadBuffer(), SetFromString(), StreamerV1(), and TUUID().
|
protected |
Definition at line 53 of file TUUID.h.
Referenced by AsString(), Compare(), FillBuffer(), GetHostAddress(), GetNodeIdentifier(), ReadBuffer(), SetFromString(), StreamerV1(), and TUUID().
|
protected |
Definition at line 50 of file TUUID.h.
Referenced by AsString(), Compare(), FillBuffer(), Format(), GetHostAddress(), GetNodeIdentifier(), GetTime(), ReadBuffer(), SetFromString(), StreamerV1(), and TUUID().
|
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().
|
protected |
Definition at line 49 of file TUUID.h.
Referenced by AsString(), Compare(), FillBuffer(), Format(), GetTime(), ReadBuffer(), SetFromString(), StreamerV1(), and TUUID().
|
protected |
Definition at line 47 of file TUUID.h.
Referenced by GetUUIDNumber(), SetFromString(), SetUUIDNumber(), and TUUID().