File indexing completed on 2024-04-06 12:12:01
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
0084 template <typename ESProduct, typename ESRecord, Transition Tr = Transition::Event>
0085 auto esConsumes() {
0086 return esConsumes<ESProduct, ESRecord, Tr>(ESInputTag{});
0087 }
0088
0089 template <typename ESProduct, typename ESRecord, Transition Tr = Transition::Event>
0090 auto esConsumes(ESInputTag const& tag) {
0091 return m_consumer->esConsumes<ESProduct, ESRecord, Tr>(tag);
0092 }
0093
0094 template <typename ESProduct, Transition Tr = Transition::Event>
0095 auto esConsumes(eventsetup::EventSetupRecordKey const& key, ESInputTag const& tag) {
0096 return m_consumer->esConsumes<ESProduct, Tr>(key, tag);
0097 }
0098
0099 template <Transition Tr = Transition::Event>
0100 [[nodiscard]] constexpr auto esConsumes() noexcept {
0101 return ConsumesCollectorESAdaptor<Tr>(*this);
0102 }
0103
0104 template <Transition Tr = Transition::Event>
0105 [[nodiscard]] auto esConsumes(ESInputTag tag) noexcept {
0106 return ConsumesCollectorWithTagESAdaptor<Tr>(*this, std::move(tag));
0107 }
0108
0109 private:
0110
0111 friend class EDConsumerBase;
0112
0113 ConsumesCollector(EDConsumerBase* iConsumer) : m_consumer(iConsumer) {}
0114
0115
0116 edm::propagate_const<EDConsumerBase*> m_consumer;
0117 };
0118
0119 template <Transition TR>
0120 class ConsumesCollectorESAdaptor {
0121 public:
0122 template <typename TYPE, typename REC>
0123 ESGetToken<TYPE, REC> consumes() {
0124 return m_consumer.template esConsumes<TYPE, REC, TR>();
0125 }
0126
0127 private:
0128
0129 friend class ConsumesCollector;
0130
0131 explicit ConsumesCollectorESAdaptor(ConsumesCollector iBase) : m_consumer(std::move(iBase)) {}
0132
0133 ConsumesCollector m_consumer;
0134 };
0135
0136 template <Transition TR>
0137 class ConsumesCollectorWithTagESAdaptor {
0138 public:
0139 template <typename TYPE, typename REC>
0140 ESGetToken<TYPE, REC> consumes() {
0141 return m_consumer.template esConsumes<TYPE, REC, TR>(m_tag);
0142 }
0143
0144 private:
0145
0146 friend class ConsumesCollector;
0147
0148 ConsumesCollectorWithTagESAdaptor(ConsumesCollector iBase, ESInputTag iTag)
0149 : m_consumer(std::move(iBase)), m_tag(std::move(iTag)) {}
0150
0151 ConsumesCollector m_consumer;
0152 ESInputTag const m_tag;
0153 };
0154
0155 template <BranchType B>
0156 class ConsumesCollectorAdaptor {
0157 public:
0158 template <typename TYPE>
0159 EDGetTokenT<TYPE> consumes() {
0160 return m_consumer.template consumes<TYPE, B>(m_tag);
0161 }
0162
0163 private:
0164
0165 friend class ConsumesCollector;
0166
0167 ConsumesCollectorAdaptor(ConsumesCollector iBase, edm::InputTag iTag) : m_consumer(iBase), m_tag(std::move(iTag)) {}
0168
0169 ConsumesCollector m_consumer;
0170 edm::InputTag const m_tag;
0171 };
0172
0173 }
0174
0175 #endif