Logo ROOT  
Reference Guide
TUUID.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 30/9/2001
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TUUID
13 #define ROOT_TUUID
14 
15 //////////////////////////////////////////////////////////////////////////
16 // //
17 // TUUID //
18 // //
19 // This class defines a UUID (Universally Unique IDentifier), also //
20 // known as GUIDs (Globally Unique IDentifier). A UUID is 128 bits //
21 // long, and if generated according to this algorithm, is either //
22 // guaranteed to be different from all other UUIDs/GUIDs generated //
23 // until 3400 A.D. or extremely likely to be different. UUIDs were //
24 // originally used in the Network Computing System (NCS) and //
25 // later in the Open Software Foundation's (OSF) Distributed Computing //
26 // Environment (DCE). //
27 // //
28 //////////////////////////////////////////////////////////////////////////
29 
30 #ifdef WIN32
31 #undef GetCurrentTime
32 #endif
33 #include "Rtypes.h"
34 
35 // forward declaration
36 class TBuffer;
37 class TFile;
38 class TDirectory;
39 class TInetAddress;
40 class TDatime;
41 
42 class TUUID {
43 
44 protected:
45  UInt_t fUUIDIndex; //!index in the list of UUIDs in TProcessUUID
46  UInt_t fTimeLow; // 60 bit time, lower 32 bits
47  UShort_t fTimeMid; // middle 16 time bits
48  UShort_t fTimeHiAndVersion; // high 12 time bits + 4 UUID version bits
49  UChar_t fClockSeqHiAndReserved; // high 6 clock bits + 2 bits reserved
50  UChar_t fClockSeqLow; // low 8 clock bits
51  UChar_t fNode[6]; // 6 node id bytes
52 
53  struct uuid_time_t {
56  };
57 
59  void Format(UShort_t clockseq, uuid_time_t ts);
60  void GetNodeIdentifier();
61  void GetCurrentTime(uuid_time_t *timestamp);
62  void GetSystemTime(uuid_time_t *timestamp);
63  void GetRandomInfo(UChar_t seed[16]);
64  void SetFromString(const char *uuid_str);
65 
66 public:
67  TUUID();
68  TUUID(const char *uuid_str);
69  virtual ~TUUID();
70 
71  const char *AsString() const;
72  Int_t Compare(const TUUID &u) const;
73  UShort_t Hash() const;
74  void Print() const;
76  TDatime GetTime() const;
77  void GetUUID(UChar_t uuid[16]) const;
78  void SetUUID(const char *uuid_str);
79  UInt_t GetUUIDNumber() const { return fUUIDIndex; }
80  void SetUUIDNumber(UInt_t index) { fUUIDIndex = index; }
81 
82  void StreamerV1(TBuffer &b);
83  void FillBuffer(char *&buffer);
84  void ReadBuffer(char *&buffer);
85  Int_t Sizeof() const { return 18; }
86 
87  ClassDef(TUUID,1) // Universally Unique IDentifier
88 };
89 
90 
91 inline TBuffer &operator>>(TBuffer &buf, TUUID &uuid)
92 { uuid.Streamer(buf); return buf; }
93 
94 // Not inlined in order to avoid const casted away warning in user code.
95 TBuffer &operator<<(TBuffer &buf, const TUUID &uuid);
96 
97 inline Bool_t operator==(const TUUID &u1, const TUUID &u2)
98 { return (!u1.Compare(u2)) ? kTRUE : kFALSE; }
99 
100 inline Bool_t operator!=(const TUUID &u1, const TUUID &u2)
101 { return !(u1 == u2); }
102 
103 
104 #endif
TUUID::GetNodeIdentifier
void GetNodeIdentifier()
Get node identifier.
Definition: TUUID.cxx:425
TUUID::uuid_time_t
Definition: TUUID.h:53
TUUID::Hash
UShort_t Hash() const
Compute 16-bit hash value of the UUID.
Definition: TUUID.cxx:585
TUUID::fTimeLow
UInt_t fTimeLow
index in the list of UUIDs in TProcessUUID
Definition: TUUID.h:46
TUUID::SetUUIDNumber
void SetUUIDNumber(UInt_t index)
Definition: TUUID.h:80
TUUID::FillBuffer
void FillBuffer(char *&buffer)
Stream UUID into output buffer.
Definition: TUUID.cxx:274
TUUID::TUUID
TUUID()
Create a UUID.
Definition: TUUID.cxx:152
TUUID::uuid_time_t::low
UInt_t low
Definition: TUUID.h:55
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TUUID::~TUUID
virtual ~TUUID()
delete this TUUID
Definition: TUUID.cxx:197
operator>>
TBuffer & operator>>(TBuffer &buf, TUUID &uuid)
Definition: TUUID.h:91
TUUID::GetCurrentTime
void GetCurrentTime(uuid_time_t *timestamp)
Get current time as 60 bit 100ns ticks since whenever.
Definition: TUUID.cxx:340
UShort_t
unsigned short UShort_t
Definition: RtypesCore.h:40
TUUID::ReadBuffer
void ReadBuffer(char *&buffer)
Stream UUID from input buffer.
Definition: TUUID.cxx:290
TUUID::CmpTime
Int_t CmpTime(uuid_time_t *t1, uuid_time_t *t2)
Compare two time values.
Definition: TUUID.cxx:205
TUUID::GetTime
TDatime GetTime() const
Get time from UUID.
Definition: TUUID.cxx:669
TBuffer
Buffer base class used for serializing objects.
Definition: TBuffer.h:43
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
b
#define b(i)
Definition: RSha256.hxx:100
TUUID::fUUIDIndex
UInt_t fUUIDIndex
Definition: TUUID.h:45
operator==
Bool_t operator==(const TUUID &u1, const TUUID &u2)
Definition: TUUID.h:97
TUUID::GetUUIDNumber
UInt_t GetUUIDNumber() const
Definition: TUUID.h:79
TUUID::fTimeHiAndVersion
UShort_t fTimeHiAndVersion
Definition: TUUID.h:48
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TUUID
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition: TUUID.h:42
operator!=
Bool_t operator!=(const TUUID &u1, const TUUID &u2)
Definition: TUUID.h:100
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
unsigned int
TUUID::Sizeof
Int_t Sizeof() const
Definition: TUUID.h:85
TUUID::StreamerV1
void StreamerV1(TBuffer &b)
Stream UUID from input buffer.
Definition: TUUID.cxx:308
operator<<
TBuffer & operator<<(TBuffer &buf, const TUUID &uuid)
Input operator. Delegate to Streamer.
Definition: TUUID.cxx:714
TUUID::fNode
UChar_t fNode[6]
Definition: TUUID.h:51
TUUID::Compare
Int_t Compare(const TUUID &u) const
Compare two UUIDs "lexically" and return.
Definition: TUUID.cxx:635
TUUID::fClockSeqLow
UChar_t fClockSeqLow
Definition: TUUID.h:50
TUUID::SetUUID
void SetUUID(const char *uuid_str)
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).
Definition: TUUID.cxx:703
TUUID::uuid_time_t::high
UInt_t high
Definition: TUUID.h:54
TUUID::Format
void Format(UShort_t clockseq, uuid_time_t ts)
Make a UUID from timestamp, clockseq and node id.
Definition: TUUID.cxx:323
t1
auto * t1
Definition: textangle.C:20
UChar_t
unsigned char UChar_t
Definition: RtypesCore.h:38
TUUID::GetHostAddress
TInetAddress GetHostAddress() const
Get address of host encoded in UUID.
Definition: TUUID.cxx:656
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TDirectory
Describe directory structure in memory.
Definition: TDirectory.h:40
TUUID::AsString
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
Definition: TUUID.cxx:570
TDatime
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:37
TUUID::GetRandomInfo
void GetRandomInfo(UChar_t seed[16])
Get random info based on some machine parameters.
Definition: TUUID.cxx:510
TUUID::fTimeMid
UShort_t fTimeMid
Definition: TUUID.h:47
TInetAddress
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:36
Rtypes.h
TUUID::fClockSeqHiAndReserved
UChar_t fClockSeqHiAndReserved
Definition: TUUID.h:49
TUUID::Print
void Print() const
Print UUID.
Definition: TUUID.cxx:562
TUUID::GetSystemTime
void GetSystemTime(uuid_time_t *timestamp)
Get system time with 100ns precision. Time is since Oct 15, 1582.
Definition: TUUID.cxx:392
int
TUUID::SetFromString
void SetFromString(const char *uuid_str)
Set this UUID to the value specified in uuid ((which must be in TUUID::AsString() format).
Definition: TUUID.cxx:218
TUUID::GetUUID
void GetUUID(UChar_t uuid[16]) const
Return uuid in specified buffer (16 byte = 128 bits).
Definition: TUUID.cxx:694