Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:03

0001 #ifndef Framework_HCTypeTag_h
0002 #define Framework_HCTypeTag_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     HeteroContainer
0006 // Module:      HCTypeTag
0007 //
0008 // Description: Base class for Tags that can specify a class Type.
0009 //
0010 // Usage:
0011 //    This class is used to specify the class Type of another class.
0012 //    To build a TypeTag you must call the method TypeTag::make<T>()
0013 //
0014 //    Example
0015 //       //Make a TypeTag for class Foo
0016 //       HCTypeTag fooTag = HCTypeTag::make< Foo>();
0017 //
0018 // Author:      Chris D. Jones
0019 // Created:     Sun Sep 20 15:05:10 EDT 1998
0020 //
0021 //
0022 
0023 // user include files
0024 #include "FWCore/Utilities/interface/TypeIDBase.h"
0025 #include "FWCore/Utilities/interface/typelookup.h"
0026 
0027 // system include files
0028 #include <string>
0029 #include <typeinfo>
0030 
0031 // forward declarations
0032 namespace edm {
0033   namespace eventsetup {
0034     namespace heterocontainer {
0035 
0036       using typelookup::className;
0037 
0038       class HCTypeTag : public TypeIDBase {
0039       public:
0040         HCTypeTag() = default;
0041 
0042         // ---------- member functions ---------------------------
0043 
0044         // ---------- const member functions ---------------------
0045         std::type_info const& value() const { return typeInfo(); }
0046         char const* name() const { return m_name; }
0047 
0048         ///find a type based on the types name, if not found will return default HCTypeTag
0049         static HCTypeTag findType(char const* iTypeName);
0050         static HCTypeTag findType(std::string const& iTypeName);
0051 
0052         template <typename T>
0053         static HCTypeTag make() {
0054           return HCTypeTag(typelookup::classTypeInfo<T>(), typelookup::className<T>());
0055         }
0056 
0057       protected:
0058         // ---------- protected member functions -----------------
0059         HCTypeTag(std::type_info const& iValue, char const* iName) : TypeIDBase(iValue), m_name(iName) {}
0060 
0061         HCTypeTag(TypeIDBase const& iValue, const char* iName) : TypeIDBase(iValue), m_name(iName) {}
0062 
0063       private:
0064         char const* m_name{""};
0065       };
0066     }  // namespace heterocontainer
0067   }    // namespace eventsetup
0068 }  // namespace edm
0069 #define HCTYPETAG_HELPER_METHODS(_dataclass_) TYPELOOKUP_METHODS(_dataclass_)
0070 
0071 #define DEFINE_HCTYPETAG_REGISTRATION(type) DEFINE_TYPELOOKUP_REGISTRATION(type)
0072 #endif