File indexing completed on 2021-02-14 13:27:43
0001 #ifndef FWCore_Framework_ConsumesCollector_h
0002 #define FWCore_Framework_ConsumesCollector_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #include "FWCore/Framework/interface/EDConsumerBase.h"
0033 #include "FWCore/Utilities/interface/propagate_const.h"
0034
0035
0036 namespace edm {
0037 class EDConsumerBase;
0038 template <Transition TR>
0039 class ConsumesCollectorESAdaptor;
0040 template <Transition TR>
0041 class ConsumesCollectorWithTagESAdaptor;
0042 template <BranchType B>
0043 class ConsumesCollectorAdaptor;
0044
0045 class ConsumesCollector {
0046 public:
0047 ConsumesCollector() = delete;
0048 ConsumesCollector(ConsumesCollector const&);
0049 ConsumesCollector(ConsumesCollector&&) = default;
0050 ConsumesCollector& operator=(ConsumesCollector const&);
0051 ConsumesCollector& operator=(ConsumesCollector&&) = default;
0052
0053
0054 template <typename ProductType, BranchType B = InEvent>
0055 EDGetTokenT<ProductType> consumes(edm::InputTag const& tag) {
0056 return m_consumer->consumes<ProductType, B>(tag);
0057 }
0058
0059 template <BranchType B = InEvent>
0060 [[nodiscard]] ConsumesCollectorAdaptor<B> consumes(edm::InputTag tag) {
0061 return ConsumesCollectorAdaptor<B>(*this, std::move(tag));
0062 }
0063
0064 EDGetToken consumes(const TypeToGet& id, edm::InputTag const& tag) { return m_consumer->consumes(id, tag); }
0065
0066 template <BranchType B>
0067 EDGetToken consumes(TypeToGet const& id, edm::InputTag const& tag) {
0068 return m_consumer->consumes<B>(id, tag);
0069 }
0070
0071 template <typename ProductType, BranchType B = InEvent>
0072 EDGetTokenT<ProductType> mayConsume(edm::InputTag const& tag) {
0073 return m_consumer->mayConsume<ProductType, B>(tag);
0074 }
0075
0076 EDGetToken mayConsume(const TypeToGet& id, edm::InputTag const& tag) { return m_consumer->mayConsume(id, tag); }
0077
0078 template <BranchType B>
0079 EDGetToken mayConsume(const TypeToGet& id, edm::InputTag const& tag) {
0080 return m_consumer->mayConsume<B>(id, tag);
0081 }
0082
0083 template <typename ProductType, BranchType B = InEvent>
0084 void consumesMany() {
0085 m_consumer->consumesMany<ProductType, B>();
0086 }
0087
0088 void consumesMany(const TypeToGet& id) { m_consumer->consumesMany(id); }
0089
0090 template <BranchType B>
0091 void consumesMany(const TypeToGet& id) {
0092 m_consumer->consumesMany<B>(id);
0093 }
0094
0095
0096 template <typename ESProduct, typename ESRecord, Transition Tr = Transition::Event>
0097 auto esConsumes() {
0098 return esConsumes<ESProduct, ESRecord, Tr>(ESInputTag{});
0099 }
0100
0101 template <typename ESProduct, typename ESRecord, Transition Tr = Transition::Event>
0102 auto esConsumes(ESInputTag const& tag) {
0103 return m_consumer->esConsumes<ESProduct, ESRecord, Tr>(tag);
0104 }
0105
0106 template <typename ESProduct, Transition Tr = Transition::Event>
0107 auto esConsumes(eventsetup::EventSetupRecordKey const& key, ESInputTag const& tag) {
0108 return m_consumer->esConsumes<ESProduct, Tr>(key, tag);
0109 }
0110
0111 template <Transition Tr = Transition::Event>
0112 [[nodiscard]] constexpr auto esConsumes() noexcept {
0113 return ConsumesCollectorESAdaptor<Tr>(*this);
0114 }
0115
0116 template <Transition Tr = Transition::Event>
0117 [[nodiscard]] auto esConsumes(ESInputTag tag) noexcept {
0118 return ConsumesCollectorWithTagESAdaptor<Tr>(*this, std::move(tag));
0119 }
0120
0121 private:
0122
0123 friend class EDConsumerBase;
0124
0125 ConsumesCollector(EDConsumerBase* iConsumer) : m_consumer(iConsumer) {}
0126
0127
0128 edm::propagate_const<EDConsumerBase*> m_consumer;
0129 };
0130
0131 template <Transition TR>
0132 class ConsumesCollectorESAdaptor {
0133 public:
0134 template <typename TYPE, typename REC>
0135 ESGetToken<TYPE, REC> consumes() {
0136 return m_consumer.template esConsumes<TYPE, REC, TR>();
0137 }
0138
0139 private:
0140
0141 friend class ConsumesCollector;
0142
0143 explicit ConsumesCollectorESAdaptor(ConsumesCollector iBase) : m_consumer(std::move(iBase)) {}
0144
0145 ConsumesCollector m_consumer;
0146 };
0147
0148 template <Transition TR>
0149 class ConsumesCollectorWithTagESAdaptor {
0150 public:
0151 template <typename TYPE, typename REC>
0152 ESGetToken<TYPE, REC> consumes() {
0153 return m_consumer.template esConsumes<TYPE, REC, TR>(m_tag);
0154 }
0155
0156 private:
0157
0158 friend class ConsumesCollector;
0159
0160 ConsumesCollectorWithTagESAdaptor(ConsumesCollector iBase, ESInputTag iTag)
0161 : m_consumer(std::move(iBase)), m_tag(std::move(iTag)) {}
0162
0163 ConsumesCollector m_consumer;
0164 ESInputTag const m_tag;
0165 };
0166
0167 template <BranchType B>
0168 class ConsumesCollectorAdaptor {
0169 public:
0170 template <typename TYPE>
0171 EDGetTokenT<TYPE> consumes() {
0172 return m_consumer.template consumes<TYPE, B>(m_tag);
0173 }
0174
0175 private:
0176
0177 friend class ConsumesCollector;
0178
0179 ConsumesCollectorAdaptor(ConsumesCollector iBase, edm::InputTag iTag) : m_consumer(iBase), m_tag(std::move(iTag)) {}
0180
0181 ConsumesCollector m_consumer;
0182 edm::InputTag const m_tag;
0183 };
0184
0185 }
0186
0187 #endif