CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Public Attributes

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 (No initialization of data for performance reasons)
 Guid (std::string const &s)
 Constructor for Guid from string.
 Guid (bool assign)
 Standard constructor (With possible 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.

Static Public Member Functions

static void create (Guid &guid)
 Create a new Guid.
static Guid const & null ()
 NULL-Guid: static class method.

Public Attributes

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

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 (No initialization of data for performance reasons)

Definition at line 31 of file Guid.h.

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

Standard constructor (With possible initialization)

Definition at line 33 of file Guid.h.

References create().

{ if (assign) create(*this);    }
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

void edm::Guid::create ( Guid guid) [static]

Create a new Guid.

Definition at line 30 of file Guid.cc.

References debug_cff::d1, 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);
    guid.Data1 = *d1;
    guid.Data2 = *d2;
    guid.Data3 = *d3;
    for (int i = 0; i < 8; ++i){
      guid.Data4[i]=me_[i+8];
    }
  }
Guid const & edm::Guid::fromString ( std::string const &  s)

Automatic conversion to string representation.

Definition at line 53 of file Guid.cc.

References compareJSON::const, Data1, Data2, Data3, Data4, edm::fmt_Guid, L1TEmulatorMonitor_cff::p, and lumiQueryAPI::q.

Referenced by Guid().

                                                      {
    // Note: This looks funny, but the specs for sscanf formats say
    //       that the space of a pointer in the ellipsis may only be
    //       integer or short. Hence one has to reserve a bit more space
    //       otherwise the stack gets corrupted.
    unsigned char d[8];
    ::sscanf( source.c_str(), fmt_Guid, &Data1, &Data2, &Data3, 
              &Data4[0], &Data4[1], &Data4[2], &Data4[3], &d[0], &d[1], &d[2], &d[3]);
    //*(int*)&Data4[4] = *(int*)d;
    unsigned int      * p = reinterpret_cast<unsigned int *>(&Data4[4]);
    unsigned int const* q = reinterpret_cast<unsigned int const*>(&d[0]);
    *p = *q;
    return *this;
  }
Guid const & edm::Guid::null ( ) [static]

NULL-Guid: static class method.

Definition at line 25 of file Guid.cc.

References edm::clid_null().

                         {
    return clid_null;
  }
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 68 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, L1TEmulatorMonitor_cff::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, L1TEmulatorMonitor_cff::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 44 of file Guid.cc.

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

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

                                       {
    char text[128];
    ::sprintf(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 create(), fromString(), operator<(), operator=(), operator==(), and toString().

unsigned short edm::Guid::Data2

Definition at line 26 of file Guid.h.

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

unsigned short edm::Guid::Data3

Definition at line 27 of file Guid.h.

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

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

Definition at line 28 of file Guid.h.

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