ATLAS Offline Software
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | Friends | List of all members
Guid Class Reference

This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number). More...

#include <Guid.h>

Collaboration diagram for Guid:

Public Types

enum  GuidGenMethod { GuidGenDefault, GuidGenRandom, GuidGenByTime }
 

Public Member Functions

 Guid ()
 Standard constructor. More...
 
 Guid (bool assign)
 Standard constructor (With possible initialization) More...
 
 Guid (const char *s)
 Constructor for Guid from char*. More...
 
 Guid (const std::string &s)
 Constructor for Guid from string. More...
 
 Guid (const Guid &c)
 Copy constructor. More...
 
Guidoperator= (const Guid &g)
 Assignment operator. More...
 
bool operator< (const Guid &g) const
 Smaller operator. More...
 
bool operator== (const Guid &g) const
 Equality operator. More...
 
bool operator== (const std::string &g) const
 
bool operator!= (const Guid &g) const
 Non-equality operator. More...
 
bool operator!= (const std::string &g) const
 
const std::string toString () const
 Automatic conversion to string representation. More...
 
const GuidfromString (const std::string &s)
 Automatic conversion from string representation. More...
 
unsigned int data1 () const
 Allow accessors to member data. More...
 
unsigned short data2 () const
 
unsigned short data3 () const
 
unsigned char data4 (unsigned int i) const
 
void setData1 (unsigned int data)
 Allow modifiers for member data. More...
 
void setData2 (unsigned short data)
 
void setData3 (unsigned short data)
 
void setData4 (unsigned char data, unsigned int i)
 

Static Public Member Functions

static const Guidnull ()
 NULL-Guid: static class method. More...
 
static GuidGenMethod initGuidGenMethod ()
 Checks for POOL_GUID_TIME or POOL_GUID_RANDOM env variables. More...
 
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. More...
 

Static Public Attributes

static const GuidGenMethod m_guidGenMethod = Guid::initGuidGenMethod()
 

Private Attributes

unsigned int m_data1
 
unsigned short m_data2
 
unsigned short m_data3
 
unsigned char m_data4 [8]
 

Friends

bool operator== (const std::string &str, const Guid &rhs)
 Equality operator. More...
 
bool operator!= (const std::string &str, const Guid &rhs)
 Non-equality operator. More...
 
std::ostream & operator<< (std::ostream &os, const Guid &rhs)
 Extraction operators. More...
 

Detailed Description

This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).

Definition at line 20 of file Guid.h.

Member Enumeration Documentation

◆ GuidGenMethod

Enumerator
GuidGenDefault 
GuidGenRandom 
GuidGenByTime 

Definition at line 67 of file Guid.h.

Constructor & Destructor Documentation

◆ Guid() [1/5]

Guid::Guid ( )
inline

Standard constructor.

Definition at line 23 of file Guid.h.

23 : m_data1(0U), m_data2(0U), m_data3(0U), m_data4() {}

◆ Guid() [2/5]

Guid::Guid ( bool  assign)
inlineexplicit

Standard constructor (With possible initialization)

Definition at line 25 of file Guid.h.

25 : Guid() { if (assign) create(*this); }

◆ Guid() [3/5]

Guid::Guid ( const char *  s)
inlineexplicit

Constructor for Guid from char*.

Definition at line 27 of file Guid.h.

27 { fromString(s); }

◆ Guid() [4/5]

Guid::Guid ( const std::string &  s)
inlineexplicit

Constructor for Guid from string.

Definition at line 29 of file Guid.h.

29 { fromString(s); }

◆ Guid() [5/5]

Guid::Guid ( const Guid c)
inline

Copy constructor.

Definition at line 31 of file Guid.h.

31 { *this = c; }

Member Function Documentation

◆ create()

void Guid::create ( Guid guid,
GuidGenMethod  method = GuidGenDefault 
)
static

Create a new Guid default method is currently Random, can be changed by param, API or environment.

Create a new Guid.

Definition at line 33 of file Guid.cxx.

33  {
34  uuid_t me_;
36  switch(method) {
37  case GuidGenRandom:
38  ::uuid_generate(me_);
39  break;
40  case GuidGenByTime:
41  ::uuid_generate_time(me_);
42  break;
43  default:
44  ::uuid_generate(me_);
45  break;
46  }
47  unsigned int *d1 = (unsigned int*)me_;
48  unsigned short *d2 = (unsigned short*)(me_ + 4);
49  unsigned short *d3 = (unsigned short*)(me_ + 6);
50  guid.m_data1 = *d1;
51  guid.m_data2 = *d2;
52  guid.m_data3 = *d3;
53  for (unsigned int i = 0; i < 8; i++) {
54  guid.m_data4[i] = me_[i + 8];
55  }
56 }

◆ data1()

unsigned int Guid::data1 ( ) const
inline

Allow accessors to member data.

Definition at line 77 of file Guid.h.

77 { return m_data1; }

◆ data2()

unsigned short Guid::data2 ( ) const
inline

Definition at line 78 of file Guid.h.

78 { return m_data2; }

◆ data3()

unsigned short Guid::data3 ( ) const
inline

Definition at line 79 of file Guid.h.

79 { return m_data3; }

◆ data4()

unsigned char Guid::data4 ( unsigned int  i) const
inline

Definition at line 80 of file Guid.h.

80 { if (i < 8) return m_data4[i]; return 0; }

◆ fromString()

const Guid & Guid::fromString ( const std::string &  s)

Automatic conversion from string representation.

Definition at line 65 of file Guid.cxx.

