CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes | Private Member Functions
edm::Guid Class Reference

#include <POOLCore/Guid.h>

Public Member Functions

Guid const & fromString (std::string const &s)
 Automatic conversion to string representation. More...
 
 Guid ()
 Standard constructor (With initializaton) More...
 
 Guid (bool)
 Standard constructor (With initialization) More...
 
 Guid (char const *s)
 Constructor for Guid from char*. More...
 
 Guid (Guid const &c)
 Copy constructor. More...
 
 Guid (std::string const &s)
 Constructor for Guid from string. More...
 
bool operator!= (Guid const &g) const
 Non-equality operator. More...
 
bool operator< (Guid const &g) const
 Smaller operator. More...
 
Guidoperator= (Guid const &g)
 Assignment operator. More...
 
bool operator== (Guid const &g) const
 Equality operator. More...
 
const std::string toString () const
 Automatic conversion from string reprentation. More...
 

Public Attributes

unsigned int Data1
 
unsigned short Data2
 
unsigned short Data3
 
unsigned char Data4 [8]
 

Private Member Functions

void init ()
 initialize a new Guid More...
 

Detailed Description

Description:

Encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number). Note: This class may not have a virual destructor

Author
M.Frank Initial version using COM on WIN32
Zhen Xie Include DCE implementation for linux
Version
1.1
Date
03/09/2002

Definition at line 23 of file Guid.h.

Constructor & Destructor Documentation

◆ Guid() [1/5]

edm::Guid::Guid ( )
inline

Standard constructor (With initializaton)

Definition at line 31 of file Guid.h.

31 { init(); }

References init().

◆ Guid() [2/5]

edm::Guid::Guid ( bool  )
inlineexplicit

Standard constructor (With initialization)

Definition at line 33 of file Guid.h.

33 { init(); }

References init().

◆ Guid() [3/5]

edm::Guid::Guid ( char const *  s)
inlineexplicit

Constructor for Guid from char*.

Definition at line 35 of file Guid.h.

35 { fromString(s); }

References fromString(), and alignCSCRings::s.

◆ Guid() [4/5]

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

Constructor for Guid from string.

Definition at line 37 of file Guid.h.

37 { fromString(s); }

References fromString(), and alignCSCRings::s.

◆ Guid() [5/5]

edm::Guid::Guid ( Guid const &  c)
inline

Copy constructor.

Definition at line 39 of file Guid.h.

39 { *this = c; }

References HltBtagPostValidation_cff::c.

Member Function Documentation

◆ fromString()

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

Automatic conversion to string representation.

Definition at line 60 of file Guid.cc.

60  {
61  char const dash = '-';
62  size_t const iSize = 8;
63  size_t const sSize = 4;
64  size_t const cSize = 2;
65  size_t offset = 0;
66  Data1 = strtol(source.substr(offset, iSize).c_str(), nullptr, 16);
67  offset += iSize;
68  assert(dash == source[offset++]);
69  Data2 = strtol(source.substr(offset, sSize).c_str(), nullptr, 16);
70  offset += sSize;
71  assert(dash == source[offset++]);
72  Data3 = strtol(source.substr(offset, sSize).c_str(), nullptr, 16);
73  offset += sSize;
74  assert(dash == source[offset++]);
75  Data4[0] = strtol(source.substr(offset, cSize).c_str(), nullptr, 16);
76  offset += cSize;
77  Data4[1] = strtol(source.substr(offset, cSize).c_str(), nullptr, 16);
78  offset += cSize;
79  assert(dash == source[offset++]);
80  Data4[2] = strtol(source.substr(offset, cSize).c_str(), nullptr, 16);
81  offset += cSize;
82  Data4[3] = strtol(source.substr(offset, cSize).c_str(), nullptr, 16);
83  offset += cSize;
84  Data4[4] = strtol(source.substr(offset, cSize).c_str(), nullptr, 16);
85  offset += cSize;
86  Data4[5] = strtol(source.substr(offset, cSize).c_str(), nullptr, 16);
87  offset += cSize;
88  Data4[6] = strtol(source.substr(offset, cSize).c_str(), nullptr, 16);
89  offset += cSize;
90  Data4[7] = strtol(source.substr(offset, cSize).c_str(), nullptr, 16);
91  offset += cSize;
92  assert(source.size() == offset);
93  return *this;
94  }

References cms::cuda::assert(), Data1, Data2, Data3, Data4, hltrates_dqm_sourceclient-live_cfg::offset, and edm::source().

Referenced by Guid().

◆ init()

void edm::Guid::init ( void  )
private

initialize a new Guid

Initialize a new Guid.

Definition at line 26 of file Guid.cc.

