author Stefano ARGIRO author Bill Tanenbaum More...
#include <edm/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) |
TransientProductLookupMap & | elementLookup () const |
ProductTransientIndex | 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 () |
TransientProductLookupMap & | productLookup () 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 (std::vector< BranchDescription > const &other) |
void | updateFromInput (ProductList const &other) |
virtual | ~ProductRegistry () |
Static Public Attributes | |
static ProductTransientIndex const | kInvalidIndex = 0xFFFFFFFF |
Private Member Functions | |
virtual void | addCalled (BranchDescription const &, bool iFromListener) |
bool & | frozen () const |
void | initializeLookupTables () const |
void | setProductProduced (BranchType branchType) const |
void | throwIfFrozen () const |
void | throwIfNotFrozen () const |
Private Attributes | |
ProductList | productList_ |
Transients | transient_ |
author Stefano ARGIRO author Bill Tanenbaum
Definition at line 40 of file ProductRegistry.h.
typedef std::map<BranchKey, ConstBranchDescription> edm::ProductRegistry::ConstProductList |
Definition at line 54 of file ProductRegistry.h.
typedef std::map<BranchKey, BranchDescription> edm::ProductRegistry::ProductList |
Definition at line 43 of file ProductRegistry.h.
edm::ProductRegistry::ProductRegistry | ( | ) |
Definition at line 36 of file ProductRegistry.cc.
: productList_(), transient_() { }
edm::ProductRegistry::ProductRegistry | ( | ProductList const & | productList, |
bool | toBeFrozen = true |
||
) | [explicit] |
Definition at line 67 of file ProductRegistry.cc.
References frozen().
: productList_(productList), transient_() { frozen() = toBeFrozen; }
virtual edm::ProductRegistry::~ProductRegistry | ( | ) | [inline, virtual] |
Definition at line 52 of file ProductRegistry.h.
{}
void edm::ProductRegistry::addCalled | ( | BranchDescription const & | , |
bool | iFromListener | ||
) | [private, virtual] |
Reimplemented in edm::SignallingProductRegistry.
Definition at line 156 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 90 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 74 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 171 of file ProductRegistry.cc.
References productList(), query::result, and size().
Referenced by edm::ConstProductRegistry::allBranchDescriptions().
{ 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 160 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 126 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 119 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 97 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 112 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::constProductList_, and transient_.
Referenced by edm::Principal::adjustToNewProductRegistry(), and initializeLookupTables().
{ //throwIfNotFrozen(); return transient_.constProductList_; }
void edm::ProductRegistry::copyProduct | ( | BranchDescription const & | productdesc | ) |
Definition at line 104 of file ProductRegistry.cc.
References edm::combinable(), edm::BranchDescription::init(), gen::k, edm::BranchDescription::produced(), productList_, and throwIfFrozen().
Referenced by edm::DaqProvenanceHelper::daqInit(), 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); } }
TransientProductLookupMap& edm::ProductRegistry::elementLookup | ( | ) | const [inline] |
Definition at line 119 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::elementLookup_, and transient_.
Referenced by initializeLookupTables().
{return transient_.elementLookup_;}
bool& edm::ProductRegistry::frozen | ( | ) | const [inline, private] |
Definition at line 168 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::frozen_, and transient_.
Referenced by ProductRegistry(), setFrozen(), throwIfFrozen(), and throwIfNotFrozen().
{return transient_.frozen_;}
ProductTransientIndex edm::ProductRegistry::indexFrom | ( | BranchID const & | iID | ) | const |
Definition at line 330 of file ProductRegistry.cc.
References edm::ProductRegistry::Transients::branchIDToIndex_, kInvalidIndex, and transient_.
{ std::map<BranchID, ProductTransientIndex>::iterator itFind = transient_.branchIDToIndex_.find(iID); if(itFind == transient_.branchIDToIndex_.end()) { return kInvalidIndex; } return itFind->second; }
void edm::ProductRegistry::initializeLookupTables | ( | ) | const [private] |
Definition at line 251 of file ProductRegistry.cc.
References edm::ProductRegistry::Transients::branchIDToIndex_, edm::TypeWithDict::byName(), constProductList(), edm::copy_all(), elementLookup(), edm::TransientProductLookupMap::fillFrom(), edm::fillLookup(), edm::foundTypes(), getHLTprescales::index, edm::is_PtrVector(), edm::is_RefToBaseVector(), edm::is_RefVector(), combine::key, missingDictionaries(), edm::missingTypes(), edm::ConstBranchDescription::processName(), productList_, productLookup(), edm::public_base_classes(), setProductProduced(), transient_, edm::value_type_of(), and edm::wrappedClassName().
Referenced by merge(), and setFrozen().
{ StringSet savedMissingTypes; savedMissingTypes.swap(missingTypes()); StringSet savedFoundTypes; savedFoundTypes.swap(foundTypes()); constProductList().clear(); transient_.branchIDToIndex_.clear(); ProductTransientIndex index = 0; //NOTE it might be possible to remove the need for this temporary map because the productList is ordered by the // BranchKey and for the same C++ class type the BranchKey will sort just like CompareTypeInBranchTypeConstBranchDescription typedef TransientProductLookupMap::FillFromMap TempLookupMap; TempLookupMap tempProductLookupMap; TempLookupMap tempElementLookupMap; StringSet usedProcessNames; StringSet missingDicts; for(auto const& product : productList_) { auto const& key = product.first; auto const& desc = product.second; if(desc.produced()) { setProductProduced(desc.branchType()); } //insert returns a pair<iterator, bool> and we want the address of the ConstBranchDescription that was created in the map // this is safe since items in a map always retain their memory address ConstBranchDescription const* pBD = &(constProductList().insert(std::make_pair(key, ConstBranchDescription(desc))).first->second); transient_.branchIDToIndex_[desc.branchID()] = index; usedProcessNames.insert(pBD->processName()); //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 { fillLookup(type, index, pBD, tempProductLookupMap); if(bool(type)) { // Here we look in the object named "type" for a typedef // named "value_type" and get the type for it. // Then check to ensure the dictionary is defined // for this value_type. // I do not throw an exception here if the check fails // because there are known cases where the dictionary does // not exist and we do not need to support those cases. TypeWithDict valueType; if((is_RefVector(type, valueType) || is_PtrVector(type, valueType) || is_RefToBaseVector(type, valueType) || value_type_of(type, valueType)) && bool(valueType)) { fillLookup(valueType, index, pBD, tempElementLookupMap); // Repeat this for all public base classes of the value_type std::vector<TypeWithDict> baseTypes; public_base_classes(valueType, baseTypes); for(TypeWithDict const& baseType : baseTypes) { fillLookup(baseType, index, pBD, tempElementLookupMap); } } } } } ++index; } missingDictionaries().reserve(missingDicts.size()); copy_all(missingDicts, std::back_inserter(missingDictionaries())); productLookup().fillFrom(tempProductLookupMap); elementLookup().fillFrom(tempElementLookupMap); savedMissingTypes.swap(missingTypes()); savedFoundTypes.swap(foundTypes()); }
void edm::ProductRegistry::initializeTransients | ( | ) | const [inline] |
Definition at line 137 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 196 of file ProductRegistry.cc.
References alignCSCRings::e, i, initializeLookupTables(), j, edm::match(), edm::BranchDescription::Permissive, productList(), productList_, alignCSCRings::s, edm::BranchDescription::Strict, and AlCaHLTBitMon_QueryRunRegistry::string.
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); } ++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; } } initializeLookupTables(); return differences.str(); }
std::vector<std::string>& edm::ProductRegistry::missingDictionaries | ( | ) | const [inline] |
Definition at line 133 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::missingDictionaries_, and transient_.
Referenced by initializeLookupTables().
{ return transient_.missingDictionaries_; }
void edm::ProductRegistry::print | ( | std::ostream & | os | ) | const |
Definition at line 338 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 127 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::producedBranchListIndex_, and transient_.
{return transient_.producedBranchListIndex_;}
ProductList const& edm::ProductRegistry::productList | ( | ) | const [inline] |
Definition at line 73 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(), 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 78 of file ProductRegistry.h.
References productList_, and throwIfFrozen().
Referenced by edm::RootFile::RootFile().
{ throwIfFrozen(); return productList_; }
TransientProductLookupMap& edm::ProductRegistry::productLookup | ( | ) | const [inline] |
Definition at line 117 of file ProductRegistry.h.
References edm::ProductRegistry::Transients::productLookup_, and transient_.
Referenced by initializeLookupTables().
{return transient_.productLookup_;}
bool edm::ProductRegistry::productProduced | ( | BranchType | branchType | ) | const [inline] |
Definition at line 125 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 131 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 129 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 163 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 106 of file ProductRegistry.h.
References productList_.
Referenced by allBranchDescriptions(), and allBranchNames().
{return productList_.size();}
void edm::ProductRegistry::throwIfFrozen | ( | ) | const [private] |
Definition at line 140 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 148 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::updateFromInput | ( | std::vector< BranchDescription > const & | other | ) |
Definition at line 189 of file ProductRegistry.cc.
References copyProduct().
{ for(BranchDescription const& branchDescription : other) { copyProduct(branchDescription); } }
void edm::ProductRegistry::updateFromInput | ( | ProductList const & | other | ) |
Definition at line 182 of file ProductRegistry.cc.
References copyProduct().
Referenced by edm::StreamerInputSource::mergeIntoRegistry(), and edm::RootInputFileSequence::RootInputFileSequence().
{ for(auto const& product : other) { copyProduct(product.second); } }
ProductTransientIndex const edm::ProductRegistry::kInvalidIndex = 0xFFFFFFFF [static] |
Definition at line 122 of file ProductRegistry.h.
Referenced by edm::Principal::addGroup_(), edm::Principal::addGroupAliased(), edm::Principal::adjustIndexesAfterProductRegistryAddition(), edm::Principal::getExistingGroup(), edm::Principal::getGroup(), indexFrom(), and edm::Principal::recombine().
Definition at line 175 of file ProductRegistry.h.
Referenced by addLabelAlias(), addProduct(), anyProducts(), callForEachBranch(), copyProduct(), initializeLookupTables(), merge(), print(), productList(), productListUpdator(), and size().
Transients edm::ProductRegistry::transient_ [mutable, private] |
Definition at line 176 of file ProductRegistry.h.
Referenced by anyProductProduced(), constProductList(), elementLookup(), frozen(), indexFrom(), initializeLookupTables(), initializeTransients(), missingDictionaries(), producedBranchListIndex(), productLookup(), productProduced(), setProducedBranchListIndex(), and setProductProduced().