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 197 of file ProductRegistry.cc.

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

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

Definition at line 105 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_.

107  {
108  assert(productDesc.produced());
109  assert(productDesc.branchID().isValid());
110  throwIfFrozen();
111  BranchDescription bd(productDesc, labelAlias, instanceAlias);
112  std::pair<ProductList::iterator, bool> ret =
113  productList_.insert(std::make_pair(BranchKey(bd), bd));
114  assert(ret.second);
115  transient_.aliasToOriginal_.emplace_back(labelAlias,
116  productDesc.moduleLabel());
117  addCalled(bd, false);
118  }
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::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")
89  << "The produced product " << previous.second << " is registered more than once.\n"
90  << "Please remove the redundant 'produces' call(s).\n";
91  } else {
92  // Duplicate registration in previous process
93  throw Exception(errors::Configuration, "Duplicate Process Name.\n")
94  << "The process name " << productDesc.processName() << " was previously used for products in the input.\n"
95  << "This has caused branch name conflicts between input products and new products.\n"
96  << "Please modify the configuration file to use a distinct process name.\n"
97  << "Alternately, drop all input products using that process name and the\n"
98  << "descendants of those products.\n";
99  }
100  }
101  addCalled(productDesc, fromListener);
102  }
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 212 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().

212  {
213  std::vector<BranchDescription const*> result;
214  result.reserve(productList().size());
215 
216  for(auto const& product : productList()) {
217  result.push_back(&product.second);
218  }
219  return result;
220  }
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 135 of file ProductRegistry.cc.

References productList_, and throwIfNotFrozen().

Referenced by size().

135  {
137  for(ProductList::const_iterator it = productList_.begin(), itEnd = productList_.end();
138  it != itEnd; ++it) {
139  if(it->second.branchType() == brType) {
140  return true;
141  }
142  }
143  return false;
144  }
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 449 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().

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

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

Referenced by freezeIt(), and initializeLookupTables().

530  {
531  if (processName &&
532  !desc.produced() &&
533  (*processName == desc.processName())) {
534 
535  throw Exception(errors::Configuration, "Duplicate Process Name.\n")
536  << "The process name " << *processName << " was previously used for products in the input.\n"
537  << "Please modify the configuration file to use a distinct process name.\n"
538  << "Alternately, drop all input products using that process name and the\n"
539  << "descendants of those products.\n";
540  }
541  }
void edm::ProductRegistry::copyProduct ( BranchDescription const &  productdesc)

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

121  {
122  assert(!productDesc.produced());
123  throwIfFrozen();
124  BranchKey k = BranchKey(productDesc);
125  ProductList::iterator iter = productList_.find(k);
126  if(iter == productList_.end()) {
127  productList_.insert(std::make_pair(k, productDesc));
128  } else {
129  assert(combinable(iter->second, productDesc));
130  iter->second.merge(productDesc);
131  }
132  }
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 543 of file ProductRegistry.cc.

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

Referenced by size().

543  {
544  std::map<BranchID, ProductResolverIndex>::const_iterator itFind = transient_.branchIDToIndex_.find(iID);
545  if(itFind == transient_.branchIDToIndex_.end()) {
547  }
548  return itFind->second;
549  }
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 282 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(), diffTreeTool::index, 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().

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

239  {
240  std::ostringstream differences;
241 
242  ProductRegistry::ProductList::iterator j = productList_.begin();
243  ProductRegistry::ProductList::iterator s = productList_.end();
244  ProductRegistry::ProductList::const_iterator i = other.productList().begin();
245  ProductRegistry::ProductList::const_iterator e = other.productList().end();
246 
247  // Loop over entries in the main product registry.
248  while(j != s || i != e) {
249  if(j != s && j->second.produced()) {
250  // Ignore branches just produced (i.e. not in input file).
251  ++j;
252  } else if(j == s || (i != e && i->first < j->first)) {
253  if(i->second.present()) {
254  differences << "Branch '" << i->second.branchName() << "' is in file '" << fileName << "'\n";
255  differences << " but not in previous files.\n";
256  } else {
257  productList_.insert(*i);
258  transient_.branchIDToIndex_[i->second.branchID()] = getNextIndexValue(i->second.branchType());
259  ++nextIndexValue(i->second.branchType());
260  }
261  ++i;
262  } else if(i == e || (j != s && j->first < i->first)) {
263  if(j->second.present() && branchesMustMatch == BranchDescription::Strict) {
264  differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
265  differences << " but not in file '" << fileName << "'.\n";
266  }
267  ++j;
268  } else {
269  std::string difs = match(j->second, i->second, fileName);
270  if(difs.empty()) {
271  j->second.merge(i->second);
272  } else {
273  differences << difs;
274  }
275  ++i;
276  ++j;
277  }
278  }
279  return differences.str();
280  }
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 551 of file ProductRegistry.cc.

References productList_.

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

551  {
552  for(auto const& product: productList_) {
553  os << product.second << "\n-----\n";
554  }
555  }
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 154 of file ProductRegistry.cc.

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

154  {
157  return transient_.runProductLookup();
158  }
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 161 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().

161  {
162  if(frozen()) return;
163  freezeIt();
164  if(initializeLookupInfo) {
165  initializeLookupTables(nullptr, nullptr, nullptr);
166  }
168  }
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 171 of file ProductRegistry.cc.

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

173  {
174  if(frozen()) return;
175  freezeIt();
176  initializeLookupTables(&productTypesConsumed, &elementTypesConsumed, &processName);
178  }
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 181 of file ProductRegistry.cc.

References Exception, and frozen().

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

181  {
182  if(frozen()) {
183  throw cms::Exception("ProductRegistry", "throwIfFrozen")
184  << "cannot modify the ProductRegistry because it is frozen\n";
185  }
186  }
void edm::ProductRegistry::throwIfNotFrozen ( ) const
private

Definition at line 189 of file ProductRegistry.cc.

References Exception, and frozen().

Referenced by anyProducts(), and freezeIt().

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

Definition at line 230 of file ProductRegistry.cc.

References copyProduct(), and AlCaHLTBitMon_QueryRunRegistry::string.

230  {
231  for(BranchDescription const& branchDescription : other) {
232  copyProduct(branchDescription);
233  }
234  }
void copyProduct(BranchDescription const &productdesc)

Member Data Documentation

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