CMS 3D CMS Logo

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

#include <POOLCore/Guid.h>

Public Member Functions

Guid const & fromBinary (std::string const &s)
 conversion from binary string representation More...
 
Guid const & fromString (std::string const &s)
 conversion from formatted string representation More...
 
 Guid ()
 Standard constructor (With initializaton) More...
 
 Guid (bool usetime)
 Standard constructor (With initialization) More...
 
 Guid (char const *s, bool binary=false)
 Constructor for Guid from char*. More...
 
 Guid (std::string const &s, bool binary=false)
 Constructor for Guid from string. More...
 
 Guid (Guid const &c)
 Copy constructor. 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...
 
std::string const toBinary () const
 conversion to binary string reprentation More...
 
std::string const toString () const
 conversion to formatted string reprentation More...
 

Static Public Member Functions

static bool isValidString (std::string const &s)
 

Private Member Functions

void init (bool usetime=false)
 initialize a new Guid More...
 

Private Attributes

uuid_t data_
 

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

Simplified by Dan Riley for CMS to use standard libuuid functions

Definition at line 26 of file Guid.h.

Constructor & Destructor Documentation

◆ Guid() [1/5]

edm::Guid::Guid ( )
inline

Standard constructor (With initializaton)

Definition at line 29 of file Guid.h.

References init().

29 { init(); }
void init(bool usetime=false)
initialize a new Guid
Definition: Guid.cc:18

◆ Guid() [2/5]

edm::Guid::Guid ( bool  usetime)
inlineexplicit

Standard constructor (With initialization)

Definition at line 31 of file Guid.h.

References init().

31 { init(usetime); }
void init(bool usetime=false)
initialize a new Guid
Definition: Guid.cc:18

◆ Guid() [3/5]

edm::Guid::Guid ( char const *  s,
bool  binary = false 
)
inlineexplicit

Constructor for Guid from char*.

Definition at line 33 of file Guid.h.

References fromBinary(), fromString(), and alignCSCRings::s.

33 { binary ? fromBinary(s) : fromString(s); }
Guid const & fromBinary(std::string const &s)
conversion from binary string representation
Definition: Guid.cc:32
Guid const & fromString(std::string const &s)
conversion from formatted string representation
Definition: Guid.cc:45

◆ Guid() [4/5]

edm::Guid::Guid ( std::string const &  s,
bool  binary = false 
)
inlineexplicit

Constructor for Guid from string.

Definition at line 35 of file Guid.h.

References fromBinary(), fromString(), and alignCSCRings::s.

35 { binary ? fromBinary(s) : fromString(s); }
Guid const & fromBinary(std::string const &s)
conversion from binary string representation
Definition: Guid.cc:32
Guid const & fromString(std::string const &s)
conversion from formatted string representation
Definition: Guid.cc:45

◆ Guid() [5/5]

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

Copy constructor.

Definition at line 37 of file Guid.h.

References HltBtagPostValidation_cff::c.

Member Function Documentation

◆ fromBinary()

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

conversion from binary string representation

Definition at line 32 of file Guid.cc.

References cms::cuda::assert(), data_, and edm::source().

Referenced by Guid().

32  {
33  assert(source.size() == sizeof(data_));
34  std::memcpy(data_, source.data(), sizeof(data_));
35  return *this;
36  }
uuid_t data_
Definition: Guid.h:70
static std::string const source("source")
assert(be >=bs)

◆ fromString()

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

conversion from formatted string representation

Definition at line 45 of file Guid.cc.

References cms::cuda::assert(), data_, submitPVResolutionJobs::err, and edm::source().

Referenced by Guid().

45  {
46  auto err = ::uuid_parse(source.c_str(), data_);
47  assert(err == 0);
48  return *this;
49  }
uuid_t data_
Definition: Guid.h:70
static std::string const source("source")
assert(be >=bs)

◆ init()

void edm::Guid::init ( bool  usetime = false)
private

initialize a new Guid

Initialize a new Guid.

Definition at line 18 of file Guid.cc.

References data_.

Referenced by Guid().

18  {
19  if (usetime) {
20  ::uuid_generate_time(data_);
21  } else {
22  // uuid_generate() defaults to uuid_generate_random() if /dev/urandom
23  // is available; if /dev/urandom is not available, then it is better
24  // to let uuid_generate() choose the best fallback rather than forcing
25  // use of an inferior source of randomness
26  ::uuid_generate(data_);
27  }
28  }
uuid_t data_
Definition: Guid.h:70

◆ isValidString()

bool edm::Guid::isValidString ( std::string const &  s)
static

Definition at line 51 of file Guid.cc.

References submitPVResolutionJobs::err, edm::source(), and createJobs::tmp.

Referenced by edm::isValidGlobalIdentifier().

51  {
52  uuid_t tmp;
53  auto err = ::uuid_parse(source.c_str(), tmp);
54  return err == 0;
55  }
static std::string const source("source")
tmp
align.sh
Definition: createJobs.py:716

◆ operator!=()

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

Non-equality operator.

Definition at line 55 of file Guid.h.

References operator==().

55 { return !(this->operator==(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
bool operator==(Guid const &g) const
Equality operator.
Definition: Guid.h:48

◆ operator<()

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

Smaller operator.

Definition at line 57 of file Guid.cc.

References data_, and g.

57 { return ::uuid_compare(data_, g.data_) < 0; }
uuid_t data_
Definition: Guid.h:70
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

◆ operator=()

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

Assignment operator.

Definition at line 39 of file Guid.h.

References data_, and g.

39  {
40  if (this != &g) {
41  ::uuid_copy(data_, g.data_);
42  }
43  return *this;
44  }
uuid_t data_
Definition: Guid.h:70
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

◆ operator==()

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

Equality operator.

Definition at line 48 of file Guid.h.

References data_, and g.

Referenced by operator!=().

48  {
49  if (this != &g) {
50  return ::uuid_compare(data_, g.data_) == 0;
51  }
52  return true;
53  }
uuid_t data_
Definition: Guid.h:70
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

◆ toBinary()

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

conversion to binary string reprentation

Definition at line 30 of file Guid.cc.

References data_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edm::createGlobalIdentifier().

30 { return std::string(reinterpret_cast<const char*>(data_), sizeof(data_)); }
uuid_t data_
Definition: Guid.h:70

◆ toString()

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

conversion to formatted string reprentation

Definition at line 38 of file Guid.cc.

References data_, MillePedeFileConverter_cfg::out, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by edm::createGlobalIdentifier().

38  {
39  char out[UUID_STR_LEN];
40  ::uuid_unparse(data_, out);
41  return std::string(out);
42  }
uuid_t data_
Definition: Guid.h:70

Member Data Documentation

◆ data_

uuid_t edm::Guid::data_
private

Definition at line 70 of file Guid.h.

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