CMS 3D CMS Logo

ESProducer.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ESProducer_h
2 #define FWCore_Framework_ESProducer_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : ESProducer
7 //
66 //
67 // Author: Chris Jones
68 // Created: Thu Apr 7 17:08:14 CDT 2005
69 //
70 
71 // system include files
72 #include <memory>
73 #include <string>
74 
75 // user include files
80 
86 
87 // forward declarations
88 namespace edm {
89  namespace eventsetup {
90 
92  //used by ESProducer to create the proper Decorator based on the
93  // argument type passed. The default it to just 'pass through'
94  // the argument as the decorator itself
95  template <typename T, typename TRecord, typename TDecorator>
96  inline const TDecorator& createDecoratorFrom(T*, const TRecord*, const TDecorator& iDec) {
97  return iDec;
98  }
99  } // namespace eventsetup
100 
102  public:
103  ESProducer();
104  ~ESProducer() noexcept(false) override;
105  ESProducer(const ESProducer&) = delete; // stop default
106  ESProducer const& operator=(const ESProducer&) = delete; // stop default
107 
109  ESProxyIndex const* getTokenIndices(unsigned int iIndex) const {
110  if (itemsToGetFromRecords_.empty()) {
111  return nullptr;
112  }
113  return (itemsToGetFromRecords_[iIndex].empty()) ? static_cast<ESProxyIndex const*>(nullptr)
114  : &(itemsToGetFromRecords_[iIndex].front());
115  }
116 
117  template <typename Record>
118  void updateFromMayConsumes(unsigned int iIndex, const Record& iRecord) {
119  if (itemsToGetFromRecords_.empty() or itemsToGetFromRecords_[iIndex].empty()) {
120  return;
121  }
122  auto const info = consumesInfos_[iIndex].get();
123  for (size_t i = 0; i < info->size(); ++i) {
124  auto chooserBase = (*info)[i].chooser_.get();
125  if (chooserBase) {
126  auto chooser = static_cast<eventsetup::impl::MayConsumeChooserBase<Record>*>(chooserBase);
127  itemsToGetFromRecords_[iIndex][i] = chooser->makeChoice(iRecord);
128  }
129  }
130  }
131 
132  protected:
137  template <typename T>
138  auto setWhatProduced(T* iThis, const es::Label& iLabel = {}) {
139  return setWhatProduced(iThis, &T::produce, iLabel);
140  }
141 
142  template <typename T>
143  auto setWhatProduced(T* iThis, const char* iLabel) {
144  return setWhatProduced(iThis, es::Label(iLabel));
145  }
146  template <typename T>
147  auto setWhatProduced(T* iThis, const std::string& iLabel) {
148  return setWhatProduced(iThis, es::Label(iLabel));
149  }
150 
151  template <typename T, typename TDecorator>
152  auto setWhatProduced(T* iThis, const TDecorator& iDec, const es::Label& iLabel = {}) {
153  return setWhatProduced(iThis, &T::produce, iDec, iLabel);
154  }
160  template <typename T, typename TReturn, typename TRecord>
161  auto setWhatProduced(T* iThis, TReturn (T ::*iMethod)(const TRecord&), const es::Label& iLabel = {}) {
162  return setWhatProduced(iThis, iMethod, eventsetup::CallbackSimpleDecorator<TRecord>(), iLabel);
163  }
170  template <typename T, typename TReturn, typename TRecord, typename TArg>
172  TReturn (T ::*iMethod)(const TRecord&),
173  const TArg& iDec,
174  const es::Label& iLabel = {}) {
175  const auto id = consumesInfos_.size();
178  unsigned int iovIndex = 0; // Start with 0, but later will cycle through all of them
179  auto temp = std::make_shared<CallbackType>(
180  iThis, iMethod, id, createDecoratorFrom(iThis, static_cast<const TRecord*>(nullptr), iDec));
181  auto callback =
182  std::make_shared<std::pair<unsigned int, std::shared_ptr<CallbackType>>>(iovIndex, std::move(temp));
184  static_cast<const typename eventsetup::produce::product_traits<TReturn>::type*>(nullptr),
185  static_cast<const TRecord*>(nullptr),
186  iLabel);
187  consumesInfos_.push_back(std::make_unique<ESConsumesInfo>());
188  return ESConsumesCollectorT<TRecord>(consumesInfos_.back().get(), id);
189  }
190 
191  private:
192  template <typename CallbackT, typename TList, typename TRecord>
193  void registerProducts(std::shared_ptr<std::pair<unsigned int, std::shared_ptr<CallbackT>>> iCallback,
194  const TList*,
195  const TRecord* iRecord,
196  const es::Label& iLabel) {
197  registerProduct(iCallback, static_cast<const typename TList::tail_type*>(nullptr), iRecord, iLabel);
198  registerProducts(std::move(iCallback), static_cast<const typename TList::head_type*>(nullptr), iRecord, iLabel);
199  }
200 
201  template <typename CallbackT, typename TRecord>
202  void registerProducts(std::shared_ptr<std::pair<unsigned int, std::shared_ptr<CallbackT>>>,
204  const TRecord*,
205  const es::Label&) {
206  //do nothing
207  }
208 
209  template <typename CallbackT, typename TProduct, typename TRecord>
210  void registerProduct(std::shared_ptr<std::pair<unsigned int, std::shared_ptr<CallbackT>>> iCallback,
211  const TProduct*,
212  const TRecord*,
213  const es::Label& iLabel) {
216  registerFactory(std::make_unique<FactoryType>(std::move(iCallback)), iLabel.default_);
217  }
218 
219  template <typename CallbackT, typename TProduct, typename TRecord, int IIndex>
220  void registerProduct(std::shared_ptr<std::pair<unsigned int, std::shared_ptr<CallbackT>>> iCallback,
222  const TRecord*,
223  const es::Label& iLabel) {
224  if (iLabel.labels_.size() <= IIndex || iLabel.labels_[IIndex] == es::Label::def()) {
226  "Unnamed Label\nthe index ",
227  IIndex,
228  " was never assigned a name in the 'setWhatProduced' method");
229  }
232  registerFactory(std::make_unique<FactoryType>(std::move(iCallback)), iLabel.labels_[IIndex]);
233  }
234 
235  std::vector<std::unique_ptr<ESConsumesInfo>> consumesInfos_;
236  std::vector<std::vector<ESProxyIndex>> itemsToGetFromRecords_;
237  //need another structure to say which record to get the data from in
238  // order to make prefetching work
239  std::vector<std::vector<ESRecordIndex>> recordsUsedDuringGet_;
240  };
241 } // namespace edm
242 #endif
edm::ESProducer::~ESProducer
~ESProducer() noexcept(false) override
Definition: ESProducer.cc:37
edm::ESProxyFactoryProducer
Definition: ESProxyFactoryProducer.h:76
edm::es::Label::default_
std::string default_
Definition: es_Label.h:88
edm::eventsetup::produce::product_traits::type
T type
Definition: produce_helpers.h:58
mps_fire.i
i
Definition: mps_fire.py:355
edm::eventsetup::ESRecordsToProxyIndices
Definition: ESRecordsToProxyIndices.h:35
edm::ESProducer::itemsToGetFromRecords_
std::vector< std::vector< ESProxyIndex > > itemsToGetFromRecords_
Definition: ESProducer.h:236
ESProxyFactoryProducer.h
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::eventsetup::impl::MayConsumeChooserBase
Definition: MayConsumeChooserBase.h:50
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const std::string &iLabel)
Definition: ESProducer.h:147
edm::ESProducer::recordsUsedDuringGet_
std::vector< std::vector< ESRecordIndex > > recordsUsedDuringGet_
Definition: ESProducer.h:239
ESConsumesCollector.h
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition: ESProducer.h:138
info
static const TGPicture * info(bool iBackgroundIsBlack)
Definition: FWCollectionSummaryWidget.cc:152
edm::eventsetup::CallbackSimpleDecorator
Definition: Callback.h:34
edm::ESProducer::getTokenIndices
ESProxyIndex const * getTokenIndices(unsigned int iIndex) const
Definition: ESProducer.h:109
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
edm::eventsetup::Callback
Definition: Callback.h:44
edm::ESProxyIndex
Definition: ESIndices.h:29
edm::ESProducer::setWhatProduced
ESConsumesCollectorT< TRecord > setWhatProduced(T *iThis, TReturn(T ::*iMethod)(const TRecord &), const TArg &iDec, const es::Label &iLabel={})
Definition: ESProducer.h:171
edm::ESConsumesCollectorT
Definition: ESConsumesCollector.h:131
edm::ESProducer::consumesInfos_
std::vector< std::unique_ptr< ESConsumesInfo > > consumesInfos_
Definition: ESProducer.h:235
es_Label.h
eventsetup_dependsOn.h
edm::eventsetup::produce::Null
Definition: produce_helpers.h:47
edm::ESProducer::registerProducts
void registerProducts(std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>>, const eventsetup::produce::Null *, const TRecord *, const es::Label &)
Definition: ESProducer.h:202
Callback.h
edm::eventsetup::createDecoratorFrom
const TDecorator & createDecoratorFrom(T *, const TRecord *, const TDecorator &iDec)
Definition: ESProducer.h:96
edm::ESProducer::ESProducer
ESProducer()
Definition: ESProducer.cc:30
edm::es::Label
Definition: es_Label.h:54
edm::es::Label::def
static const std::string & def()
Definition: es_Label.h:82
edm::ESProxyFactoryProducer::registerFactory
void registerFactory(std::unique_ptr< TFactory > iFactory, const std::string &iLabel=std::string())
Definition: ESProxyFactoryProducer.h:97
edm::ESProducer::operator=
ESProducer const & operator=(const ESProducer &)=delete
edm::eventsetup::ProxyArgumentFactoryTemplate
Definition: ProxyArgumentFactoryTemplate.h:37
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::es::L
Definition: es_Label.h:36
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, TReturn(T ::*iMethod)(const TRecord &), const es::Label &iLabel={})
Definition: ESProducer.h:161
edm::ESProducer::registerProducts
void registerProducts(std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TList *, const TRecord *iRecord, const es::Label &iLabel)
Definition: ESProducer.h:193
ESRecordsToProxyIndices
edm::eventsetup::DecoratorFromArg::Decorator_t
TArg Decorator_t
Definition: eventsetup_dependsOn.h:156
edm::ESProducer::updateFromMayConsumes
void updateFromMayConsumes(unsigned int iIndex, const Record &iRecord)
Definition: ESProducer.h:118
edm::ESProducer::registerProduct
void registerProduct(std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const TProduct *, const TRecord *, const es::Label &iLabel)
Definition: ESProducer.h:210
edm::es::Label::labels_
std::vector< std::string > labels_
Definition: es_Label.h:87
edm::ESProducer::updateLookup
void updateLookup(eventsetup::ESRecordsToProxyIndices const &) final
Definition: ESProducer.cc:54
produce_helpers.h
edmIntegrityCheck.callback
callback
Definition: edmIntegrityCheck.py:75
eostools.move
def move(src, dest)
Definition: eostools.py:511
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
T
long double T
Definition: Basic3DVectorLD.h:48
Record
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
edm::Exception::throwThis
static void throwThis(Code category, char const *message0="", char const *message1="", char const *message2="", char const *message3="", char const *message4="")
Definition: EDMException.cc:83
CallbackProxy.h
or
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::ESProducer
Definition: ESProducer.h:101
edm::eventsetup::CallbackProxy
Definition: CallbackProxy.h:37
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const char *iLabel)
Definition: ESProducer.h:143
ProxyArgumentFactoryTemplate.h
MayConsumeChooserBase.h
edm::errors::Configuration
Definition: EDMException.h:36
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const TDecorator &iDec, const es::Label &iLabel={})
Definition: ESProducer.h:152
edm::ESProducer::registerProduct
void registerProduct(std::shared_ptr< std::pair< unsigned int, std::shared_ptr< CallbackT >>> iCallback, const es::L< TProduct, IIndex > *, const TRecord *, const es::Label &iLabel)
Definition: ESProducer.h:220