CMS 3D CMS Logo

ESConsumesCollector.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ESConsumesCollector_h
2 #define FWCore_Framework_ESConsumesCollector_h
3 // -*- C++ -*-
4 //
5 // Package: FWCore/Framework
6 // Class : edm::ConsumesCollector
7 //
26 //
27 // Original Author: Kyle Knoepfel
28 // Created: Fri, 02 Oct 2018 12:44:47 GMT
29 //
30 
37 
38 #include <vector>
39 #include <memory>
40 namespace edm {
41  using ESConsumesInfo =
42  std::vector<std::tuple<edm::eventsetup::EventSetupRecordKey, edm::eventsetup::DataKey, std::string> >;
43 
45  public:
46  ESConsumesCollector() = delete;
47  ESConsumesCollector(ESConsumesCollector const&) = default;
51 
52  // ---------- member functions ---------------------------
53  template <typename Product, typename Record>
54  auto consumesFrom(ESInputTag const& tag) {
55  using namespace edm::eventsetup;
56  ESTokenIndex index{static_cast<ESTokenIndex::Value_t>(m_consumer->size())};
57  m_consumer->emplace_back(EventSetupRecordKey::makeKey<Record>(),
58  DataKey(DataKey::makeTypeTag<Product>(), tag.data().c_str()),
59  tag.module());
60  //even though m_consumer may expand, the address for
61  // name().value() remains the same since it is 'moved'.
62  return ESGetToken<Product, Record>{m_transitionID, index, std::get<1>(m_consumer->back()).name().value()};
63  }
64 
65  protected:
66  explicit ESConsumesCollector(ESConsumesInfo* const iConsumer, unsigned int iTransitionID)
67  : m_consumer{iConsumer}, m_transitionID{iTransitionID} {}
68 
69  private:
70  // ---------- member data --------------------------------
72  unsigned int m_transitionID{0};
73  };
74 
75  template <typename RECORD>
77  public:
78  ESConsumesCollectorT() = delete;
83 
84  // ---------- member functions ---------------------------
85 
86  template <typename Product>
87  auto consumes(ESInputTag const& tag) {
88  return consumesFrom<Product, RECORD>(tag);
89  }
90 
91  private:
92  //only ESProducer is allowed to make an instance of this class
93  friend class ESProducer;
94 
95  explicit ESConsumesCollectorT(ESConsumesInfo* const iConsumer, unsigned int iTransitionID)
96  : ESConsumesCollector(iConsumer, iTransitionID) {}
97  };
98 
99 } // namespace edm
100 
101 #endif
ESConsumesCollector(ESConsumesInfo *const iConsumer, unsigned int iTransitionID)
ESConsumesCollector & operator=(ESConsumesCollector const &)=default
auto consumesFrom(ESInputTag const &tag)
auto consumes(ESInputTag const &tag)
const std::string & data() const
Definition: ESInputTag.h:104
std::vector< std::tuple< edm::eventsetup::EventSetupRecordKey, edm::eventsetup::DataKey, std::string > > ESConsumesInfo
HLT enums.
ESConsumesCollectorT(ESConsumesInfo *const iConsumer, unsigned int iTransitionID)
const std::string & module() const
Definition: ESInputTag.h:99
edm::propagate_const< ESConsumesInfo * > m_consumer