File indexing completed on 2024-04-06 12:13:13
0001 #ifndef FWCore_Utilities_TypeToGet_h
0002 #define FWCore_Utilities_TypeToGet_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024 #include "FWCore/Utilities/interface/TypeID.h"
0025 #include "FWCore/Utilities/interface/ProductKindOfType.h"
0026
0027
0028 namespace edm {
0029 template <typename T>
0030 class View;
0031
0032 class TypeToGet {
0033 public:
0034
0035
0036
0037
0038 TypeToGet(TypeID const& iID, KindOfType iKind) : m_type(iID), m_kind(iKind) {}
0039
0040 TypeToGet() = delete;
0041
0042 TypeID const& type() const { return m_type; }
0043 KindOfType kind() const { return m_kind; }
0044
0045
0046 template <typename T>
0047 static TypeToGet make() {
0048 return TypeToGet(edm::TypeID(typeIdFor(static_cast<T*>(nullptr))), kindOfTypeFor(static_cast<T*>(nullptr)));
0049 }
0050
0051 private:
0052 template <typename T>
0053 static std::type_info const& typeIdFor(T*) {
0054 return typeid(T);
0055 }
0056
0057 template <typename T>
0058 static std::type_info const& typeIdFor(edm::View<T>*) {
0059 return typeid(T);
0060 }
0061
0062 template <typename T>
0063 static KindOfType kindOfTypeFor(T*) {
0064 return PRODUCT_TYPE;
0065 }
0066
0067 template <typename T>
0068 static KindOfType kindOfTypeFor(edm::View<T>*) {
0069 return ELEMENT_TYPE;
0070 }
0071
0072
0073 TypeID m_type;
0074 KindOfType m_kind;
0075 };
0076 }
0077
0078 #endif