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)
 
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 48 of file ProductRegistry.h.

Definition at line 37 of file ProductRegistry.h.

Constructor & Destructor Documentation

edm::ProductRegistry::ProductRegistry ( )

Definition at line 33 of file ProductRegistry.cc.

33  :
34  productList_(),
35  transient_() {
36  }
edm::ProductRegistry::ProductRegistry ( ProductList const &  productList,
bool  toBeFrozen = true 
)
explicit

Definition at line 71 of file ProductRegistry.cc.

References freezeIt().

71  :
73  transient_() {
74  freezeIt(toBeFrozen);
75  }
ProductList const & productList() const
void freezeIt(bool frozen=true)
virtual edm::ProductRegistry::~ProductRegistry ( )
inlinevirtual

Definition at line 46 of file ProductRegistry.h.

46 {}

Member Function Documentation

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

Reimplemented in edm::SignallingProductRegistry.

Definition at line 212 of file ProductRegistry.cc.

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

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

Definition at line 120 of file ProductRegistry.cc.

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

122  {
123  assert(productDesc.produced());
124  assert(productDesc.branchID().isValid());
125  throwIfFrozen();
126  BranchDescription bd(productDesc, labelAlias, instanceAlias);
127  std::pair<ProductList::iterator, bool> ret =
128  productList_.insert(std::make_pair(BranchKey(bd), bd));
129  assert(ret.second);
130  transient_.aliasToOriginal_.emplace_back(labelAlias,
131  productDesc.moduleLabel());
132  addCalled(bd, false);
133  }
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 78 of file ProductRegistry.cc.

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

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

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

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

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

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

Definition at line 227 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().

227  {
228  std::vector<BranchDescription const*> result;
229  result.reserve(productList().size());
230 
231  for(auto const& product : productList()) {
232  result.push_back(&product.second);
233  }
234  return result;
235  }
ProductList::size_type size() const
ProductList const & productList() const
std::vector< std::string > edm::ProductRegistry::allBranchNames ( ) const

Definition at line 216 of file ProductRegistry.cc.

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

Referenced by productListUpdator().

216  {
217  std::vector<std::string> result;
218  result.reserve(productList().size());
219 
220  for(auto const& product : productList()) {
221  result.push_back(product.second.branchName());
222  }
223  return result;
224  }
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 150 of file ProductRegistry.cc.

References productList_, and throwIfNotFrozen().

Referenced by size().

150  {
152  for(ProductList::const_iterator it = productList_.begin(), itEnd = productList_.end();
153  it != itEnd; ++it) {
154  if(it->second.branchType() == brType) {
155  return true;
156  }
157  }
158  return false;
159  }
void throwIfNotFrozen() const
template<typename T >
void edm::ProductRegistry::callForEachBranch ( T const &  iFunc)
inline

Definition at line 94 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().

94  {
95  //NOTE: If implementation changes from a map, need to check that iterators are still valid
96  // after an insert with the new container, else need to copy the container and iterate over the copy
97  for(ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(),
98  itEntryEnd = productList_.end();
99  itEntry != itEntryEnd; ++itEntry) {
100  iFunc(itEntry->second);
101  }
102  }
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 464 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().

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

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

Referenced by freezeIt(), and initializeLookupTables().

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

Definition at line 136 of file ProductRegistry.cc.

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

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

136  {
137  assert(!productDesc.produced());
138  throwIfFrozen();
139  BranchKey k = BranchKey(productDesc);
140  ProductList::iterator iter = productList_.find(k);
141  if(iter == productList_.end()) {
142  productList_.insert(std::make_pair(k, productDesc));
143  } else {
144  assert(combinable(iter->second, productDesc));
145  iter->second.merge(productDesc);
146  }
147  }
bool combinable(BranchDescription const &a, BranchDescription const &b)
int k[5][pyjets_maxn]
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 558 of file ProductRegistry.cc.

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

Referenced by size().

558  {
559  std::map<BranchID, ProductResolverIndex>::const_iterator itFind = transient_.branchIDToIndex_.find(iID);
560  if(itFind == transient_.branchIDToIndex_.end()) {
562  }
563  return itFind->second;
564  }
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 297 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().

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

References edm::ProductRegistry::Transients::branchIDToIndex_, MillePedeFileConverter_cfg::e, getNextIndexValue(), mps_fire::i, 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().

