Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-12 01:51:25

0001 #ifndef FWCOre_Utilities_Guid_h
0002 #define FWCOre_Utilities_Guid_h
0003 
0004 #include "uuid/uuid.h"
0005 #include <string>
0006 
0007 /*
0008  *  copied from pool
0009  */
0010 namespace edm {
0011 
0012   /** @class Guid Guid.h POOLCore/Guid.h
0013     *
0014     * Description:
0015     *
0016     * Encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
0017     * Note: This class may not have a virual destructor
0018     *
0019     * @author   M.Frank          Initial version using COM on WIN32
0020     * @author   Zhen Xie         Include DCE implementation for linux
0021     * @version  1.1
0022     * @date     03/09/2002
0023     *
0024     * Simplified by Dan Riley for CMS to use standard libuuid functions
0025     */
0026   class Guid {  // size is 16
0027   public:
0028     /// Standard constructor (With initializaton)
0029     Guid() { init(); }
0030     /// Standard constructor (With initialization)
0031     explicit Guid(bool usetime) { init(usetime); }
0032     /// Constructor for Guid from char*
0033     explicit Guid(char const* s, bool binary = false) { binary ? fromBinary(s) : fromString(s); }
0034     /// Constructor for Guid from string
0035     explicit Guid(std::string const& s, bool binary = false) { binary ? fromBinary(s) : fromString(s); }
0036     /// Copy constructor
0037     Guid(Guid const& c) { *this = c; }
0038     /// Assignment operator
0039     Guid& operator=(Guid const& g) {
0040       if (this != &g) {
0041         ::uuid_copy(data_, g.data_);
0042       }
0043       return *this;
0044     }
0045     /// Smaller operator
0046     bool operator<(Guid const& g) const;
0047     /// Equality operator
0048     bool operator==(Guid const& g) const {
0049       if (this != &g) {
0050         return ::uuid_compare(data_, g.data_) == 0;
0051       }
0052       return true;
0053     }
0054     /// Non-equality operator
0055     bool operator!=(Guid const& g) const { return !(this->operator==(g)); }
0056     /// conversion to binary string reprentation
0057     std::string const toBinary() const;
0058     /// conversion from binary string representation
0059     Guid const& fromBinary(std::string const& s);
0060     /// conversion to formatted string reprentation
0061     std::string const toString() const;
0062     /// conversion from formatted string representation
0063     Guid const& fromString(std::string const& s);
0064 
0065     static bool isValidString(std::string const& s);
0066 
0067   private:
0068     /// initialize a new Guid
0069     void init(bool usetime = false);
0070     uuid_t data_;
0071   };
0072 }  // namespace edm
0073 #endif