CMS 3D CMS Logo

typelookup.h
Go to the documentation of this file.
1 #ifndef FWCore_Utilities_typelookup_h
2 #define FWCore_Utilities_typelookup_h
3 // -*- C++ -*-
4 //
5 // Package: Utilities
6 // Class : typelookup
7 //
38 //
39 // Original Author: Chris Jones
40 // Created: Wed Jan 20 14:26:21 CST 2010
41 //
42 
43 // system include files
44 #include <typeinfo>
45 #include <utility>
46 
47 // user include files
48 
49 namespace edm {
50  class TypeIDBase;
51 
52  namespace typelookup {
56  std::pair<const char*, const std::type_info*> findType(const char* iClassName);
57 
60  template <typename T>
61  const char* className();
62 
67  template <typename T>
68  const std::type_info& classTypeInfo();
69 
73  class NameRegistrar {
74  public:
75  NameRegistrar(const char* iTypeName, const std::type_info& iInfo);
76  };
77 
78  } // namespace typelookup
79 } // namespace edm
80 
81 #define TYPELOOKUP_METHODS(Tname) \
82  namespace edm { \
83  namespace typelookup { \
84  template <> \
85  const char* className<Tname>() { \
86  return #Tname; \
87  } \
88  template <> \
89  const std::type_info& classTypeInfo<Tname>() { \
90  return typeid(Tname); \
91  } \
92  } \
93  }
94 
95 #define EDM_TYPELOOKUP_SYM(x, y) EDM_TYPELOOKUP_SYM2(x, y)
96 #define EDM_TYPELOOKUP_SYM2(x, y) x##y
97 
98 #define DEFINE_TYPELOOKUP_REGISTRATION(type) \
99  static const edm::typelookup::NameRegistrar EDM_TYPELOOKUP_SYM(s_register, __LINE__)( \
100  edm::typelookup::className<type>(), typeid(type))
101 
102 #define TYPELOOKUP_DATA_REG(_dataclass_) \
103  TYPELOOKUP_METHODS(_dataclass_) \
104  DEFINE_TYPELOOKUP_REGISTRATION(_dataclass_)
105 
106 #endif
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:69
NameRegistrar(const char *iTypeName, const std::type_info &iInfo)
Definition: typelookup.cc:65
const std::type_info & classTypeInfo()
HLT enums.
const char * className()