#include <ProductRegistry.h>
Classes | |
struct | Transients |
Public Types | |
typedef std::map< BranchKey, ConstBranchDescription > | ConstProductList |
typedef std::map< BranchKey, BranchDescription > | ProductList |
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< 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) |
ConstProductList & | constProductList () const |
void | copyProduct (BranchDescription const &productdesc) |
ProductHolderIndex const & | getNextIndexValue (BranchType branchType) const |
ProductHolderIndex | indexFrom (BranchID const &iID) const |
void | initializeTransients () const |
std::string | merge (ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode parametersMustMatch=BranchDescription::Permissive, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive) |
std::vector< std::string > & | missingDictionaries () const |
void | print (std::ostream &os) const |
BranchListIndex | producedBranchListIndex () const |
ProductList const & | productList () const |
ProductList & | productListUpdator () |
boost::shared_ptr < ProductHolderIndexHelper > const & | productLookup (BranchType branchType) const |
bool | productProduced (BranchType branchType) const |
ProductRegistry (ProductList const &productList, bool toBeFrozen=true) | |
ProductRegistry () | |
void | setFrozen (bool initializeLookupInfo=true) const |
void | setProducedBranchListIndex (BranchListIndex blix) const |
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) |
bool & | frozen () const |
void | initializeLookupTables () const |
ProductHolderIndex & | nextIndexValue (BranchType branchType) const |
void | setProductProduced (BranchType branchType) const |
void | throwIfFrozen () const |
void | throwIfNotFrozen () const |
void | updateConstProductRegistry () |
Private Attributes | |
ProductList | productList_ |
Transients | transient_ |
author Stefano ARGIRO author Bill Tanenbaum
Definition at line 29 of file ProductRegistry.h.
typedef std::map<BranchKey, ConstBranchDescription> edm::ProductRegistry::ConstProductList |
Definition at line 43 of file ProductRegistry.h.
typedef std::map<BranchKey, BranchDescription> edm::ProductRegistry::ProductList |
Definition at line 32 of file ProductRegistry.h.
edm::ProductRegistry::ProductRegistry | ( | ) |
Definition at line 38 of file ProductRegistry.cc.
: productList_(), transient_() { }
edm::ProductRegistry::ProductRegistry | ( | ProductList const & | productList, |
bool | toBeFrozen = true |
||
) | [explicit] |
Definition at line 79 of file ProductRegistry.cc.
References frozen().
: productList_(productList), transient_() { frozen() = toBeFrozen; }
virtual edm::ProductRegistry::~ProductRegistry | ( | ) | [inline, virtual] |
Definition at line 41 of file ProductRegistry.h.
{}
void edm::ProductRegistry::addCalled | ( | BranchDescription const & | , |
bool | iFromListener | ||
) | [private, virtual] |
Reimplemented in edm::SignallingProductRegistry.
Definition at line 175 of file ProductRegistry.cc.
Referenced by addLabelAlias(), and addProduct().
{ }
void edm::ProductRegistry::addLabelAlias | ( | BranchDescription const & | productdesc, |
std::string const & | labelAlias, | ||
std::string const & | instanceAlias | ||
) |
Definition at line 102 of file ProductRegistry.cc.
References addCalled(), edm::BranchDescription::branchID(), edm::BranchID::isValid(), edm::BranchDescription::produced(), productList_, run_regression::ret, and throwIfFrozen().
{ assert(productDesc.produced()); assert(productDesc.branchID().isValid()); throwIfFrozen(); BranchDescription bd(productDesc, labelAlias, instanceAlias); std::pair<ProductList::iterator, bool> ret = productList_.insert(std::make_pair(BranchKey(bd), bd)); assert(ret.second); addCalled(bd, false); }
void edm::ProductRegistry::addProduct | ( | BranchDescription const & | productdesc, |
bool | iFromListener = false |
||
) |
Definition at line 86 of file ProductRegistry.cc.
References addCalled(), edm::errors::Configuration, Exception, edm::BranchDescription::processName(), edm::BranchDescription::produced(), productList_, run_regression::ret, and throwIfFrozen().
Referenced by edm::ProductRegistryHelper::addToRegistry().
{ assert(productDesc.produced()); throwIfFrozen(); checkDicts(productDesc); std::pair<ProductList::iterator, bool> ret = productList_.insert(std::make_pair(BranchKey(productDesc), productDesc)); if(!ret.second) { throw Exception(errors::Configuration, "Duplicate Process") << "The process name " << productDesc.processName() << " was previously used on these products.\n" << "Please modify the configuration file to use a distinct process name.\n"; } addCalled(productDesc, fromListener); }
std::vector< BranchDescription const * > edm::ProductRegistry::allBranchDescriptions | ( | ) | const |
Definition at line 190 of file ProductRegistry.cc.
References productList(), query::result, and size().
Referenced by edm::ConstProductRegistry::allBranchDescriptions(), and edm::OutputModule::selectProducts().
{ std::vector<BranchDescription const*> result; result.reserve(productList().size()); for(auto const& product : productList()) { result.push_back(&product.second); } return result; }
std::vector< std::string > edm::ProductRegistry::allBranchNames | ( | ) | const |
Definition at line 179 of file ProductRegistry.cc.
References productList(), query::result, and size().
Referenced by edm::ConstProductRegistry::allBranchNames().
{ std::vector<std::string> result; result.reserve(productList().size()); for(auto const& product : productList()) { result.push_back(product.second.branchName()); } return result; }
bool edm::ProductRegistry::anyProductProduced | ( | ) | const [inline] |
Definition at line 112 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::anyProductProduced_, and transient_.
Referenced by edm::ConstProductRegistry::anyProductProduced(), edm::Schedule::Schedule(), and edm::SubProcess::write().
{return transient_.anyProductProduced_;}
bool edm::ProductRegistry::anyProducts | ( | BranchType const | brType | ) | const |
Definition at line 131 of file ProductRegistry.cc.
References productList_, and throwIfNotFrozen().
{ throwIfNotFrozen(); for(ProductList::const_iterator it = productList_.begin(), itEnd = productList_.end(); it != itEnd; ++it) { if(it->second.branchType() == brType) { return true; } } return false; }
void edm::ProductRegistry::callForEachBranch | ( | T const & | iFunc | ) | [inline] |
Definition at line 86 of file ProductRegistry.h.
References productList_.
Referenced by edm::ProducerBase::registerProducts(), and edm::EDAnalyzer::registerProductsAndCallbacks().
{ //NOTE: If implementation changes from a map, need to check that iterators are still valid // after an insert with the new container, else need to copy the container and iterate over the copy for(ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(), itEntryEnd = productList_.end(); itEntry != itEntryEnd; ++itEntry) { iFunc(itEntry->second); } }
ConstProductList& edm::ProductRegistry::constProductList | ( | ) | const [inline] |
Definition at line 101 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::constProductList_, and transient_.
Referenced by initializeLookupTables(), and updateConstProductRegistry().
{ //throwIfNotFrozen(); return transient_.constProductList_; }
void edm::ProductRegistry::copyProduct | ( | BranchDescription const & | productdesc | ) |
Definition at line 116 of file ProductRegistry.cc.
References edm::combinable(), edm::BranchDescription::init(), gen::k, edm::BranchDescription::produced(), productList_, and throwIfFrozen().
Referenced by edm::DaqProvenanceHelper::daqInit(), edm::LHEProvenanceHelper::lheInit(), edm::RootFile::RootFile(), and updateFromInput().
{ assert(!productDesc.produced()); throwIfFrozen(); productDesc.init(); BranchKey k = BranchKey(productDesc); ProductList::iterator iter = productList_.find(k); if(iter == productList_.end()) { productList_.insert(std::make_pair(k, productDesc)); } else { assert(combinable(iter->second, productDesc)); iter->second.merge(productDesc); } }
bool& edm::ProductRegistry::frozen | ( | ) | const [inline, private] |
Definition at line 157 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::frozen_, and transient_.
Referenced by ProductRegistry(), setFrozen(), throwIfFrozen(), and throwIfNotFrozen().
{return transient_.frozen_;}
ProductHolderIndex const & edm::ProductRegistry::getNextIndexValue | ( | BranchType | branchType | ) | const |
Definition at line 339 of file ProductRegistry.cc.
References edm::ProductRegistry::Transients::eventNextIndexValue_, edm::InEvent, edm::InLumi, edm::ProductRegistry::Transients::lumiNextIndexValue_, edm::ProductRegistry::Transients::runNextIndexValue_, and transient_.
{ if (branchType == InEvent) return transient_.eventNextIndexValue_; if (branchType == InLumi) return transient_.lumiNextIndexValue_; return transient_.runNextIndexValue_; }
ProductHolderIndex edm::ProductRegistry::indexFrom | ( | BranchID const & | iID | ) | const |
Definition at line 324 of file ProductRegistry.cc.
References edm::ProductRegistry::Transients::branchIDToIndex_, edm::ProductHolderIndexInvalid, and transient_.
{ std::map<BranchID, ProductHolderIndex>::iterator itFind = transient_.branchIDToIndex_.find(iID); if(itFind == transient_.branchIDToIndex_.end()) { return ProductHolderIndexInvalid; } return itFind->second; }
void edm::ProductRegistry::initializeLookupTables | ( | ) | const [private] |
Definition at line 271 of file ProductRegistry.cc.
References edm::ProductRegistry::Transients::branchIDToIndex_, edm::TypeWithDict::byName(), constProductList(), edm::copy_all(), edm::ProductRegistry::Transients::eventNextIndexValue_, getHLTprescales::index, edm::InEvent, edm::InLumi, edm::InRun, edm::eventsetup::heterocontainer::insert(), combine::key, edm::ProductRegistry::Transients::lumiNextIndexValue_, missingDictionaries(), nextIndexValue(), productList_, productLookup(), edm::ProductRegistry::Transients::runNextIndexValue_, setProductProduced(), transient_, and edm::wrappedClassName().
Referenced by setFrozen().
{ StringSet missingDicts; transient_.branchIDToIndex_.clear(); constProductList().clear(); for(auto const& product : productList_) { auto const& key = product.first; auto const& desc = product.second; constProductList().insert(std::make_pair(key, ConstBranchDescription(desc))); if(desc.produced()) { setProductProduced(desc.branchType()); } //only do the following if the data is supposed to be available in the event if(desc.present()) { TypeWithDict type(TypeWithDict::byName(desc.className())); TypeWithDict wrappedType(TypeWithDict::byName(wrappedClassName(desc.className()))); if(!bool(type) || !bool(wrappedType)) { missingDicts.insert(desc.className()); } else { ProductHolderIndex index = productLookup(desc.branchType())->insert(type, desc.moduleLabel().c_str(), desc.productInstanceName().c_str(), desc.processName().c_str()); transient_.branchIDToIndex_[desc.branchID()] = index; } } } productLookup(InEvent)->setFrozen(); productLookup(InLumi)->setFrozen(); productLookup(InRun)->setFrozen(); transient_.eventNextIndexValue_ = productLookup(InEvent)->nextIndexValue(); transient_.lumiNextIndexValue_ = productLookup(InLumi)->nextIndexValue(); transient_.runNextIndexValue_ = productLookup(InRun)->nextIndexValue(); for(auto const& product : productList_) { auto const& desc = product.second; if (transient_.branchIDToIndex_.find(desc.branchID()) == transient_.branchIDToIndex_.end()) { transient_.branchIDToIndex_[desc.branchID()] = nextIndexValue(desc.branchType()); ++nextIndexValue(desc.branchType()); } } missingDictionaries().reserve(missingDicts.size()); copy_all(missingDicts, std::back_inserter(missingDictionaries())); }
void edm::ProductRegistry::initializeTransients | ( | ) | const [inline] |
Definition at line 125 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::reset(), and transient_.
{transient_.reset();}
std::string edm::ProductRegistry::merge | ( | ProductRegistry const & | other, |
std::string const & | fileName, | ||
BranchDescription::MatchMode | parametersMustMatch = BranchDescription::Permissive , |
||
BranchDescription::MatchMode | branchesMustMatch = BranchDescription::Permissive |
||
) |
Definition at line 215 of file ProductRegistry.cc.
References edm::ProductRegistry::Transients::branchIDToIndex_, alignCSCRings::e, i, j, edm::match(), nextIndexValue(), edm::BranchDescription::Permissive, productList(), productList_, alignCSCRings::s, edm::BranchDescription::Strict, AlCaHLTBitMon_QueryRunRegistry::string, transient_, and updateConstProductRegistry().
Referenced by edm::StreamerInputSource::mergeIntoRegistry(), edm::RootInputFileSequence::nextFile(), and edm::RootInputFileSequence::previousFile().
{ std::ostringstream differences; ProductRegistry::ProductList::iterator j = productList_.begin(); ProductRegistry::ProductList::iterator s = productList_.end(); ProductRegistry::ProductList::const_iterator i = other.productList().begin(); ProductRegistry::ProductList::const_iterator e = other.productList().end(); // Loop over entries in the main product registry. while(j != s || i != e) { if(j != s && j->second.produced()) { // Ignore branches just produced (i.e. not in input file). ++j; } else if(j == s || (i != e && i->first < j->first)) { if(i->second.present()) { differences << "Branch '" << i->second.branchName() << "' is in file '" << fileName << "'\n"; differences << " but not in previous files.\n"; } else { productList_.insert(*i); transient_.branchIDToIndex_[i->second.branchID()] = nextIndexValue(i->second.branchType()); ++nextIndexValue(i->second.branchType()); } ++i; } else if(i == e || (j != s && j->first < i->first)) { if(j->second.present() && branchesMustMatch == BranchDescription::Strict) { differences << "Branch '" << j->second.branchName() << "' is in previous files\n"; differences << " but not in file '" << fileName << "'.\n"; } ++j; } else { std::string difs = match(j->second, i->second, fileName, parametersMustMatch); if(difs.empty()) { if(parametersMustMatch == BranchDescription::Permissive) j->second.merge(i->second); } else { differences << difs; } ++i; ++j; } } updateConstProductRegistry(); return differences.str(); }
std::vector<std::string>& edm::ProductRegistry::missingDictionaries | ( | ) | const [inline] |
Definition at line 119 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::missingDictionaries_, and transient_.
Referenced by initializeLookupTables().
{ return transient_.missingDictionaries_; }
ProductHolderIndex & edm::ProductRegistry::nextIndexValue | ( | BranchType | branchType | ) | const [private] |
Definition at line 346 of file ProductRegistry.cc.
References edm::ProductRegistry::Transients::eventNextIndexValue_, edm::InEvent, edm::InLumi, edm::ProductRegistry::Transients::lumiNextIndexValue_, edm::ProductRegistry::Transients::runNextIndexValue_, and transient_.
Referenced by initializeLookupTables(), and merge().
{ if (branchType == InEvent) return transient_.eventNextIndexValue_; if (branchType == InLumi) return transient_.lumiNextIndexValue_; return transient_.runNextIndexValue_; }
void edm::ProductRegistry::print | ( | std::ostream & | os | ) | const |
Definition at line 332 of file ProductRegistry.cc.
References productList_.
Referenced by edm::operator<<().
{ for(auto const& product: productList_) { os << product.second << "\n-----\n"; } }
BranchListIndex edm::ProductRegistry::producedBranchListIndex | ( | ) | const [inline] |
Definition at line 113 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::producedBranchListIndex_, and transient_.
{return transient_.producedBranchListIndex_;}
ProductList const& edm::ProductRegistry::productList | ( | ) | const [inline] |
Definition at line 62 of file ProductRegistry.h.
References productList_.
Referenced by edm::Principal::adjustToNewProductRegistry(), allBranchDescriptions(), allBranchNames(), edm::fillProductRegistryTransients(), merge(), edm::operator==(), edm::ConstProductRegistry::productList(), edm::registryIsSubset(), edm::RootFile::RootFile(), edm::Schedule::Schedule(), edm::OutputModule::selectProducts(), fwlite::internal::BranchMapReaderStrategyV11::updateFile(), fwlite::internal::BranchMapReaderStrategyV17::updateFile(), fwlite::internal::BranchMapReaderStrategyV8::updateFile(), fwlite::internal::BranchMapReaderStrategyV1::updateMap(), edm::BranchIDListHelper::updateRegistries(), ProvenanceDumper::work_(), and edm::ProvenanceCheckerOutputModule::write().
{ //throwIfNotFrozen(); return productList_; }
ProductList& edm::ProductRegistry::productListUpdator | ( | ) | [inline] |
Definition at line 67 of file ProductRegistry.h.
References productList_, and throwIfFrozen().
Referenced by edm::RootFile::RootFile().
{ throwIfFrozen(); return productList_; }
boost::shared_ptr< ProductHolderIndexHelper > const & edm::ProductRegistry::productLookup | ( | BranchType | branchType | ) | const |
Definition at line 143 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::Schedule::beginJob(), and initializeLookupTables().
{ if (branchType == InEvent) return transient_.eventProductLookup_; if (branchType == InLumi) return transient_.lumiProductLookup_; return transient_.runProductLookup_; }
bool edm::ProductRegistry::productProduced | ( | BranchType | branchType | ) | const [inline] |
Definition at line 111 of file ProductRegistry.h.
References revisionDML::branchType(), edm::ProductRegistry::Transients::productProduced_, and transient_.
{return transient_.productProduced_[branchType];}
void edm::ProductRegistry::setFrozen | ( | bool | initializeLookupInfo = true | ) | const |
Definition at line 150 of file ProductRegistry.cc.
References frozen(), and initializeLookupTables().
Referenced by edm::Schedule::Schedule().
{ if(frozen()) return; frozen() = true; if(initializeLookupInfo) { initializeLookupTables(); } }
void edm::ProductRegistry::setProducedBranchListIndex | ( | BranchListIndex | blix | ) | const [inline] |
Definition at line 115 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::producedBranchListIndex_, and transient_.
Referenced by edm::BranchIDListHelper::updateRegistries().
{ transient_.producedBranchListIndex_ = blix; }
void edm::ProductRegistry::setProductProduced | ( | BranchType | branchType | ) | const [inline, private] |
Definition at line 152 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::anyProductProduced_, revisionDML::branchType(), edm::ProductRegistry::Transients::productProduced_, and transient_.
Referenced by initializeLookupTables().
{ transient_.productProduced_[branchType] = true; transient_.anyProductProduced_ = true; }
ProductList::size_type edm::ProductRegistry::size | ( | void | ) | const [inline] |
Definition at line 95 of file ProductRegistry.h.
References productList_.
Referenced by allBranchDescriptions(), and allBranchNames().
{return productList_.size();}
void edm::ProductRegistry::throwIfFrozen | ( | ) | const [private] |
Definition at line 159 of file ProductRegistry.cc.
References Exception, and frozen().
Referenced by addLabelAlias(), addProduct(), copyProduct(), and productListUpdator().
{ if(frozen()) { throw cms::Exception("ProductRegistry", "throwIfFrozen") << "cannot modify the ProductRegistry because it is frozen\n"; } }
void edm::ProductRegistry::throwIfNotFrozen | ( | ) | const [private] |
Definition at line 167 of file ProductRegistry.cc.
References Exception, and frozen().
Referenced by anyProducts().
{ if(!frozen()) { throw cms::Exception("ProductRegistry", "throwIfNotFrozen") << "cannot read the ProductRegistry because it is not yet frozen\n"; } }
void edm::ProductRegistry::updateConstProductRegistry | ( | ) | [private] |
Definition at line 262 of file ProductRegistry.cc.
References constProductList(), combine::key, and productList_.
Referenced by merge().
{ constProductList().clear(); for(auto const& product : productList_) { auto const& key = product.first; auto const& desc = product.second; constProductList().insert(std::make_pair(key, ConstBranchDescription(desc))); } }
void edm::ProductRegistry::updateFromInput | ( | ProductList const & | other | ) |
Definition at line 201 of file ProductRegistry.cc.
References copyProduct().
Referenced by edm::StreamerInputSource::mergeIntoRegistry(), and edm::RootInputFileSequence::RootInputFileSequence().
{ for(auto const& product : other) { copyProduct(product.second); } }
void edm::ProductRegistry::updateFromInput | ( | std::vector< BranchDescription > const & | other | ) |
Definition at line 208 of file ProductRegistry.cc.
References copyProduct().
{ for(BranchDescription const& branchDescription : other) { copyProduct(branchDescription); } }
Definition at line 167 of file ProductRegistry.h.
Referenced by addLabelAlias(), addProduct(), anyProducts(), callForEachBranch(), copyProduct(), initializeLookupTables(), merge(), print(), productList(), productListUpdator(), size(), and updateConstProductRegistry().
Transients edm::ProductRegistry::transient_ [mutable, private] |
Definition at line 168 of file ProductRegistry.h.
Referenced by anyProductProduced(), constProductList(), frozen(), getNextIndexValue(), indexFrom(), initializeLookupTables(), initializeTransients(), merge(), missingDictionaries(), nextIndexValue(), producedBranchListIndex(), productLookup(), productProduced(), setProducedBranchListIndex(), and setProductProduced().