ATLAS Offline Software
Guid.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef PERSISTENTDATAMODEL_GUID_H
6 #define PERSISTENTDATAMODEL_GUID_H
7 
13 #include <iostream> // for std::ostream
14 #include <string>
15 #include <cstring>
16 
20 class Guid {
21 public:
23  Guid() : m_data1(0U), m_data2(0U), m_data3(0U), m_data4() {}
25  explicit Guid(bool assign) : Guid() { if (assign) create(*this); }
27  explicit Guid(const char* s) { fromString(s); }
29  explicit Guid(const std::string& s) { fromString(s); }
31  Guid(const Guid& c) { *this = c; }
33  Guid& operator=(const Guid& g) {
34  if (this != &g) {
35  m_data1 = g.m_data1;
36  m_data2 = g.m_data2;
37  m_data3 = g.m_data3;
38  memcpy (m_data4, g.m_data4, sizeof (m_data4));
39  }
40  return *this;
41  }
43  bool operator<(const Guid& g) const;
45  bool operator==(const Guid& g) const {
46  if (this != & g) {
47  if (m_data1 != g.m_data1 ) return false;
48  if (m_data2 != g.m_data2 ) return false;
49  if (m_data3 != g.m_data3 ) return false;
50  const unsigned int* p = (const unsigned int*)m_data4, *q = (const unsigned int*)g.m_data4;
51  return *p++ == *q++ && *p == *q;
52  }
53  return true;
54  }
55  bool operator==(const std::string& g) const { return (this->toString() == g); }
57  bool operator!=(const Guid& g) const { return !(this->operator==(g)); }
58  bool operator!=(const std::string& g) const { return !(this->operator==(g)); }
59 
61  const std::string toString() const;
63  const Guid& fromString(const std::string& s);
65  static const Guid& null();
66 
71 
75 
77  unsigned int data1() const { return m_data1; }
78  unsigned short data2() const { return m_data2; }
79  unsigned short data3() const { return m_data3; }
80  unsigned char data4(unsigned int i) const { if (i < 8) return m_data4[i]; return 0; }
81 
83  void setData1(unsigned int data) { m_data1 = data; }
84  void setData2(unsigned short data) { m_data2 = data; }
85  void setData3(unsigned short data) { m_data3 = data; }
86  void setData4(unsigned char data, unsigned int i) { if (i < 8) m_data4[i] = data; }
87 
89  friend bool operator==(const std::string& str, const Guid& rhs) { return (rhs.operator==(str)); }
91  friend bool operator!=(const std::string& str, const Guid& rhs) { return !(rhs.operator==(str)); }
93  friend std::ostream& operator<<(std::ostream& os, const Guid& rhs) { os << rhs.toString(); return os; }
94 
95 private:
96  unsigned int m_data1;
97  unsigned short m_data2;
98  unsigned short m_data3;
99  unsigned char m_data4[8];
100 };
101 
102 #endif
RunTileTBRec.method
method
Definition: RunTileTBRec.py:73
Guid::Guid
Guid()
Standard constructor.
Definition: Guid.h:23
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Guid::m_data4
unsigned char m_data4[8]
Definition: Guid.h:99
Guid::initGuidGenMethod
static GuidGenMethod initGuidGenMethod()
Checks for POOL_GUID_TIME or POOL_GUID_RANDOM env variables.
Definition: Guid.cxx:24
Guid::setData1
void setData1(unsigned int data)
Allow modifiers for member data.
Definition: Guid.h:83
Guid::Guid
Guid(const Guid &c)
Copy constructor.
Definition: Guid.h:31
Guid::operator==
bool operator==(const std::string &g) const
Definition: Guid.h:55
Guid::toString
const std::string toString() const
Automatic conversion to string representation.
Definition: Guid.cxx:58
Guid::m_data3
unsigned short m_data3
Definition: Guid.h:98
Guid::Guid
Guid(bool assign)
Standard constructor (With possible initialization)
Definition: Guid.h:25
Guid::data1
unsigned int data1() const
Allow accessors to member data.
Definition: Guid.h:77
Guid::data3
unsigned short data3() const
Definition: Guid.h:79
Guid::GuidGenByTime
@ GuidGenByTime
Definition: Guid.h:67
Guid::data2
unsigned short data2() const
Definition: Guid.h:78
Guid::create
static void create(Guid &guid, GuidGenMethod method=GuidGenDefault)
Create a new Guid default method is currently Random, can be changed by param, API or environment.
Definition: Guid.cxx:33
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
Guid::GuidGenRandom
@ GuidGenRandom
Definition: Guid.h:67
Guid::GuidGenMethod
GuidGenMethod
Definition: Guid.h:67
lumiFormat.i
int i
Definition: lumiFormat.py:85
Guid::operator==
friend bool operator==(const std::string &str, const Guid &rhs)
Equality operator.
Definition: Guid.h:89
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
Guid::GuidGenDefault
@ GuidGenDefault
Definition: Guid.h:67
Guid::operator!=
friend bool operator!=(const std::string &str, const Guid &rhs)
Non-equality operator.
Definition: Guid.h:91
Guid::Guid
Guid(const std::string &s)
Constructor for Guid from string.
Definition: Guid.h:29
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
pool_uuid.guid
guid
Definition: pool_uuid.py:112
Guid::operator<
bool operator<(const Guid &g) const
Smaller operator.
Definition: Guid.cxx:78
Guid::m_data1
unsigned int m_data1
Definition: Guid.h:96
Guid::operator==
bool operator==(const Guid &g) const
Equality operator.
Definition: Guid.h:45
Guid
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
Definition: Guid.h:20
Guid::operator=
Guid & operator=(const Guid &g)
Assignment operator.
Definition: Guid.h:33
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
Guid::m_guidGenMethod
static const GuidGenMethod m_guidGenMethod
Definition: Guid.h:68
Guid::operator<<
friend std::ostream & operator<<(std::ostream &os, const Guid &rhs)
Extraction operators.
Definition: Guid.h:93
Guid::setData3
void setData3(unsigned short data)
Definition: Guid.h:85
Guid::data4
unsigned char data4(unsigned int i) const
Definition: Guid.h:80
Guid::fromString
const Guid & fromString(const std::string &s)
Automatic conversion from string representation.
Definition: Guid.cxx:65
extractSporadic.q
list q
Definition: extractSporadic.py:98
Guid::Guid
Guid(const char *s)
Constructor for Guid from char*.
Definition: Guid.h:27
Guid::operator!=
bool operator!=(const std::string &g) const
Definition: Guid.h:58
str
Definition: BTagTrackIpAccessor.cxx:11
Guid::setData4
void setData4(unsigned char data, unsigned int i)
Definition: Guid.h:86
Guid::m_data2
unsigned short m_data2
Definition: Guid.h:97
Guid::setData2
void setData2(unsigned short data)
Definition: Guid.h:84
Guid::operator!=
bool operator!=(const Guid &g) const
Non-equality operator.
Definition: Guid.h:57
python.compressB64.c
def c
Definition: compressB64.py:93