65  {
66  if (::sscanf(source.c_str(), fmt_Guid, &m_data1, &m_data2, &m_data3,
67  &m_data4[0], &m_data4[1], &m_data4[2], &m_data4[3], &m_data4[4], &m_data4[5], &m_data4[6], &m_data4[7]) != 11) {
68  m_data1 = 0U;
69  m_data2 = 0U;
70  m_data3 = 0U;
71  for (unsigned int i = 0; i < 8; i++) {
72  m_data4[i] = '\0';
73  }
74  }
75  return *this;
76 }

◆ initGuidGenMethod()

Guid::GuidGenMethod Guid::initGuidGenMethod ( )
static

Checks for POOL_GUID_TIME or POOL_GUID_RANDOM env variables.

Definition at line 24 of file Guid.cxx.

24  {
25  char* envv = getenv("POOL_GUID_TIME");
26  if (envv != 0 && *envv) return GuidGenByTime;
27  envv = getenv("POOL_GUID_RANDOM");
28  if (envv != 0 && *envv) return GuidGenRandom;
29  return GuidGenDefault;
30 }

◆ null()

const Guid & Guid::null ( )
static

NULL-Guid: static class method.

Definition at line 18 of file Guid.cxx.

18  {
19  return clid_null;
20 }

◆ operator!=() [1/2]

bool Guid::operator!= ( const Guid g) const
inline

Non-equality operator.

Definition at line 57 of file Guid.h.

57 { return !(this->operator==(g)); }

◆ operator!=() [2/2]

bool Guid::operator!= ( const std::string &  g) const
inline

Definition at line 58 of file Guid.h.

58 { return !(this->operator==(g)); }

◆ operator<()

bool Guid::operator< ( const Guid g) const

Smaller operator.

Definition at line 78 of file Guid.cxx.

78  {
79  return ::memcmp(&g.m_data1, &m_data1, 16) < 0;
80 }

◆ operator=()

Guid& Guid::operator= ( const Guid g)
inline

Assignment operator.

Definition at line 33 of file Guid.h.

33  {
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  }

◆ operator==() [1/2]

bool Guid::operator== ( const Guid g) const
inline

Equality operator.

Definition at line 45 of file Guid.h.

45  {
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  }

◆ operator==() [2/2]

bool Guid::operator== ( const std::string &  g) const
inline

Definition at line 55 of file Guid.h.

55 { return (this->toString() == g); }

◆ setData1()

void Guid::setData1 ( unsigned int  data)
inline

Allow modifiers for member data.

Definition at line 83 of file Guid.h.

83 { m_data1 = data; }

◆ setData2()

void Guid::setData2 ( unsigned short  data)
inline

Definition at line 84 of file Guid.h.

84 { m_data2 = data; }

◆ setData3()

void Guid::setData3 ( unsigned short  data)
inline

Definition at line 85 of file Guid.h.

85 { m_data3 = data; }

◆ setData4()

void Guid::setData4 ( unsigned char  data,
unsigned int  i 
)
inline

Definition at line 86 of file Guid.h.

86 { if (i < 8) m_data4[i] = data; }

◆ toString()

const std::string Guid::toString ( ) const

Automatic conversion to string representation.

Definition at line 58 of file Guid.cxx.

58  {
59  char text[128];
60  int s = ::sprintf(text, fmt_Guid, m_data1, m_data2, m_data3,
61  m_data4[0], m_data4[1], m_data4[2], m_data4[3], m_data4[4], m_data4[5], m_data4[6], m_data4[7]);
62  return std::string(text, s);
63 }

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const std::string &  str,
const Guid rhs 
)
friend

Non-equality operator.

Definition at line 91 of file Guid.h.

91 { return !(rhs.operator==(str)); }

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Guid rhs 
)
friend

Extraction operators.

Definition at line 93 of file Guid.h.

93 { os << rhs.toString(); return os; }

◆ operator==

bool operator== ( const std::string &  str,
const Guid rhs 
)
friend

Equality operator.

Definition at line 89 of file Guid.h.

89 { return (rhs.operator==(str)); }

Member Data Documentation

◆ m_data1

unsigned int Guid::m_data1
private

Definition at line 96 of file Guid.h.

◆ m_data2

unsigned short Guid::m_data2
private

Definition at line 97 of file Guid.h.

◆ m_data3

unsigned short Guid::m_data3
private

Definition at line 98 of file Guid.h.

◆ m_data4

unsigned char Guid::m_data4[8]
private

Definition at line 99 of file Guid.h.

◆ m_guidGenMethod

const Guid::GuidGenMethod Guid::m_guidGenMethod = Guid::initGuidGenMethod()
static

Definition at line 68 of file Guid.h.


The documentation for this class was generated from the following files:
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
dq_defect_virtual_defect_validation.d1
d1
Definition: dq_defect_virtual_defect_validation.py:79
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::GuidGenByTime
@ GuidGenByTime
Definition: Guid.h:67
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
lumiFormat.i
int i
Definition: lumiFormat.py:85
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
Guid::GuidGenDefault
@ GuidGenDefault
Definition: Guid.h:67
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
pool_uuid.guid
guid
Definition: pool_uuid.py:112
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
SCT_ConditionsAlgorithms::CoveritySafe::getenv
std::string getenv(const std::string &variableName)
get an environment variable
Definition: SCT_ConditionsUtilities.cxx:17
python.CaloScaleNoiseConfig.str
str
Definition: CaloScaleNoiseConfig.py:78
Guid::m_guidGenMethod
static const GuidGenMethod m_guidGenMethod
Definition: Guid.h:68
dq_defect_virtual_defect_validation.d2
d2
Definition: dq_defect_virtual_defect_validation.py:81
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
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
copySelective.source
string source
Definition: copySelective.py:32
str
Definition: BTagTrackIpAccessor.cxx:11
Guid::m_data2
unsigned short m_data2
Definition: Guid.h:97
python.compressB64.c
def c
Definition: compressB64.py:93