Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TUUID.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/base:$Id$
0002 // Author: Fons Rademakers   30/9/2001
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2001, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TUUID
0013 #define ROOT_TUUID
0014 
0015 //////////////////////////////////////////////////////////////////////////
0016 //                                                                      //
0017 // TUUID                                                                //
0018 //                                                                      //
0019 // This class defines a UUID (Universally Unique IDentifier), also      //
0020 // known as GUIDs (Globally Unique IDentifier). A UUID is 128 bits      //
0021 // long, and if generated according to this algorithm, is either        //
0022 // guaranteed to be different from all other UUIDs/GUIDs generated      //
0023 // until 3400 A.D. or extremely likely to be different. UUIDs were      //
0024 // originally used in the Network Computing System (NCS) and            //
0025 // later in the Open Software Foundation's (OSF) Distributed Computing  //
0026 // Environment (DCE).                                                   //
0027 //                                                                      //
0028 //////////////////////////////////////////////////////////////////////////
0029 
0030 #ifdef WIN32
0031 #undef GetCurrentTime
0032 #endif
0033 #include "Rtypes.h"
0034 
0035 // forward declaration
0036 class TBuffer;
0037 class TFile;
0038 class TDirectory;
0039 class TInetAddress;
0040 class TDatime;
0041 
0042 class TUUID {
0043 
0044 protected:
0045    UInt_t    fUUIDIndex;             //!index in the list of UUIDs in TProcessUUID
0046    UInt_t    fTimeLow;               // 60 bit time, lower 32 bits
0047    UShort_t  fTimeMid;               // middle 16 time bits
0048    UShort_t  fTimeHiAndVersion;      // high 12 time bits + 4 UUID version bits
0049    UChar_t   fClockSeqHiAndReserved; // high 6 clock bits + 2 bits reserved
0050    UChar_t   fClockSeqLow;           // low 8 clock bits
0051    UChar_t   fNode[6];               // 6 node id bytes
0052 
0053    struct uuid_time_t {
0054       UInt_t high;
0055       UInt_t low;
0056    };
0057 
0058    Int_t CmpTime(uuid_time_t *t1, uuid_time_t *t2);
0059    void  Format(UShort_t clockseq, uuid_time_t ts);
0060    void  GetNodeIdentifier();
0061    void  GetCurrentTime(uuid_time_t *timestamp);
0062    void  GetSystemTime(uuid_time_t *timestamp);
0063    void  GetRandomInfo(UChar_t seed[16]);
0064    void  SetFromString(const char *uuid_str);
0065 
0066 public:
0067    TUUID();
0068    TUUID(const char *uuid_str);
0069    virtual ~TUUID();
0070 
0071    const char  *AsString() const;
0072    Int_t        Compare(const TUUID &u) const;
0073    UShort_t     Hash() const;
0074    void         Print() const;
0075    TInetAddress GetHostAddress() const;
0076    TDatime      GetTime() const;
0077    void         GetUUID(UChar_t uuid[16]) const;
0078    void         SetUUID(const char *uuid_str);
0079    UInt_t       GetUUIDNumber() const { return fUUIDIndex; }
0080    void         SetUUIDNumber(UInt_t index) { fUUIDIndex = index; }
0081 
0082    void         StreamerV1(TBuffer &b);
0083    void         FillBuffer(char *&buffer);
0084    void         ReadBuffer(char *&buffer);
0085    Int_t        Sizeof() const { return 18; }
0086 
0087    ClassDef(TUUID,1)  // Universally Unique IDentifier
0088 };
0089 
0090 
0091 inline TBuffer &operator>>(TBuffer &buf, TUUID &uuid)
0092 { uuid.Streamer(buf); return buf; }
0093 
0094 // Not inlined in order to avoid const casted away warning in user code.
0095 TBuffer &operator<<(TBuffer &buf, const TUUID &uuid);
0096 
0097 inline Bool_t operator==(const TUUID &u1, const TUUID &u2)
0098 { return (!u1.Compare(u2)) ? kTRUE : kFALSE; }
0099 
0100 inline Bool_t operator!=(const TUUID &u1, const TUUID &u2)
0101 { return !(u1 == u2); }
0102 
0103 
0104 #endif