CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  {
31 
32  public:
33  struct Def { };
34 
36  t_(&(typeid(Def)))
37  { }
38 
39  explicit TypeIDBase(const std::type_info& t) :
40  t_(&t)
41  { }
42 
43  explicit TypeIDBase(const std::type_info* t) :
44  t_(t == 0 ? &(typeid(Def)) : t)
45  { }
46 
47  // ---------- const member functions ---------------------
48 
52  const char* name() const { return t_->name(); }
53 
54  bool operator<(const TypeIDBase& b) const { return t_->before(*(b.t_)); }
55  bool operator==(const TypeIDBase& b) const { return (*t_) == *(b.t_); }
56 
57  protected:
58  const std::type_info& typeInfo() const {return *t_;}
59 
60  private:
61 
62  //const TypeIDBase& operator=(const TypeIDBase&); // stop default
63 
64  // ---------- member data --------------------------------
65  //NOTE: since the compiler generates the type_info's and they have a lifetime
66  // good for the entire application, we do not have to delete it
67  // We also are using a pointer rather than a reference so that operator= will work
68  const std::type_info* t_;
69  };
70 
71  inline bool operator>(const TypeIDBase& a, const TypeIDBase& b)
72  { return b<a; }
73 
74  inline bool operator!=(const TypeIDBase& a, const TypeIDBase& b)
75  { return !(a==b); }
76 
77 }
78 
79 #endif
bool operator==(const TypeIDBase &b) const
Definition: TypeIDBase.h:55
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
const std::type_info & typeInfo() const
Definition: TypeIDBase.h:58
bool operator<(const TypeIDBase &b) const
Definition: TypeIDBase.h:54
TypeIDBase(const std::type_info &t)
Definition: TypeIDBase.h:39
const std::type_info * t_
Definition: TypeIDBase.h:68
bool operator>(View< T > const &, View< T > const &)
Definition: View.h:389
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
TypeIDBase(const std::type_info *t)
Definition: TypeIDBase.h:43
const char * name() const
Definition: TypeIDBase.h:52