CMS 3D CMS Logo

TypeID.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_TypeID_h
2 #define FWCore_Utilities_TypeID_h
3 
4 /*----------------------------------------------------------------------
5 
6 TypeID: A unique identifier for a C++ type.
7 
8 The identifier is unique within an entire program, but can not be
9 persisted across invocations of the program.
10 
11 ----------------------------------------------------------------------*/
12 #include <iosfwd>
13 #include <typeinfo>
14 #include <string>
16 
17 namespace edm {
18  bool stripTemplate(std::string& theName);
19 
20  std::string stripNamespace(std::string const& theName);
21 
22  class TypeID : private TypeIDBase {
23  public:
24  TypeID() : TypeIDBase() {}
25 
26  explicit TypeID(std::type_info const& t) : TypeIDBase(t) {}
27 
28  template <typename T>
29  explicit TypeID(T const& t) : TypeIDBase(typeid(t)) {}
30 
31  // Print out the name of the type, using the dictionary class name.
32  void print(std::ostream& os) const;
33 
34  std::string const& className() const;
35 
36  std::string userClassName() const;
37 
39 
40  explicit operator bool() const;
41 
42  using TypeIDBase::name;
43 
44  bool operator<(TypeID const& b) const { return this->TypeIDBase::operator<(b); }
45 
46  bool operator==(TypeID const& b) const { return this->TypeIDBase::operator==(b); }
47 
49 
50  private:
51  };
52 
53  inline bool operator>(TypeID const& a, TypeID const& b) { return b < a; }
54 
55  inline bool operator!=(TypeID const& a, TypeID const& b) { return !(a == b); }
56 
57  std::ostream& operator<<(std::ostream& os, TypeID const& id);
58 } // namespace edm
59 #endif
bool operator==(const TypeIDBase &b) const
Definition: TypeIDBase.h:47
void print(std::ostream &os) const
Definition: TypeID.cc:13
const std::type_info & typeInfo() const
Definition: TypeIDBase.h:50
bool operator<(const TypeIDBase &b) const
Definition: TypeIDBase.h:46
TypeID(std::type_info const &t)
Definition: TypeID.h:26
bool operator>(View< T > const &, View< T > const &)
Definition: View.h:382
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
TypeID()
Definition: TypeID.h:24
std::string userClassName() const
Definition: TypeID.cc:54
double b
Definition: hdecay.h:120
bool operator<(TypeID const &b) const
Definition: TypeID.h:44
std::string stripNamespace(std::string const &theName)
Definition: TypeID.cc:90
HLT enums.
double a
Definition: hdecay.h:121
std::string const & className() const
Definition: TypeID.cc:43
TypeID(T const &t)
Definition: TypeID.h:29
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
long double T
bool stripTemplate(std::string &theName)
Definition: TypeID.cc:64
const char * name() const
Definition: TypeIDBase.h:44
bool operator==(TypeID const &b) const
Definition: TypeID.h:46
std::string friendlyClassName() const
Definition: TypeID.cc:62