CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
edm::ProductRegistry Class Reference

#include <ProductRegistry.h>

Inheritance diagram for edm::ProductRegistry:
edm::SignallingProductRegistry

Classes

struct  Transients
 

Public Types

typedef std::map< BranchKey, BranchDescription const > ConstProductList
 
typedef std::map< BranchKey, BranchDescriptionProductList
 

Public Member Functions

void addLabelAlias (BranchDescription const &productdesc, std::string const &labelAlias, std::string const &instanceAlias)
 
void addProduct (BranchDescription const &productdesc, bool iFromListener=false)
 
std::vector< std::pair< std::string, std::string > > const & aliasToOriginal () const
 
std::vector< BranchDescription const * > allBranchDescriptions () const
 
std::vector< std::string > allBranchNames () const
 
bool anyProductProduced () const
 
bool anyProducts (BranchType const brType) const
 
template<typename T >
void callForEachBranch (T const &iFunc)
 
void copyProduct (BranchDescription const &productdesc)
 
bool frozen () const
 
ProductResolverIndex const & getNextIndexValue (BranchType branchType) const
 
ProductResolverIndex indexFrom (BranchID const &iID) const
 
void initializeTransients ()
 
std::string merge (ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
 
void print (std::ostream &os) const
 
ProductList const & productList () const
 
ProductListproductListUpdator ()
 
std::shared_ptr< ProductResolverIndexHelper const > productLookup (BranchType branchType) const
 
std::shared_ptr< ProductResolverIndexHelperproductLookup (BranchType branchType)
 
bool productProduced (BranchType branchType) const
 
 ProductRegistry ()
 
 ProductRegistry (ProductList const &productList, bool toBeFrozen=true)
 
void setFrozen (bool initializeLookupInfo=true)
 
void setFrozen (std::set< TypeID > const &productTypesConsumed, std::set< TypeID > const &elementTypesConsumed, std::string const &processName)
 
void setUnscheduledProducts (std::set< std::string > const &unscheduledLabels)
 
ProductList::size_type size () const
 
void updateFromInput (ProductList const &other)
 
void updateFromInput (std::vector< BranchDescription > const &other)
 
virtual ~ProductRegistry ()
 

Private Member Functions

virtual void addCalled (BranchDescription const &, bool iFromListener)
 
void checkDictionariesOfConsumedTypes (std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::map< TypeID, TypeID > const &containedTypeMap, std::map< TypeID, std::vector< TypeWithDict >> &containedTypeToBaseTypesMap)
 
void checkForDuplicateProcessName (BranchDescription const &desc, std::string const *processName) const
 
void freezeIt (bool frozen=true)
 
void initializeLookupTables (std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::string const *processName)
 
ProductResolverIndexnextIndexValue (BranchType branchType)
 
void setProductProduced (BranchType branchType)
 
void throwIfFrozen () const
 
void throwIfNotFrozen () const
 

Private Attributes

ProductList productList_
 
Transients transient_
 

Detailed Description

author Stefano ARGIRO author Bill Tanenbaum

Date
19 Jul 2005

Definition at line 34 of file ProductRegistry.h.

Member Typedef Documentation

Definition at line 47 of file ProductRegistry.h.

Definition at line 36 of file ProductRegistry.h.

Constructor & Destructor Documentation

edm::ProductRegistry::ProductRegistry ( )

Definition at line 32 of file ProductRegistry.cc.

32 : productList_(), transient_() {}
edm::ProductRegistry::ProductRegistry ( ProductList const &  productList,
bool  toBeFrozen = true 
)
explicit

Definition at line 68 of file ProductRegistry.cc.

References freezeIt().

70  freezeIt(toBeFrozen);
71  }
ProductList const & productList() const
void freezeIt(bool frozen=true)
virtual edm::ProductRegistry::~ProductRegistry ( )
inlinevirtual

Definition at line 45 of file ProductRegistry.h.

45 {}

Member Function Documentation

void edm::ProductRegistry::addCalled ( BranchDescription const &  ,
bool  iFromListener 
)
privatevirtual

Reimplemented in edm::SignallingProductRegistry.

Definition at line 199 of file ProductRegistry.cc.

Referenced by addLabelAlias(), addProduct(), and freezeIt().

199 {}
void edm::ProductRegistry::addLabelAlias ( BranchDescription const &  productdesc,
std::string const &  labelAlias,
std::string const &  instanceAlias 
)

Definition at line 113 of file ProductRegistry.cc.

References addCalled(), edm::ProductRegistry::Transients::aliasToOriginal_, edm::BranchDescription::branchID(), edm::BranchID::isValid(), edm::BranchDescription::moduleLabel(), edm::BranchDescription::produced(), productList_, runTheMatrix::ret, throwIfFrozen(), and transient_.

