CMS 3D CMS Logo

HCTypeTag.h
Go to the documentation of this file.
1 #ifndef Framework_HCTypeTag_h
2 #define Framework_HCTypeTag_h
3 // -*- C++ -*-
4 //
5 // Package: HeteroContainer
6 // Module: HCTypeTag
7 //
8 // Description: Base class for Tags that can specify a class Type.
9 //
10 // Usage:
11 // This class is used to specify the class Type of another class.
12 // To build a TypeTag you must call the method TypeTag::make<T>()
13 //
14 // Example
15 // //Make a TypeTag for class Foo
16 // HCTypeTag fooTag = HCTypeTag::make< Foo>();
17 //
18 // Author: Chris D. Jones
19 // Created: Sun Sep 20 15:05:10 EDT 1998
20 //
21 //
22 
23 // user include files
26 
27 // system include files
28 #include <string>
29 #include <typeinfo>
30 
31 // forward declarations
32 namespace edm {
33  namespace eventsetup {
34  namespace heterocontainer {
35 
37 
38  class HCTypeTag : public TypeIDBase {
39  public:
40  HCTypeTag() = default;
41 
42  // ---------- member functions ---------------------------
43 
44  // ---------- const member functions ---------------------
45  std::type_info const& value() const { return typeInfo(); }
46  char const* name() const { return m_name; }
47 
49  static HCTypeTag findType(char const* iTypeName);
50  static HCTypeTag findType(std::string const& iTypeName);
51 
52  template <typename T>
53  static HCTypeTag make() {
54  return HCTypeTag(typelookup::classTypeInfo<T>(), typelookup::className<T>());
55  }
56 
57  protected:
58  // ---------- protected member functions -----------------
59  HCTypeTag(std::type_info const& iValue, char const* iName) : TypeIDBase(iValue), m_name(iName) {}
60 
61  HCTypeTag(TypeIDBase const& iValue, const char* iName) : TypeIDBase(iValue), m_name(iName) {}
62 
63  private:
64  char const* m_name{""};
65  };
66  } // namespace heterocontainer
67  } // namespace eventsetup
68 } // namespace edm
69 #define HCTYPETAG_HELPER_METHODS(_dataclass_) TYPELOOKUP_METHODS(_dataclass_)
70 
71 #define DEFINE_HCTYPETAG_REGISTRATION(type) DEFINE_TYPELOOKUP_REGISTRATION(type)
72 #endif
static HCTypeTag findType(char const *iTypeName)
find a type based on the types name, if not found will return default HCTypeTag
const std::type_info & typeInfo() const
Definition: TypeIDBase.h:50
HCTypeTag(TypeIDBase const &iValue, const char *iName)
Definition: HCTypeTag.h:61
HLT enums.
HCTypeTag(std::type_info const &iValue, char const *iName)
Definition: HCTypeTag.h:59
std::type_info const & value() const
Definition: HCTypeTag.h:45
const char * className()