ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_Rtypes
34 #include "Rtypes.h"
35 #endif
36 
37 // forward declaration
38 class TBuffer;
39 class TFile;
40 class TDirectory;
41 class TInetAddress;
42 class TDatime;
43 
44 class TUUID {
45 
46 protected:
47  UInt_t fUUIDIndex; //!index in the list of UUIDs in TProcessUUID
48  UInt_t fTimeLow; // 60 bit time, lower 32 bits
49  UShort_t fTimeMid; // middle 16 time bits
50  UShort_t fTimeHiAndVersion; // high 12 time bits + 4 UUID version bits
51  UChar_t fClockSeqHiAndReserved; // high 6 clock bits + 2 bits reserved
52  UChar_t fClockSeqLow; // low 8 clock bits
53  UChar_t fNode[6]; // 6 node id bytes
54 
55  struct uuid_time_t {
58  };
59 
61  void Format(UShort_t clockseq, uuid_time_t ts);
62  void GetNodeIdentifier();
63  void GetCurrentTime(uuid_time_t *timestamp);
64  void GetSystemTime(uuid_time_t *timestamp);
65  void GetRandomInfo(UChar_t seed[16]);
66  void SetFromString(const char *uuid_str);
67 
68 public:
69  TUUID();
70  TUUID(const char *uuid_str);
71  virtual ~TUUID();
72 
73  const char *AsString() const;
74  Int_t Compare(const TUUID &u) const;
75  UShort_t Hash() const;
76  void Print() const;
78  TDatime GetTime() const;
79  void GetUUID(UChar_t uuid[16]) const;
80  void SetUUID(const char *uuid_str);
81  UInt_t GetUUIDNumber() const { return fUUIDIndex; }
82  void SetUUIDNumber(UInt_t index) { fUUIDIndex = index; }
83 
84  void StreamerV1(TBuffer &b);
85  void FillBuffer(char *&buffer);
86  void ReadBuffer(char *&buffer);
87  Int_t Sizeof() const { return 18; }
88 
89  ClassDef(TUUID,1) // Universally Unique IDentifier
90 };
91 
92 
93 inline TBuffer &operator>>(TBuffer &buf, TUUID &uuid)
94 { uuid.Streamer(buf); return buf; }
95 
96 // Not inlined in order to avoid const casted away warning in user code.
97 TBuffer &operator<<(TBuffer &buf, const TUUID &uuid);
98 
99 inline Bool_t operator==(const TUUID &u1, const TUUID &u2)
100 { return (!u1.Compare(u2)) ? kTRUE : kFALSE; }
101 
102 inline Bool_t operator!=(const TUUID &u1, const TUUID &u2)
103 { return !(u1 == u2); }
104 
105 
106 #endif
TDatime GetTime() const
Get time from UUID.
Definition: TUUID.cxx:635
virtual ~TUUID()
delete this TUUID
Definition: TUUID.cxx:188
tuple buffer
Definition: tree.py:99
UInt_t low
Definition: TUUID.h:57
Bool_t operator==(const TUUID &u1, const TUUID &u2)
Definition: TUUID.h:99
unsigned short UShort_t
Definition: RtypesCore.h:36
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:45
This class represents an Internet Protocol (IP) address.
Definition: TInetAddress.h:40
void ReadBuffer(char *&buffer)
Stream UUID from input buffer.
Definition: TUUID.cxx:281
UInt_t fTimeLow
index in the list of UUIDs in TProcessUUID
Definition: TUUID.h:48
Buffer base class used for serializing objects.
Definition: TBuffer.h:42
UInt_t GetUUIDNumber() const
Definition: TUUID.h:81
TBuffer & operator<<(TBuffer &buf, const TUUID &uuid)
Input operator. Delegate to Streamer.
Definition: TUUID.cxx:680
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
UInt_t fUUIDIndex
Definition: TUUID.h:47
TLatex * t1
Definition: textangle.C:20
Int_t CmpTime(uuid_time_t *t1, uuid_time_t *t2)
Compare two time values.
Definition: TUUID.cxx:196
This class defines a UUID (Universally Unique IDentifier), also known as GUIDs (Globally Unique IDent...
Definition: TUUID.h:44
#define ClassDef(name, id)
Definition: Rtypes.h:254
UShort_t fTimeHiAndVersion
Definition: TUUID.h:50
void Print() const
Print UUID.
Definition: TUUID.cxx:528
UShort_t Hash() const
Compute 16-bit hash value of the UUID.
Definition: TUUID.cxx:551
unsigned int UInt_t
Definition: RtypesCore.h:42
const char * AsString() const
Return UUID as string. Copy string immediately since it will be reused.
Definition: TUUID.cxx:536
void GetUUID(UChar_t uuid[16]) const
Return uuid in specified buffer (16 byte = 128 bits).
Definition: TUUID.cxx:660
UChar_t fNode[6]
Definition: TUUID.h:53
TText * t2
Definition: rootenv.C:28
TInetAddress GetHostAddress() const
Get address of host encoded in UUID.
Definition: TUUID.cxx:622
UInt_t high
Definition: TUUID.h:56
void Format(UShort_t clockseq, uuid_time_t ts)
Make a UUID from timestamp, clockseq and node id.
Definition: TUUID.cxx:314
Describe directory structure in memory.
Definition: TDirectory.h:44
void StreamerV1(TBuffer &b)
Stream UUID from input buffer.
Definition: TUUID.cxx:299
UShort_t fTimeMid
Definition: TUUID.h:49
TBuffer & operator>>(TBuffer &buf, TUUID &uuid)
Definition: TUUID.h:93
Int_t Sizeof() const
Definition: TUUID.h:87
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:669
UChar_t fClockSeqHiAndReserved
Definition: TUUID.h:51
Int_t Compare(const TUUID &u) const
Compare two UUIDs "lexically" and return.
Definition: TUUID.cxx:601
void GetRandomInfo(UChar_t seed[16])
Get random info based on some machine parameters.
Definition: TUUID.cxx:476
void GetNodeIdentifier()
Get node identifier.
Definition: TUUID.cxx:416
Bool_t operator!=(const TUUID &u1, const TUUID &u2)
Definition: TUUID.h:102
void SetUUIDNumber(UInt_t index)
Definition: TUUID.h:82
void FillBuffer(char *&buffer)
Stream UUID into output buffer.
Definition: TUUID.cxx:265
UChar_t fClockSeqLow
Definition: TUUID.h:52
unsigned char UChar_t
Definition: RtypesCore.h:34
const Bool_t kTRUE
Definition: Rtypes.h:91
void GetSystemTime(uuid_time_t *timestamp)
Get system time with 100ns precision. Time is since Oct 15, 1582.
Definition: TUUID.cxx:383
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:209
void GetCurrentTime(uuid_time_t *timestamp)
Get current time as 60 bit 100ns ticks since whenever.
Definition: TUUID.cxx:331
This class stores the date and time with a precision of one second in an unsigned 32 bit word (950130...
Definition: TDatime.h:39