CMS 3D CMS Logo

TypeIDBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_TypeIDBase_h
2 #define FWCore_Utilities_TypeIDBase_h
3 // -*- C++ -*-
4 //
5 // Package: Utilities
6 // Class : TypeIDBase
7 //
17 //
18 // Original Author: Chris Jones
19 // Created: Thu Nov 10 14:59:35 EST 2005
20 //
21 
22 // system include files
23 #include <typeinfo>
24 
25 // user include files
26 
27 // forward declarations
28 namespace edm {
29  class TypeIDBase {
30  public:
31  struct Def {};
32 
33  TypeIDBase() : t_(&(typeid(Def))) {}
34 
35  explicit TypeIDBase(const std::type_info& t) : t_(&t) {}
36 
37  explicit TypeIDBase(const std::type_info* t) : t_(t == nullptr ? &(typeid(Def)) : t) {}
38 
39  // ---------- const member functions ---------------------
40 
44  const char* name() const { return t_->name(); }
45 
46  bool operator<(const TypeIDBase& b) const { return t_->before(*(b.t_)); }
47  bool operator==(const TypeIDBase& b) const { return (*t_) == *(b.t_); }
48 
49  protected:
50  const std::type_info& typeInfo() const { return *t_; }
51 
52  private:
53  //const TypeIDBase& operator=(const TypeIDBase&); // stop default
54 
55  // ---------- member data --------------------------------
56  //NOTE: since the compiler generates the type_info's and they have a lifetime
57  // good for the entire application, we do not have to delete it
58  // We also are using a pointer rather than a reference so that operator= will work
59  const std::type_info* t_;
60  };
61 
62  inline bool operator>(const TypeIDBase& a, const TypeIDBase& b) { return b < a; }
63 
64  inline bool operator!=(const TypeIDBase& a, const TypeIDBase& b) { return !(a == b); }
65 
66 } // namespace edm
67 
68 #endif
bool operator==(const TypeIDBase &b) const
Definition: TypeIDBase.h:47
#define nullptr
const std::type_info & typeInfo() const
Definition: TypeIDBase.h:50
bool operator<(const TypeIDBase &b) const
Definition: TypeIDBase.h:46
TypeIDBase(const std::type_info &t)
Definition: TypeIDBase.h:35
const std::type_info * t_
Definition: TypeIDBase.h:59
bool operator>(View< T > const &, View< T > const &)
Definition: View.h:382
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &) noexcept
double b
Definition: hdecay.h:120
HLT enums.
double a
Definition: hdecay.h:121
TypeIDBase(const std::type_info *t)
Definition: TypeIDBase.h:37
const char * name() const
Definition: TypeIDBase.h:44