115  {
116  assert(productDesc.produced());
117  assert(productDesc.branchID().isValid());
118  throwIfFrozen();
119  BranchDescription bd(productDesc, labelAlias, instanceAlias);
120  std::pair<ProductList::iterator, bool> ret = productList_.insert(std::make_pair(BranchKey(bd), bd));
121  assert(ret.second);
122  transient_.aliasToOriginal_.emplace_back(labelAlias, productDesc.moduleLabel());
123  addCalled(bd, false);
124  }
ret
prodAgent to be discontinued
virtual void addCalled(BranchDescription const &, bool iFromListener)
std::vector< std::pair< std::string, std::string > > aliasToOriginal_
void throwIfFrozen() const
void edm::ProductRegistry::addProduct ( BranchDescription const &  productdesc,
bool  iFromListener = false 
)

Definition at line 73 of file ProductRegistry.cc.

References addCalled(), edm::BranchDescription::branchType(), edm::errors::Configuration, Exception, edm::errors::LogicError, edm::BranchDescription::processName(), edm::BranchDescription::produced(), productList_, runTheMatrix::ret, and throwIfFrozen().

Referenced by edm::ProductRegistryHelper::addToRegistry().

73  {
74  assert(productDesc.produced());
75  throwIfFrozen();
76  std::pair<ProductList::iterator, bool> ret =
77  productList_.insert(std::make_pair(BranchKey(productDesc), productDesc));
78  if (!ret.second) {
79  auto const& previous = *productList_.find(BranchKey(productDesc));
80  if (previous.second.produced()) {
81  // Duplicate registration in current process
82  throw Exception(errors::LogicError, "Duplicate Product Identifier")
83  << "\nThe Framework requires a unique branch name for each product\n"
84  << "which consists of four parts: a friendly class name, module label,\n"
85  << "product instance name, and process name. A product has been\n"
86  << "registered with a duplicate branch name. The most common way\n"
87  << "to fix this error is to modify the product instance name in\n"
88  << "one of the offending 'produces' function calls. Another fix\n"
89  << "would be to delete one of them if they are for the same product.\n\n"
90  << " friendly class name = " << previous.second.friendlyClassName() << "\n"
91  << " module label = " << previous.second.moduleLabel() << "\n"
92  << " product instance name = " << previous.second.productInstanceName() << "\n"
93  << " process name = " << previous.second.processName() << "\n\n"
94  << "The following additional information is not used as part of\n"
95  << "the unique branch identifier.\n\n"
96  << " branch types = " << previous.second.branchType() << " " << productDesc.branchType() << "\n"
97  << " class name = " << previous.second.fullClassName() << "\n\n"
98  << "Note that if the four parts of the branch name are the same,\n"
99  << "then this error will occur even if the branch types differ!\n\n";
100  } else {
101  // Duplicate registration in previous process
102  throw Exception(errors::Configuration, "Duplicate Process Name.\n")
103  << "The process name " << productDesc.processName() << " was previously used for products in the input.\n"
104  << "This has caused branch name conflicts between input products and new products.\n"
105  << "Please modify the configuration file to use a distinct process name.\n"
106  << "Alternately, drop all input products using that process name and the\n"
107  << "descendants of those products.\n";
108  }
109  }
110  addCalled(productDesc, fromListener);
111  }
ret
prodAgent to be discontinued
virtual void addCalled(BranchDescription const &, bool iFromListener)
void throwIfFrozen() const
std::vector<std::pair<std::string, std::string> > const& edm::ProductRegistry::aliasToOriginal ( ) const
inline

Definition at line 121 of file ProductRegistry.h.

References edm::ProductRegistry::Transients::aliasToOriginal_, getNextIndexValue(), and transient_.

Referenced by edm::EDConsumerBase::throwConsumesCallAfterFrozen().

121  {
123  }
std::vector< std::pair< std::string, std::string > > aliasToOriginal_
std::vector< BranchDescription const * > edm::ProductRegistry::allBranchDescriptions ( ) const

Definition at line 211 of file ProductRegistry.cc.

References productList(), mps_fire::result, and size().

Referenced by edm::RootFile::dropOnInput(), productListUpdator(), edm::SubProcess::selectProducts(), edm::OutputModule::selectProducts(), edm::global::OutputModuleBase::selectProducts(), edm::limited::OutputModuleBase::selectProducts(), edm::one::OutputModuleBase::selectProducts(), and edm::PrincipalGetAdapter::throwUnregisteredPutException().

211  {
212  std::vector<BranchDescription const*> result;
213  result.reserve(productList().size());
214 
215  for (auto const& product : productList()) {
216  result.push_back(&product.second);
217  }
218  return result;
219  }
ProductList::size_type size() const
ProductList const & productList() const
std::vector< std::string > edm::ProductRegistry::allBranchNames ( ) const