26  {
27  uuid_t me_;
28  ::uuid_generate_random(me_);
29  unsigned int* d1 = reinterpret_cast<unsigned int*>(me_);
30  unsigned short* d2 = reinterpret_cast<unsigned short*>(me_ + 4);
31  unsigned short* d3 = reinterpret_cast<unsigned short*>(me_ + 6);
32  Data1 = *d1;
33  Data2 = *d2;
34  Data3 = *d3;
35  for (int i = 0; i < 8; ++i) {
36  Data4[i] = me_[i + 8];
37  }
38  }

References d1, Data1, Data2, Data3, Data4, and mps_fire::i.

Referenced by Guid().

◆ operator!=()

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

Non-equality operator.

Definition at line 71 of file Guid.h.

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

References operator==().

◆ operator<()

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

Smaller operator.

Definition at line 96 of file Guid.cc.

96 { return ::memcmp(&g.Data1, &Data1, 16) < 0; }

References Data1, and g.

◆ operator=()

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

Assignment operator.

Definition at line 41 of file Guid.h.

41  {
42  if (this != &g) {
43  Data1 = g.Data1;
44  Data2 = g.Data2;
45  Data3 = g.Data3;
46  unsigned int* p = reinterpret_cast<unsigned int*>(&Data4[0]);
47  unsigned int const* q = reinterpret_cast<unsigned int const*>(&g.Data4[0]);
48  *(p + 1) = *(q + 1);
49  *p = *q;
50  }
51  return *this;
52  }

References Data1, Data2, Data3, Data4, g, AlCaHLTBitMon_ParallelJobs::p, and data-class-funcs::q.

◆ operator==()

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

Equality operator.

Definition at line 56 of file Guid.h.

56  {
57  if (this != &g) {
58  if (Data1 != g.Data1)
59  return false;
60  if (Data2 != g.Data2)
61  return false;
62  if (Data3 != g.Data3)
63  return false;
64  unsigned int const* p = reinterpret_cast<unsigned int const*>(&Data4[0]);
65  unsigned int const* q = reinterpret_cast<unsigned int const*>(&g.Data4[0]);
66  return *p == *q && *(p + 1) == *(q + 1);
67  }
68  return true;
69  }

References Data1, Data2, Data3, Data4, g, AlCaHLTBitMon_ParallelJobs::p, and data-class-funcs::q.

Referenced by operator!=().

◆ toString()

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

Automatic conversion from string reprentation.

Definition at line 40 of file Guid.cc.

40  {
41  char text[bufSize];
42  ::snprintf(text,
43  sizeof(text),
44  fmt_Guid,
45  Data1,
46  Data2,
47  Data3,
48  Data4[0],
49  Data4[1],
50  Data4[2],
51  Data4[3],
52  Data4[4],
53  Data4[5],
54  Data4[6],
55  Data4[7]);
56  return text;
57  }

References edm::bufSize, Data1, Data2, Data3, Data4, edm::fmt_Guid, and runonSM::text.

Referenced by edm::createGlobalIdentifier().

Member Data Documentation

◆ Data1

unsigned int edm::Guid::Data1

Definition at line 25 of file Guid.h.

Referenced by fromString(), init(), operator<(), operator=(), operator==(), and toString().

◆ Data2

unsigned short edm::Guid::Data2

Definition at line 26 of file Guid.h.

Referenced by fromString(), init(), operator=(), operator==(), and toString().

◆ Data3

unsigned short edm::Guid::Data3

Definition at line 27 of file Guid.h.

Referenced by fromString(), init(), operator=(), operator==(), and toString().

◆ Data4

unsigned char edm::Guid::Data4[8]

Definition at line 28 of file Guid.h.

Referenced by fromString(), init(), operator=(), operator==(), and toString().

edm::source
static const std::string source("source")
edm::bufSize
static const int bufSize
Definition: Guid.cc:23
mps_fire.i
i
Definition: mps_fire.py:355
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
data-class-funcs.q
q
Definition: data-class-funcs.py:169
cms::cuda::assert
assert(be >=bs)
edm::Guid::Data1
unsigned int Data1
Definition: Guid.h:25
edm::fmt_Guid
static char const * fmt_Guid
Definition: Guid.cc:21
edm::Guid::Data3
unsigned short Data3
Definition: Guid.h:27
alignCSCRings.s
s
Definition: alignCSCRings.py:92
edm::Guid::operator==
bool operator==(Guid const &g) const
Equality operator.
Definition: Guid.h:56
edm::Guid::fromString
Guid const & fromString(std::string const &s)
Automatic conversion to string representation.
Definition: Guid.cc:60
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
edm::Guid::Data4
unsigned char Data4[8]
Definition: Guid.h:28
edm::Guid::Data2
unsigned short Data2
Definition: Guid.h:26
runonSM.text
text
Definition: runonSM.py:43
hltrates_dqm_sourceclient-live_cfg.offset
offset
Definition: hltrates_dqm_sourceclient-live_cfg.py:82
edm::Guid::init
void init()
initialize a new Guid
Definition: Guid.cc:26
d1
static constexpr float d1
Definition: L1EGammaCrystalsEmulatorProducer.cc:84
g
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4