|
37 | 37 | #include "FWCore/Framework/interface/HCTypeTag.h" |
38 | 38 | #include "FWCore/Framework/interface/DataKey.h" |
39 | 39 | #include "FWCore/Framework/interface/data_default_record_trait.h" |
| 40 | +#include "FWCore/Framework/interface/ModuleConsumesMinimalESInfo.h" |
40 | 41 | #include "FWCore/ServiceRegistry/interface/ServiceRegistryfwd.h" |
41 | 42 | #include "FWCore/Utilities/interface/BranchType.h" |
42 | 43 | #include "FWCore/Utilities/interface/ESIndices.h" |
@@ -114,20 +115,12 @@ namespace edm { |
114 | 115 | typedef ProductLabels Labels; |
115 | 116 | void labelsForToken(EDGetToken iToken, Labels& oLabels) const; |
116 | 117 |
|
117 | | - void modulesWhoseProductsAreConsumed(std::array<std::vector<ModuleDescription const*>*, NumBranchTypes>& modulesAll, |
118 | | - ProductRegistry const& preg, |
119 | | - std::map<std::string, ModuleDescription const*> const& labelsToDesc, |
120 | | - std::string const& processName) const; |
121 | | - |
122 | | - void esModulesWhoseProductsAreConsumed( |
123 | | - std::array<std::vector<eventsetup::ComponentDescription const*>*, kNumberOfEventSetupTransitions>& esModules, |
124 | | - eventsetup::ESRecordsToProductResolverIndices const&) const; |
125 | | - |
126 | 118 | /// Convert "@currentProcess" in InputTag process names to the actual current process name. |
127 | 119 | void convertCurrentProcessAlias(std::string const& processName); |
128 | 120 |
|
129 | 121 | std::vector<ModuleConsumesInfo> moduleConsumesInfos() const; |
130 | | - std::vector<ModuleConsumesESInfo> moduleConsumesESInfos(eventsetup::ESRecordsToProductResolverIndices const&) const; |
| 122 | + ///This can only be called before the end of beginJob (after that the underlying data has been deleted) |
| 123 | + std::vector<ModuleConsumesMinimalESInfo> moduleConsumesMinimalESInfos() const; |
131 | 124 |
|
132 | 125 | ESResolverIndex const* esGetTokenIndices(edm::Transition iTrans) const { |
133 | 126 | if (iTrans < edm::Transition::NumberOfEventSetupTransitions) { |
@@ -232,6 +225,20 @@ namespace edm { |
232 | 225 | return ESGetTokenGeneric(static_cast<unsigned int>(Tr), index, iRecord.type()); |
233 | 226 | } |
234 | 227 |
|
| 228 | + /**The passed functor must take the following signature |
| 229 | + * F( ModuleConsumesInfo const& ) |
| 230 | + * The functor will be called for each consumed EDProduct registered for the module |
| 231 | + */ |
| 232 | + template <typename F> |
| 233 | + void consumedProducts(F&& iFunc) const; |
| 234 | + |
| 235 | + /**The passed functor must take the following signature |
| 236 | + * F(edm::ModuleConsumesMinimalESInfo const& ) |
| 237 | + * The functor will be called for each consumed ESProduct registered for the module |
| 238 | + */ |
| 239 | + template <typename F> |
| 240 | + void consumedESProducts(F&& iFunct) const; |
| 241 | + |
235 | 242 | private: |
236 | 243 | virtual void extendUpdateLookup(BranchType iBranchType, ProductResolverIndexHelper const&); |
237 | 244 | virtual void registerLateConsumes(eventsetup::ESRecordsToProductResolverIndices const&) {} |
@@ -326,6 +333,47 @@ namespace edm { |
326 | 333 | bool containsCurrentProcessAlias_; |
327 | 334 | }; |
328 | 335 |
|
| 336 | + template <typename F> |
| 337 | + void EDConsumerBase::consumedProducts(F&& iFunc) const { |
| 338 | + auto itKind = m_tokenInfo.begin<kKind>(); |
| 339 | + auto itLabels = m_tokenInfo.begin<kLabels>(); |
| 340 | + auto itAlways = m_tokenInfo.begin<kAlwaysGets>(); |
| 341 | + for (auto itInfo = m_tokenInfo.begin<kLookupInfo>(), itEnd = m_tokenInfo.end<kLookupInfo>(); itInfo != itEnd; |
| 342 | + ++itInfo, ++itKind, ++itLabels, ++itAlways) { |
| 343 | + auto labels = *itLabels; |
| 344 | + unsigned int start = labels.m_startOfModuleLabel; |
| 345 | + auto module = &(m_tokenLabels[start]); |
| 346 | + auto productInstance = module + labels.m_deltaToProductInstance; |
| 347 | + auto process = module + labels.m_deltaToProcessName; |
| 348 | + |
| 349 | + iFunc(ModuleConsumesInfo(itInfo->m_type, |
| 350 | + module, |
| 351 | + productInstance, |
| 352 | + process, |
| 353 | + itInfo->m_branchType, |
| 354 | + *itKind, |
| 355 | + *itAlways, |
| 356 | + itInfo->m_index.skipCurrentProcess())); |
| 357 | + } |
| 358 | + } |
| 359 | + |
| 360 | + template <typename F> |
| 361 | + void EDConsumerBase::consumedESProducts(F&& iFunc) const { |
| 362 | + unsigned int index = 0; |
| 363 | + auto itResolverIndex = esTokenLookupInfoContainer().begin<kESResolverIndex>(); |
| 364 | + for (auto it = esTokenLookupInfoContainer().begin<kESLookupInfo>(); |
| 365 | + it != esTokenLookupInfoContainer().end<kESLookupInfo>(); |
| 366 | + ++it, ++index, ++itResolverIndex) { |
| 367 | + //NOTE: memory for it->m_key is passed on to call via the ModuleConsumesMinimalESInfo constructor |
| 368 | + // this avoids a copy and avoids code later in the call chain accidently using deleted memory |
| 369 | + iFunc(ModuleConsumesMinimalESInfo(static_cast<Transition>(consumesIndexConverter()[index].first), |
| 370 | + it->m_record, |
| 371 | + it->m_key, |
| 372 | + &(m_tokenLabels[it->m_startOfComponentName]), |
| 373 | + *itResolverIndex)); |
| 374 | + } |
| 375 | + } |
| 376 | + |
329 | 377 | template <Transition TR> |
330 | 378 | class EDConsumerBaseESAdaptor { |
331 | 379 | public: |
|
0 commit comments