CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: typelookup.h,v 1.2 2010/01/25 23:17:59 chrjones Exp $
42 //
43 
44 // system include files
45 #include <typeinfo>
46 #include <utility>
47 
48 // user include files
49 
50 namespace edm {
51  class TypeIDBase;
52 
53  namespace typelookup
54  {
58  std::pair<const char*, const std::type_info*> findType(const char* iClassName);
59 
62  template <typename T>
63  const char* className();
64 
69  template <typename T>
70  const std::type_info& classTypeInfo();
71 
75  class NameRegistrar {
76  public:
77  NameRegistrar(const char* iTypeName,const std::type_info& iInfo);
78  };
79 
80  }
81 }
82 
83 #define TYPELOOKUP_METHODS(Tname) \
84 namespace edm { namespace typelookup { \
85 template<> const char* className< Tname >() \
86 { return #Tname ; } \
87 template<> const std::type_info& classTypeInfo< Tname > () \
88 { return typeid( Tname ); } } }
89 
90 
91 #define EDM_TYPELOOKUP_SYM(x,y) EDM_TYPELOOKUP_SYM2(x,y)
92 #define EDM_TYPELOOKUP_SYM2(x,y) x ## y
93 
94 #define DEFINE_TYPELOOKUP_REGISTRATION(type) \
95 static edm::typelookup::NameRegistrar EDM_TYPELOOKUP_SYM(s_register , __LINE__ ) (edm::typelookup::className<type>(),typeid(type))
96 
97 #define TYPELOOKUP_DATA_REG(_dataclass_) TYPELOOKUP_METHODS(_dataclass_) \
98 DEFINE_TYPELOOKUP_REGISTRATION(_dataclass_)
99 
100 
101 #endif
std::pair< const char *, const std::type_info * > findType(const char *iClassName)
Definition: typelookup.cc:51
NameRegistrar(const char *iTypeName, const std::type_info &iInfo)
Definition: typelookup.cc:44
const std::type_info & classTypeInfo()
const char * className()