CMS 3D CMS Logo

Public Member Functions | Public Attributes | Private Member Functions

edm::Guid Class Reference

#include <POOLCore/Guid.h>

List of all members.

Public Member Functions

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

Public Attributes

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

Private Member Functions

void init ()
 initialize a new Guid

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

edm::Guid::Guid ( ) [inline]

Standard constructor (With initializaton)

Definition at line 31 of file Guid.h.

References init().

{ init(); }
edm::Guid::Guid ( bool  ) [inline, explicit]

Standard constructor (With initialization)

Definition at line 33 of file Guid.h.

References init().

{ init(); }
edm::Guid::Guid ( char const *  s) [inline, explicit]

Constructor for Guid from char*.

Definition at line 35 of file Guid.h.

References fromString().

{ fromString(s);          }
edm::Guid::Guid ( std::string const &  s) [inline, explicit]

Constructor for Guid from string.

Definition at line 37 of file Guid.h.

References fromString().

{ fromString(s);          }
edm::Guid::Guid ( Guid const &  c) [inline]

Copy constructor.

Definition at line 39 of file Guid.h.

References trackerHits::c.

{ *this = c;              }

Member Function Documentation

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

Automatic conversion to string representation.

Definition at line 52 of file Guid.cc.

References Data1, Data2, Data3, Data4, and evf::evtn::offset().

Referenced by Guid().

                                                      {
    char const dash = '-';
    size_t const iSize = 8;
    size_t const sSize = 4;
    size_t const cSize = 2;
    size_t offset = 0;
    Data1 = strtol(source.substr(offset, iSize).c_str(), 0, 16);
    offset += iSize;
    assert(dash == source[offset++]); 
    Data2 = strtol(source.substr(offset, sSize).c_str(), 0, 16);
    offset += sSize;
    assert(dash == source[offset++]); 
    Data3 = strtol(source.substr(offset, sSize).c_str(), 0, 16);
    offset += sSize;
    assert(dash == source[offset++]); 
    Data4[0] = strtol(source.substr(offset, cSize).c_str(), 0, 16);
    offset += cSize;
    Data4[1] = strtol(source.substr(offset, cSize).c_str(), 0, 16);
    offset += cSize;
    assert(dash == source[offset++]);
    Data4[2] = strtol(source.substr(offset, cSize).c_str(), 0, 16);
    offset += cSize;
    Data4[3] = strtol(source.substr(offset, cSize).c_str(), 0, 16);
    offset += cSize;
    Data4[4] = strtol(source.substr(offset, cSize).c_str(), 0, 16);
    offset += cSize;
    Data4[5] = strtol(source.substr(offset, cSize).c_str(), 0, 16);
    offset += cSize;
    Data4[6] = strtol(source.substr(offset, cSize).c_str(), 0, 16);
    offset += cSize;
    Data4[7] = strtol(source.substr(offset, cSize).c_str(), 0, 16);
    offset += cSize;
    assert(source.size() == offset);
    return *this;
  }
void edm::Guid::init ( void  ) [private]

initialize a new Guid

Initialize a new Guid.

Definition at line 27 of file Guid.cc.

References Data1, Data2, Data3, Data4, and i.

Referenced by Guid().

                    {
    uuid_t me_;
    ::uuid_generate_time(me_);
    unsigned int*   d1 = reinterpret_cast<unsigned int*>(me_);
    unsigned short* d2 = reinterpret_cast<unsigned short*>(me_+4);
    unsigned short* d3 = reinterpret_cast<unsigned short*>(me_+6);
    Data1 = *d1;
    Data2 = *d2;
    Data3 = *d3;
    for(int i = 0; i < 8; ++i){
      Data4[i] = me_[i + 8];
    }
  }
bool edm::Guid::operator!= ( Guid const &  g) const [inline]

Non-equality operator.

Definition at line 68 of file Guid.h.

References operator==().

                                         {
      return !(this->operator == (g));
    }
bool edm::Guid::operator< ( Guid const &  g) const

Smaller operator.

Definition at line 88 of file Guid.cc.

References Data1.

                                          {
    return ::memcmp(&g.Data1, &Data1, 16) < 0;
  }
Guid& edm::Guid::operator= ( Guid const &  g) [inline]

Assignment operator.

Definition at line 41 of file Guid.h.

References compareJSON::const, Data1, Data2, Data3, Data4, AlCaHLTBitMon_ParallelJobs::p, and lumiQueryAPI::q.

                                   {
      if (this != &g)  {
        Data1 = g.Data1;
        Data2 = g.Data2;
        Data3 = g.Data3;
        unsigned int      * p = reinterpret_cast<unsigned int *>(&Data4[0]);
        unsigned int const* q = reinterpret_cast<unsigned int const*>(&g.Data4[0]);
        *(p+1) = *(q+1);
        *p     = *q;
      }
      return *this;
    }
bool edm::Guid::operator== ( Guid const &  g) const [inline]

Equality operator.

Definition at line 56 of file Guid.h.

References compareJSON::const, Data1, Data2, Data3, Data4, AlCaHLTBitMon_ParallelJobs::p, and lumiQueryAPI::q.

Referenced by operator!=().

                                         {
      if (this != & g)  {
        if (Data1 != g.Data1) return false;
        if (Data2 != g.Data2) return false;
        if (Data3 != g.Data3) return false;
        unsigned int const* p = reinterpret_cast<unsigned int const*>(&Data4[0]);
        unsigned int const* q = reinterpret_cast<unsigned int const*>(&g.Data4[0]);
        return *p == *q && *(p+1) == *(q+1);
      }
      return true;
    }
std::string const edm::Guid::toString ( ) const

Automatic conversion from string reprentation.

Definition at line 41 of file Guid.cc.

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

Referenced by FUShmDQMOutputService::FUShmDQMOutputService(), and edm::FUShmOutputModule::FUShmOutputModule().

                                       {
    char text[bufSize];
    ::snprintf(text, sizeof(text),
              fmt_Guid,
              Data1, Data2, Data3,
              Data4[0], Data4[1], Data4[2], Data4[3],
              Data4[4], Data4[5], Data4[6], Data4[7]);
    return text;
  }

Member Data Documentation

unsigned int edm::Guid::Data1

Definition at line 25 of file Guid.h.

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

unsigned short edm::Guid::Data2

Definition at line 26 of file Guid.h.

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

unsigned short edm::Guid::Data3

Definition at line 27 of file Guid.h.

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

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

Definition at line 28 of file Guid.h.

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