Definition at line 201 of file ProductRegistry.cc.

References productList(), mps_fire::result, and size().

Referenced by productListUpdator().

201  {
202  std::vector<std::string> result;
203  result.reserve(productList().size());
204 
205  for (auto const& product : productList()) {
206  result.push_back(product.second.branchName());
207  }
208  return result;
209  }
ProductList::size_type size() const
ProductList const & productList() const
bool edm::ProductRegistry::anyProductProduced ( ) const
inline
bool edm::ProductRegistry::anyProducts ( BranchType const  brType) const

Definition at line 139 of file ProductRegistry.cc.

References productList_, and throwIfNotFrozen().

Referenced by size().

139  {
141  for (ProductList::const_iterator it = productList_.begin(), itEnd = productList_.end(); it != itEnd; ++it) {
142  if (it->second.branchType() == brType) {
143  return true;
144  }
145  }
146  return false;
147  }
void throwIfNotFrozen() const
template<typename T >
void edm::ProductRegistry::callForEachBranch ( T const &  iFunc)
inline

Definition at line 97 of file ProductRegistry.h.

References productList_.

Referenced by edm::ProducerBase::registerProducts(), edm::stream::EDAnalyzerBase::registerProductsAndCallbacks(), edm::EDAnalyzer::registerProductsAndCallbacks(), edm::one::EDAnalyzerBase::registerProductsAndCallbacks(), edm::global::EDAnalyzerBase::registerProductsAndCallbacks(), and edm::limited::EDAnalyzerBase::registerProductsAndCallbacks().

97  {
98  //NOTE: If implementation changes from a map, need to check that iterators are still valid
99  // after an insert with the new container, else need to copy the container and iterate over the copy
100  for (ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(), itEntryEnd = productList_.end();
101  itEntry != itEntryEnd;
102  ++itEntry) {
103  iFunc(itEntry->second);
104  }
105  }
void edm::ProductRegistry::checkDictionariesOfConsumedTypes ( std::set< TypeID > const *  productTypesConsumed,
std::set< TypeID > const *  elementTypesConsumed,
std::map< TypeID, TypeID > const &  containedTypeMap,
std::map< TypeID, std::vector< TypeWithDict >> &  containedTypeToBaseTypesMap 
)
private

Definition at line 473 of file ProductRegistry.cc.

References edm::TypeWithDict::byName(), edm::checkClassDictionaries(), edm::checkDictionary(), edm::TypeID::className(), edm::productholderindexhelper::getContainedTypeFromWrapper(), edm::public_base_classes(), AlCaHLTBitMon_QueryRunRegistry::string, edm::throwMissingDictionariesException(), and edm::wrappedClassName().

Referenced by freezeIt(), and initializeLookupTables().

