Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:29:20

0001 #ifndef FWCore_Utilities_TypeID_h
0002 #define FWCore_Utilities_TypeID_h
0003 
0004 /*----------------------------------------------------------------------
0005   
0006 TypeID: A unique identifier for a C++ type.
0007 
0008 The identifier is unique within an entire program, but can not be
0009 persisted across invocations of the program.
0010 
0011 ----------------------------------------------------------------------*/
0012 #include <iosfwd>
0013 #include <typeinfo>
0014 #include <string>
0015 #include "FWCore/Utilities/interface/TypeIDBase.h"
0016 
0017 namespace edm {
0018   bool stripTemplate(std::string& theName);
0019 
0020   std::string stripNamespace(std::string const& theName);
0021 
0022   class TypeID : private TypeIDBase {
0023   public:
0024     TypeID() : TypeIDBase() {}
0025 
0026     explicit TypeID(std::type_info const& t) : TypeIDBase(t) {}
0027 
0028     template <typename T>
0029     explicit TypeID(T const& t) : TypeIDBase(typeid(t)) {}
0030 
0031     // Print out the name of the type, using the dictionary class name.
0032     void print(std::ostream& os) const;
0033 
0034     std::string const& className() const;
0035 
0036     std::string userClassName() const;
0037 
0038     std::string friendlyClassName() const;
0039 
0040     explicit operator bool() const;
0041 
0042     using TypeIDBase::name;
0043 
0044     bool operator<(TypeID const& b) const { return this->TypeIDBase::operator<(b); }
0045 
0046     bool operator==(TypeID const& b) const { return this->TypeIDBase::operator==(b); }
0047 
0048     using TypeIDBase::typeInfo;
0049 
0050   private:
0051   };
0052 
0053   inline bool operator>(TypeID const& a, TypeID const& b) { return b < a; }
0054 
0055   inline bool operator!=(TypeID const& a, TypeID const& b) { return !(a == b); }
0056 
0057   std::ostream& operator<<(std::ostream& os, TypeID const& id);
0058 }  // namespace edm
0059 #endif