254  {
255  std::ostringstream differences;
256 
257  ProductRegistry::ProductList::iterator j = productList_.begin();
258  ProductRegistry::ProductList::iterator s = productList_.end();
259  ProductRegistry::ProductList::const_iterator i = other.productList().begin();
260  ProductRegistry::ProductList::const_iterator e = other.productList().end();
261 
262  // Loop over entries in the main product registry.
263  while(j != s || i != e) {
264  if(j != s && j->second.produced()) {
265  // Ignore branches just produced (i.e. not in input file).
266  ++j;
267  } else if(j == s || (i != e && i->first < j->first)) {
268  if(i->second.present()) {
269  differences << "Branch '" << i->second.branchName() << "' is in file '" << fileName << "'\n";
270  differences << " but not in previous files.\n";
271  } else {
272  productList_.insert(*i);
273  transient_.branchIDToIndex_[i->second.branchID()] = getNextIndexValue(i->second.branchType());
274  ++nextIndexValue(i->second.branchType());
275  }
276  ++i;
277  } else if(i == e || (j != s && j->first < i->first)) {
278  if(j->second.present() && branchesMustMatch == BranchDescription::Strict) {
279  differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
280  differences << " but not in file '" << fileName << "'.\n";
281  }
282  ++j;
283  } else {
284  std::string difs = match(j->second, i->second, fileName);
285  if(difs.empty()) {
286  j->second.merge(i->second);
287  } else {
288  differences << difs;
289  }
290  ++i;
291  ++j;
292  }
293  }
294  return differences.str();
295  }
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 566 of file ProductRegistry.cc.

References productList_.

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

566  {
567  for(auto const& product: productList_) {
568  os << product.second << "\n-----\n";
569  }
570  }
ProductList const& edm::ProductRegistry::productList ( ) const
inline
ProductList& edm::ProductRegistry::productListUpdator ( )
inline
std::shared_ptr< ProductResolverIndexHelper const > edm::ProductRegistry::productLookup ( BranchType  branchType) const
std::shared_ptr< ProductResolverIndexHelper > edm::ProductRegistry::productLookup ( BranchType  branchType)

Definition at line 169 of file ProductRegistry.cc.

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

169  {
172  return transient_.runProductLookup();
173  }
std::shared_ptr< ProductResolverIndexHelper const > lumiProductLookup() const
std::shared_ptr< ProductResolverIndexHelper const > eventProductLookup() const
std::shared_ptr< ProductResolverIndexHelper const > runProductLookup() const
def branchType(schema, name)
Definition: revisionDML.py:112
bool edm::ProductRegistry::productProduced ( BranchType  branchType) const
inline

Definition at line 115 of file ProductRegistry.h.

References revisionDML::branchType(), edm::ProductRegistry::Transients::productProduced_, and transient_.

std::array< bool, NumBranchTypes > productProduced_
def branchType(schema, name)
Definition: revisionDML.py:112
void edm::ProductRegistry::setFrozen ( bool  initializeLookupInfo = true)

Definition at line 176 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().

176  {
177  if(frozen()) return;
178  freezeIt();
179  if(initializeLookupInfo) {
180  initializeLookupTables(nullptr, nullptr, nullptr);
181  }
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:120
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 186 of file ProductRegistry.cc.

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

188  {
189  if(frozen()) return;
190  freezeIt();
191  initializeLookupTables(&productTypesConsumed, &elementTypesConsumed, &processName);
193  }
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:120
std::vector< std::pair< std::string, std::string > > aliasToOriginal_
void edm::ProductRegistry::setProductProduced ( BranchType  branchType)
inlineprivate
ProductList::size_type edm::ProductRegistry::size ( void  ) const
inline
void edm::ProductRegistry::throwIfFrozen ( ) const
private

Definition at line 196 of file ProductRegistry.cc.

References Exception, and frozen().

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

196  {
197  if(frozen()) {
198  throw cms::Exception("ProductRegistry", "throwIfFrozen")
199  << "cannot modify the ProductRegistry because it is frozen\n";
200  }
201  }
void edm::ProductRegistry::throwIfNotFrozen ( ) const
private

Definition at line 204 of file ProductRegistry.cc.

References Exception, and frozen().

Referenced by anyProducts(), and freezeIt().

204  {
205  if(!frozen()) {
206  throw cms::Exception("ProductRegistry", "throwIfNotFrozen")
207  << "cannot read the ProductRegistry because it is not yet frozen\n";
208  }
209  }
void edm::ProductRegistry::updateFromInput ( ProductList const &  other)
void edm::ProductRegistry::updateFromInput ( std::vector< BranchDescription > const &  other)

Definition at line 245 of file ProductRegistry.cc.

References copyProduct(), and AlCaHLTBitMon_QueryRunRegistry::string.

245  {
246  for(BranchDescription const& branchDescription : other) {
247  copyProduct(branchDescription);
248  }
249  }
void copyProduct(BranchDescription const &productdesc)

Member Data Documentation

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