477  {
478  std::vector<std::string> missingDictionaries;
479  std::set<std::string> consumedTypesWithMissingDictionaries;
480 
481  if (productTypesConsumed) {
482  // Check dictionaries for all classes declared to be consumed
483  for (auto const& consumedTypeID : *productTypesConsumed) {
484  // We use the containedTypeMap to see which types have already
485  // had their dictionaries checked. We do not waste time rechecking
486  // those dictionaries.
487  if (containedTypeMap.find(consumedTypeID) == containedTypeMap.end()) {
488  std::string wrappedName = wrappedClassName(consumedTypeID.className());
489  TypeWithDict wrappedType = TypeWithDict::byName(wrappedName);
490  if (!checkDictionary(missingDictionaries, wrappedName, wrappedType)) {
491  checkDictionary(missingDictionaries, consumedTypeID);
492  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
493  continue;
494  }
495  bool transient = false;
496  TDictAttributeMap* wp = wrappedType.getClass()->GetAttributeMap();
497  if (wp && wp->HasKey("persistent") && !strcmp(wp->GetPropertyAsString("persistent"), "false")) {
498  transient = true;
499  }
500  if (transient) {
501  if (!checkDictionary(missingDictionaries, consumedTypeID)) {
502  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
503  }
504 
506  TypeID(wrappedType.typeInfo()), consumedTypeID.className());
507  bool hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
508  if (hasContainedType) {
509  if (containedTypeToBaseTypesMap.find(containedTypeID) == containedTypeToBaseTypesMap.end()) {
510  std::vector<TypeWithDict> bases;
511  // Run this to check for missing dictionaries, bases is not really used
512  if (!public_base_classes(missingDictionaries, containedTypeID, bases)) {
513  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
514  }
515  containedTypeToBaseTypesMap.insert(std::make_pair(containedTypeID, bases));
516  }
517  }
518  } else {
519  if (!checkClassDictionaries(missingDictionaries, wrappedName, wrappedType)) {
520  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
521  }
522  }
523  }
524  }
525  if (!missingDictionaries.empty()) {
526  std::string context(
527  "Calling ProductRegistry::initializeLookupTables, checking dictionaries for consumed products");
528  throwMissingDictionariesException(missingDictionaries, context, consumedTypesWithMissingDictionaries, false);
529  }
530  }
531 
532  if (elementTypesConsumed) {
533  missingDictionaries.clear();
534  consumedTypesWithMissingDictionaries.clear();
535  for (auto const& consumedTypeID : *elementTypesConsumed) {
536  if (containedTypeToBaseTypesMap.find(consumedTypeID) == containedTypeToBaseTypesMap.end()) {
537  std::vector<TypeWithDict> bases;
538  // Run this to check for missing dictionaries, bases is not really used
539  if (!public_base_classes(missingDictionaries, consumedTypeID, bases)) {
540  consumedTypesWithMissingDictionaries.emplace(consumedTypeID.className());
541  }
542  }
543  }
544  if (!missingDictionaries.empty()) {
545  std::string context(
546  "Calling ProductRegistry::initializeLookupTables, checking dictionaries for elements of products consumed "
547  "using View");
548  throwMissingDictionariesException(missingDictionaries, context, consumedTypesWithMissingDictionaries, true);
549  }
550  }
551  }
void throwMissingDictionariesException(std::vector< std::string > &missingDictionaries, std::string const &context)
TypeID getContainedTypeFromWrapper(TypeID const &wrappedtypeID, std::string const &className)
bool public_base_classes(std::vector< std::string > &missingDictionaries, TypeID const &typeID, std::vector< TypeWithDict > &baseTypes)
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
bool checkDictionary(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
bool checkClassDictionaries(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
std::string wrappedClassName(std::string const &iFullName)
void edm::ProductRegistry::checkForDuplicateProcessName ( BranchDescription const &  desc,
std::string const *  processName 
) const
private

Definition at line 553 of file ProductRegistry.cc.

References edm::errors::Configuration, Exception, edm::BranchDescription::processName(), and edm::BranchDescription::produced().

Referenced by freezeIt(), and initializeLookupTables().

554  {
555  if (processName && !desc.produced() && (*processName == desc.processName())) {
556  throw Exception(errors::Configuration, "Duplicate Process Name.\n")
557  << "The process name " << *processName << " was previously used for products in the input.\n"
558  << "Please modify the configuration file to use a distinct process name.\n"
559  << "Alternately, drop all input products using that process name and the\n"
560  << "descendants of those products.\n";
561  }
562  }
void edm::ProductRegistry::copyProduct ( BranchDescription const &  productdesc)

Definition at line 126 of file ProductRegistry.cc.

References edm::combinable(), dqmdumpme::k, edm::BranchDescription::produced(), productList_, and throwIfFrozen().

Referenced by edm::DaqProvenanceHelper::daqInit(), edm::LHEProvenanceHelper::LHEProvenanceHelper(), edm::RootFile::RootFile(), and updateFromInput().

126  {
127  assert(!productDesc.produced());
128  throwIfFrozen();
129  BranchKey k = BranchKey(productDesc);
130  ProductList::iterator iter = productList_.find(k);
131  if (iter == productList_.end()) {
132  productList_.insert(std::make_pair(k, productDesc));
133  } else {
134  assert(combinable(iter->second, productDesc));
135  iter->second.merge(productDesc);
136  }
137  }
bool combinable(BranchDescription const &a, BranchDescription const &b)
void throwIfFrozen() const
void edm::ProductRegistry::freezeIt ( bool  frozen = true)
inlineprivate
bool edm::ProductRegistry::frozen ( ) const
inline
ProductResolverIndex const & edm::ProductRegistry::getNextIndexValue ( BranchType  branchType) const
ProductResolverIndex edm::ProductRegistry::indexFrom ( BranchID const &  iID) const

Definition at line 564 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::branchIDToIndex_, edm::ProductResolverIndexInvalid, and transient_.

Referenced by size().

564  {
565  std::map<BranchID, ProductResolverIndex>::const_iterator itFind = transient_.branchIDToIndex_.find(iID);
566  if (itFind == transient_.branchIDToIndex_.end()) {
568  }
569  return itFind->second;
570  }
std::map< BranchID, ProductResolverIndex > branchIDToIndex_
void edm::ProductRegistry::initializeLookupTables ( std::set< TypeID > const *  productTypesConsumed,
std::set< TypeID > const *  elementTypesConsumed,
std::string const *  processName 
)
private

Definition at line 307 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::branchIDToIndex_, edm::checkClassDictionaries(), checkDictionariesOfConsumedTypes(), edm::checkDictionary(), edm::checkDictionaryOfWrappedType(), checkForDuplicateProcessName(), edm::ProductRegistry::Transients::eventNextIndexValue_, edm::productholderindexhelper::getContainedTypeFromWrapper(), getNextIndexValue(), edm::InEvent, edm::InLumi, edm::InRun, edm::eventsetup::heterocontainer::insert(), edm::ProductRegistry::Transients::lumiNextIndexValue_, nextIndexValue(), productList_, productLookup(), edm::public_base_classes(), edm::ProductRegistry::Transients::runNextIndexValue_, setProductProduced(), AlCaHLTBitMon_QueryRunRegistry::string, edm::throwMissingDictionariesException(), and transient_.

Referenced by freezeIt(), and setFrozen().

309  {
310  std::map<TypeID, TypeID> containedTypeMap;
311  std::map<TypeID, std::vector<TypeWithDict> > containedTypeToBaseTypesMap;
312 
313  std::vector<std::string> missingDictionaries;
314  std::vector<std::string> branchNamesForMissing;
315  std::vector<std::string> producedTypes;
316 
318 
319  for (auto const& product : productList_) {
320  auto const& desc = product.second;
321 
323 
324  if (desc.produced() && !desc.transient()) {
325  setProductProduced(desc.branchType());
326  }
327 
328  //only do the following if the data is supposed to be available in the event
329  if (desc.present()) {
330  // Check dictionaries (we already checked for the produced ones earlier somewhere else).
331  // We have to have the dictionaries to properly setup the lookup tables for support of
332  // Views. Also we need them to determine which present products are declared to be
333  // consumed in the case where the consumed type is a View<T>.
334  if (!desc.produced()) {
335  if (!checkDictionary(missingDictionaries, desc.className(), desc.unwrappedType())) {
336  checkDictionaryOfWrappedType(missingDictionaries, desc.className());
337  branchNamesForMissing.emplace_back(desc.branchName());
338  producedTypes.emplace_back(desc.className() + std::string(" (read from input)"));
339  continue;
340  }
341  }
342  TypeID typeID(desc.unwrappedType().typeInfo());
343 
344  auto iterContainedType = containedTypeMap.find(typeID);
345  bool alreadySawThisType = (iterContainedType != containedTypeMap.end());
346 
347  if (!desc.produced() && !alreadySawThisType) {
348  if (!checkDictionary(missingDictionaries, desc.wrappedName(), desc.wrappedType())) {
349  branchNamesForMissing.emplace_back(desc.branchName());
350  producedTypes.emplace_back(desc.className() + std::string(" (read from input)"));
351  continue;
352  }
353  }
354 
355  TypeID wrappedTypeID(desc.wrappedType().typeInfo());
356 
357  TypeID containedTypeID;
358  if (alreadySawThisType) {
359  containedTypeID = iterContainedType->second;
360  } else {
361  containedTypeID = productholderindexhelper::getContainedTypeFromWrapper(wrappedTypeID, typeID.className());
362  }
363  bool hasContainedType = (containedTypeID != TypeID(typeid(void)) && containedTypeID != TypeID());
364 
365  std::vector<TypeWithDict>* baseTypesOfContainedType = nullptr;
366 
367  if (!alreadySawThisType) {
368  bool alreadyCheckedConstituents = desc.produced() && !desc.transient();
369  if (!alreadyCheckedConstituents && !desc.transient()) {
370  // This checks dictionaries of the wrapped class and all its constituent classes
371  if (!checkClassDictionaries(missingDictionaries, desc.wrappedName(), desc.wrappedType())) {
372  branchNamesForMissing.emplace_back(desc.branchName());
373  producedTypes.emplace_back(desc.className() + std::string(" (read from input)"));
374  continue;
375  }
376  }
377 
378  if (hasContainedType) {
379  auto iterBaseTypes = containedTypeToBaseTypesMap.find(containedTypeID);
380  if (iterBaseTypes == containedTypeToBaseTypesMap.end()) {
381  std::vector<TypeWithDict> baseTypes;
382  if (!public_base_classes(missingDictionaries, containedTypeID, baseTypes)) {
383  branchNamesForMissing.emplace_back(desc.branchName());
384  if (desc.produced()) {
385  producedTypes.emplace_back(desc.className() + std::string(" (produced in current process)"));
386  } else {
387  producedTypes.emplace_back(desc.className() + std::string(" (read from input)"));
388  }
389  continue;
390  }
391  iterBaseTypes = containedTypeToBaseTypesMap.insert(std::make_pair(containedTypeID, baseTypes)).first;
392  }
393  baseTypesOfContainedType = &iterBaseTypes->second;
394  }
395 
396  // Do this after the dictionary checks of constituents so the list of branch names for missing types
397  // is complete
398  containedTypeMap.emplace(typeID, containedTypeID);
399  } else {
400  if (hasContainedType) {
401  auto iterBaseTypes = containedTypeToBaseTypesMap.find(containedTypeID);
402  if (iterBaseTypes != containedTypeToBaseTypesMap.end()) {
403  baseTypesOfContainedType = &iterBaseTypes->second;
404  }
405  }
406  }
407 
408  if (productTypesConsumed != nullptr && !desc.produced()) {
409  bool mainTypeConsumed = (productTypesConsumed->find(typeID) != productTypesConsumed->end());
410  bool containedTypeConsumed =
411  hasContainedType && (elementTypesConsumed->find(containedTypeID) != elementTypesConsumed->end());
412  if (hasContainedType && !containedTypeConsumed && baseTypesOfContainedType != nullptr) {
413  for (TypeWithDict const& baseType : *baseTypesOfContainedType) {
414  if (elementTypesConsumed->find(TypeID(baseType.typeInfo())) != elementTypesConsumed->end()) {
415  containedTypeConsumed = true;
416  break;
417  }
418  }
419  }
420  if (!containedTypeConsumed) {
421  if (mainTypeConsumed) {
422  // The main type is consumed, but either
423  // there is no contained type, or if there is,
424  // neither it nor any of its base classes are consumed.
425  // Set the contained type, if there is one, to void,
426  if (hasContainedType) {
427  containedTypeID = TypeID(typeid(void));
428  }
429  } else {
430  // The main type is not consumed, and either
431  // there is no contained type, or if there is,
432  // neither it nor any of its base classes are consumed.
433  // Don't insert anything in the lookup tables.
434  continue;
435  }
436  }
437  }
438  ProductResolverIndex index = productLookup(desc.branchType())
439  ->insert(typeID,
440  desc.moduleLabel().c_str(),
441  desc.productInstanceName().c_str(),
442  desc.processName().c_str(),
443  containedTypeID,
444  baseTypesOfContainedType);
445 
446  transient_.branchIDToIndex_[desc.branchID()] = index;
447  }
448  }
449  if (!missingDictionaries.empty()) {
450  std::string context("Calling ProductRegistry::initializeLookupTables");
451  throwMissingDictionariesException(missingDictionaries, context, producedTypes, branchNamesForMissing);
452  }
453 
454  productLookup(InEvent)->setFrozen();
455  productLookup(InLumi)->setFrozen();
456  productLookup(InRun)->setFrozen();
457 
459  transient_.lumiNextIndexValue_ = productLookup(InLumi)->nextIndexValue();
460  transient_.runNextIndexValue_ = productLookup(InRun)->nextIndexValue();
461 
462  for (auto const& product : productList_) {
463  auto const& desc = product.second;
464  if (transient_.branchIDToIndex_.find(desc.branchID()) == transient_.branchIDToIndex_.end()) {
465  transient_.branchIDToIndex_[desc.branchID()] = getNextIndexValue(desc.branchType());
466  ++nextIndexValue(desc.branchType());
467  }
468  }
470  productTypesConsumed, elementTypesConsumed, containedTypeMap, containedTypeToBaseTypesMap);
471  }
void setProductProduced(BranchType branchType)
void throwMissingDictionariesException(std::vector< std::string > &missingDictionaries, std::string const &context)
unsigned int ProductResolverIndex
TypeID getContainedTypeFromWrapper(TypeID const &wrappedtypeID, std::string const &className)
bool public_base_classes(std::vector< std::string > &missingDictionaries, TypeID const &typeID, std::vector< TypeWithDict > &baseTypes)
ProductResolverIndex eventNextIndexValue_
bool checkDictionary(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
ProductResolverIndex lumiNextIndexValue_
void checkForDuplicateProcessName(BranchDescription const &desc, std::string const *processName) const
ProductResolverIndex & nextIndexValue(BranchType branchType)
bool checkClassDictionaries(std::vector< std::string > &missingDictionaries, TypeID const &typeID)
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:50
void checkDictionariesOfConsumedTypes(std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::map< TypeID, TypeID > const &containedTypeMap, std::map< TypeID, std::vector< TypeWithDict >> &containedTypeToBaseTypesMap)
ProductResolverIndex runNextIndexValue_
std::shared_ptr< ProductResolverIndexHelper const > productLookup(BranchType branchType) const
ProductResolverIndex const & getNextIndexValue(BranchType branchType) const
bool checkDictionaryOfWrappedType(std::vector< std::string > &missingDictionaries, TypeID const &unwrappedTypeID)
std::map< BranchID, ProductResolverIndex > branchIDToIndex_
void edm::ProductRegistry::initializeTransients ( )
inline
std::string edm::ProductRegistry::merge ( ProductRegistry const &  other,
std::string const &  fileName,
BranchDescription::MatchMode  branchesMustMatch = BranchDescription::Permissive 
)

Definition at line 262 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::branchIDToIndex_, MillePedeFileConverter_cfg::e, getNextIndexValue(), mps_fire::i, dqmiolumiharvest::j, edm::match(), nextIndexValue(), productList(), productList_, alignCSCRings::s, edm::BranchDescription::Strict, AlCaHLTBitMon_QueryRunRegistry::string, and transient_.

Referenced by edm::StreamerInputSource::mergeIntoRegistry(), edm::RootPrimaryFileSequence::nextFile(), and edm::RootPrimaryFileSequence::previousFile().

264  {
265  std::ostringstream differences;
266 
267  ProductRegistry::ProductList::iterator j = productList_.begin();
268  ProductRegistry::ProductList::iterator s = productList_.end();
269  ProductRegistry::ProductList::const_iterator i = other.productList().begin();
270  ProductRegistry::ProductList::const_iterator e = other.productList().end();
271 
272  // Loop over entries in the main product registry.
273  while (j != s || i != e) {
274  if (j != s && j->second.produced()) {
275  // Ignore branches just produced (i.e. not in input file).
276  ++j;
277  } else if (j == s || (i != e && i->first < j->first)) {
278  if (i->second.present()) {
279  differences << "Branch '" << i->second.branchName() << "' is in file '" << fileName << "'\n";
280  differences << " but not in previous files.\n";
281  } else {
282  productList_.insert(*i);
283  transient_.branchIDToIndex_[i->second.branchID()] = getNextIndexValue(i->second.branchType());
284  ++nextIndexValue(i->second.branchType());
285  }
286  ++i;
287  } else if (i == e || (j != s && j->first < i->first)) {
288  if (j->second.present() && branchesMustMatch == BranchDescription::Strict) {
289  differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
290  differences << " but not in file '" << fileName << "'.\n";
291  }
292  ++j;
293  } else {
294  std::string difs = match(j->second, i->second, fileName);
295  if (difs.empty()) {
296  j->second.merge(i->second);
297  } else {
298  differences << difs;
299  }
300  ++i;
301  ++j;
302  }
303  }
304  return differences.str();
305  }
ProductResolverIndex & nextIndexValue(BranchType branchType)
ProductResolverIndex const & getNextIndexValue(BranchType branchType) const
std::map< BranchID, ProductResolverIndex > branchIDToIndex_
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
ProductResolverIndex & edm::ProductRegistry::nextIndexValue ( BranchType  branchType)
private
void edm::ProductRegistry::print ( std::ostream &  os) const

Definition at line 572 of file ProductRegistry.cc.

References productList_.

Referenced by edm::operator<<(), and size().

572  {
573  for (auto const& product : productList_) {
574  os << product.second << "\n-----\n";
575  }
576  }
ProductList const& edm::ProductRegistry::productList ( ) const
inline
ProductList& edm::ProductRegistry::productListUpdator ( )
inline
std::shared_ptr< ProductResolverIndexHelper const > edm::ProductRegistry::productLookup ( BranchType  branchType) const

Definition at line 149 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::eventProductLookup(), edm::InEvent, edm::InLumi, edm::ProductRegistry::Transients::lumiProductLookup(), edm::ProductRegistry::Transients::runProductLookup(), and transient_.

Referenced by edm::WorkerManager::beginJob(), edm::Schedule::changeModule(), initializeLookupTables(), edm::EDConsumerBase::modulesWhoseProductsAreConsumed(), and size().

149  {
150  if (branchType == InEvent)
152  if (branchType == InLumi)
153  return transient_.lumiProductLookup();
154  return transient_.runProductLookup();
155  }
std::shared_ptr< ProductResolverIndexHelper const > lumiProductLookup() const
std::shared_ptr< ProductResolverIndexHelper const > eventProductLookup() const
std::shared_ptr< ProductResolverIndexHelper const > runProductLookup() const
std::shared_ptr< ProductResolverIndexHelper > edm::ProductRegistry::productLookup ( BranchType  branchType)

Definition at line 157 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::eventProductLookup(), edm::InEvent, edm::InLumi, edm::ProductRegistry::Transients::lumiProductLookup(), edm::ProductRegistry::Transients::runProductLookup(), and transient_.

157  {
158  if (branchType == InEvent)
160  if (branchType == InLumi)
161  return transient_.lumiProductLookup();
162  return transient_.runProductLookup();
163  }
std::shared_ptr< ProductResolverIndexHelper const > lumiProductLookup() const
std::shared_ptr< ProductResolverIndexHelper const > eventProductLookup() const
std::shared_ptr< ProductResolverIndexHelper const > runProductLookup() const
bool edm::ProductRegistry::productProduced ( BranchType  branchType) const
inline

Definition at line 118 of file ProductRegistry.h.

References edm::ProductRegistry::Transients::productProduced_, and transient_.

118 { return transient_.productProduced_[branchType]; }
std::array< bool, NumBranchTypes > productProduced_
void edm::ProductRegistry::setFrozen ( bool  initializeLookupInfo = true)

Definition at line 165 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::aliasToOriginal_, freezeIt(), frozen(), initializeLookupTables(), edm::sort_all(), and transient_.

Referenced by fwlite::internal::BranchMapReaderStrategyV8::updateFile(), fwlite::internal::BranchMapReaderStrategyV11::updateFile(), fwlite::internal::BranchMapReaderStrategyV17::updateFile(), and fwlite::internal::BranchMapReaderStrategyV1::updateMap().

165  {
166  if (frozen())
167  return;
168  freezeIt();
169  if (initializeLookupInfo) {
170  initializeLookupTables(nullptr, nullptr, nullptr);
171  }
173  }
void initializeLookupTables(std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::string const *processName)
void freezeIt(bool frozen=true)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
std::vector< std::pair< std::string, std::string > > aliasToOriginal_
void edm::ProductRegistry::setFrozen ( std::set< TypeID > const &  productTypesConsumed,
std::set< TypeID > const &  elementTypesConsumed,
std::string const &  processName 
)

Definition at line 175 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::aliasToOriginal_, freezeIt(), frozen(), initializeLookupTables(), edm::sort_all(), and transient_.

177  {
178  if (frozen())
179  return;
180  freezeIt();
181  initializeLookupTables(&productTypesConsumed, &elementTypesConsumed, &processName);
183  }
void initializeLookupTables(std::set< TypeID > const *productTypesConsumed, std::set< TypeID > const *elementTypesConsumed, std::string const *processName)
void freezeIt(bool frozen=true)
void sort_all(RandomAccessSequence &s)
wrappers for std::sort
Definition: Algorithms.h:92
std::vector< std::pair< std::string, std::string > > aliasToOriginal_
void edm::ProductRegistry::setProductProduced ( BranchType  branchType)
inlineprivate
void edm::ProductRegistry::setUnscheduledProducts ( std::set< std::string > const &  unscheduledLabels)

Definition at line 233 of file ProductRegistry.cc.

References edm::InEvent, dumpMFGeometry_cfg::prod, productList_, and throwIfFrozen().

Referenced by edm::SecondaryEventProvider::SecondaryEventProvider().

233  {
234  throwIfFrozen();
235 
236  bool hasAliases = false;
237  std::vector<BranchID> onDemandIDs;
238  for (auto& prod : productList_) {
239  if (prod.second.produced() && prod.second.branchType() == InEvent &&
240  unscheduledLabels.end() != unscheduledLabels.find(prod.second.moduleLabel())) {
241  prod.second.setOnDemand(true);
242  onDemandIDs.push_back(prod.second.branchID());
243  }
244  if (prod.second.produced() && prod.second.isAlias()) {
245  hasAliases = true;
246  }
247  }
248 
249  // Need to loop over EDAliases to set their on-demand flag based on the pointed-to branch
250  if (hasAliases) {
251  std::sort(onDemandIDs.begin(), onDemandIDs.end());
252  for (auto& prod : productList_) {
253  if (prod.second.isAlias()) {
254  if (std::binary_search(onDemandIDs.begin(), onDemandIDs.end(), prod.second.aliasForBranchID())) {
255  prod.second.setOnDemand(true);
256  }
257  }
258  }
259  }
260  }
void throwIfFrozen() const
ProductList::size_type edm::ProductRegistry::size ( void  ) const
inline
void edm::ProductRegistry::throwIfFrozen ( ) const
private

Definition at line 185 of file ProductRegistry.cc.

References Exception, and frozen().

Referenced by addLabelAlias(), addProduct(), copyProduct(), freezeIt(), productListUpdator(), and setUnscheduledProducts().

185  {
186  if (frozen()) {
187  throw cms::Exception("ProductRegistry", "throwIfFrozen")
188  << "cannot modify the ProductRegistry because it is frozen\n";
189  }
190  }
void edm::ProductRegistry::throwIfNotFrozen ( ) const
private

Definition at line 192 of file ProductRegistry.cc.

References Exception, and frozen().

Referenced by anyProducts(), and freezeIt().

192  {
193  if (!frozen()) {
194  throw cms::Exception("ProductRegistry", "throwIfNotFrozen")
195  << "cannot read the ProductRegistry because it is not yet frozen\n";
196  }
197  }
void edm::ProductRegistry::updateFromInput ( ProductList const &  other)
void edm::ProductRegistry::updateFromInput ( std::vector< BranchDescription > const &  other)

Definition at line 227 of file ProductRegistry.cc.

References copyProduct().

227  {
228  for (BranchDescription const& branchDescription : other) {
229  copyProduct(branchDescription);
230  }
231  }
void copyProduct(BranchDescription const &productdesc)

Member Data Documentation

ProductList edm::ProductRegistry::productList_
private
Transients edm::ProductRegistry::transient_
private