CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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,
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)
 
ConstProductListconstProductList ()
 
void copyProduct (BranchDescription const &productdesc)
 
bool frozen () const
 
ProductHolderIndex const & getNextIndexValue (BranchType branchType) const
 
ProductHolderIndex indexFrom (BranchID const &iID) const
 
void initializeTransients ()
 
std::string merge (ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
 
std::vector< std::string > const & missingDictionaries () const
 
std::vector< std::string > & missingDictionariesForUpdate ()
 
void print (std::ostream &os) const
 
ProductList const & productList () const
 
ProductListproductListUpdator ()
 
std::shared_ptr
< ProductHolderIndexHelper >
const & 
productLookup (BranchType branchType) const
 
bool productProduced (BranchType branchType) const
 
 ProductRegistry ()
 
 ProductRegistry (ProductList const &productList, bool toBeFrozen=true)
 
void setFrozen (bool initializeLookupInfo=true)
 
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 freezeIt (bool frozen=true)
 
void initializeLookupTables ()
 
ProductHolderIndexnextIndexValue (BranchType branchType)
 
void setProductProduced (BranchType branchType)
 
void throwIfFrozen () const
 
void throwIfNotFrozen () const
 
void updateConstProductRegistry ()
 

Private Attributes

ProductList productList_
 
Transients transient_
 

Detailed Description

author Stefano ARGIRO author Bill Tanenbaum

Date
19 Jul 2005

Definition at line 29 of file ProductRegistry.h.

Member Typedef Documentation

Definition at line 43 of file ProductRegistry.h.

Definition at line 32 of file ProductRegistry.h.

Constructor & Destructor Documentation

edm::ProductRegistry::ProductRegistry ( )

Definition at line 39 of file ProductRegistry.cc.

39  :
40  productList_(),
41  transient_() {
42  }
edm::ProductRegistry::ProductRegistry ( ProductList const &  productList,
bool  toBeFrozen = true 
)
explicit

Definition at line 78 of file ProductRegistry.cc.

References freezeIt().

78  :
80  transient_() {
81  freezeIt(toBeFrozen);
82  }
ProductList const & productList() const
void freezeIt(bool frozen=true)
virtual edm::ProductRegistry::~ProductRegistry ( )
inlinevirtual

Definition at line 41 of file ProductRegistry.h.

41 {}

Member Function Documentation

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

Reimplemented in edm::SignallingProductRegistry.

Definition at line 173 of file ProductRegistry.cc.

Referenced by addLabelAlias(), and addProduct().

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

Definition at line 101 of file ProductRegistry.cc.

References addCalled(), edm::BranchDescription::branchID(), edm::BranchID::isValid(), edm::BranchDescription::produced(), productList_, run_regression::ret, and throwIfFrozen().

103  {
104  assert(productDesc.produced());
105  assert(productDesc.branchID().isValid());
106  throwIfFrozen();
107  BranchDescription bd(productDesc, labelAlias, instanceAlias);
108  std::pair<ProductList::iterator, bool> ret =
109  productList_.insert(std::make_pair(BranchKey(bd), bd));
110  assert(ret.second);
111  addCalled(bd, false);
112  }
virtual void addCalled(BranchDescription const &, bool iFromListener)
void throwIfFrozen() const
void edm::ProductRegistry::addProduct ( BranchDescription const &  productdesc,
bool  iFromListener = false 
)

Definition at line 85 of file ProductRegistry.cc.

References addCalled(), edm::errors::Configuration, edm::hlt::Exception, edm::BranchDescription::processName(), edm::BranchDescription::produced(), productList_, run_regression::ret, and throwIfFrozen().

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

86  {
87  assert(productDesc.produced());
88  throwIfFrozen();
89  checkDicts(productDesc);
90  std::pair<ProductList::iterator, bool> ret =
91  productList_.insert(std::make_pair(BranchKey(productDesc), productDesc));
92  if(!ret.second) {
93  throw Exception(errors::Configuration, "Duplicate Process")
94  << "The process name " << productDesc.processName() << " was previously used on these products.\n"
95  << "Please modify the configuration file to use a distinct process name.\n";
96  }
97  addCalled(productDesc, fromListener);
98  }
virtual void addCalled(BranchDescription const &, bool iFromListener)
void throwIfFrozen() const
std::vector< BranchDescription const * > edm::ProductRegistry::allBranchDescriptions ( ) const

Definition at line 188 of file ProductRegistry.cc.

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

Referenced by edm::ConstProductRegistry::allBranchDescriptions(), edm::RootFile::dropOnInput(), edm::SubProcess::selectProducts(), edm::OutputModule::selectProducts(), and edm::one::OutputModuleBase::selectProducts().

188  {
189  std::vector<BranchDescription const*> result;
190  result.reserve(productList().size());
191 
192  for(auto const& product : productList()) {
193  result.push_back(&product.second);
194  }
195  return result;
196  }
ProductList::size_type size() const
ProductList const & productList() const
tuple result
Definition: query.py:137
std::vector< std::string > edm::ProductRegistry::allBranchNames ( ) const

Definition at line 177 of file ProductRegistry.cc.

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

Referenced by edm::ConstProductRegistry::allBranchNames().

177  {
178  std::vector<std::string> result;
179  result.reserve(productList().size());
180 
181  for(auto const& product : productList()) {
182  result.push_back(product.second.branchName());
183  }
184  return result;
185  }
ProductList::size_type size() const
ProductList const & productList() const
tuple result
Definition: query.py:137
bool edm::ProductRegistry::anyProductProduced ( ) const
inline
bool edm::ProductRegistry::anyProducts ( BranchType const  brType) const

Definition at line 129 of file ProductRegistry.cc.

References productList_, and throwIfNotFrozen().

129  {
131  for(ProductList::const_iterator it = productList_.begin(), itEnd = productList_.end();
132  it != itEnd; ++it) {
133  if(it->second.branchType() == brType) {
134  return true;
135  }
136  }
137  return false;
138  }
void throwIfNotFrozen() const
template<typename T >
void edm::ProductRegistry::callForEachBranch ( T const &  iFunc)
inline

Definition at line 85 of file ProductRegistry.h.

References productList_.

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

85  {
86  //NOTE: If implementation changes from a map, need to check that iterators are still valid
87  // after an insert with the new container, else need to copy the container and iterate over the copy
88  for(ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(),
89  itEntryEnd = productList_.end();
90  itEntry != itEntryEnd; ++itEntry) {
91  iFunc(itEntry->second);
92  }
93  }
ConstProductList& edm::ProductRegistry::constProductList ( )
inline

Definition at line 100 of file ProductRegistry.h.

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

Referenced by initializeLookupTables(), and updateConstProductRegistry().

100  {
101  //throwIfNotFrozen();
103  }
void edm::ProductRegistry::copyProduct ( BranchDescription const &  productdesc)

Definition at line 115 of file ProductRegistry.cc.

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

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

115  {
116  assert(!productDesc.produced());
117  throwIfFrozen();
118  BranchKey k = BranchKey(productDesc);
119  ProductList::iterator iter = productList_.find(k);
120  if(iter == productList_.end()) {
121  productList_.insert(std::make_pair(k, productDesc));
122  } else {
123  assert(combinable(iter->second, productDesc));
124  iter->second.merge(productDesc);
125  }
126  }
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
ProductHolderIndex const & edm::ProductRegistry::getNextIndexValue ( BranchType  branchType) const
ProductHolderIndex edm::ProductRegistry::indexFrom ( BranchID const &  iID) const

Definition at line 321 of file ProductRegistry.cc.

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

321  {
322  std::map<BranchID, ProductHolderIndex>::const_iterator itFind = transient_.branchIDToIndex_.find(iID);
323  if(itFind == transient_.branchIDToIndex_.end()) {
325  }
326  return itFind->second;
327  }
std::map< BranchID, ProductHolderIndex > branchIDToIndex_
void edm::ProductRegistry::initializeLookupTables ( )
private

Definition at line 268 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::branchIDToIndex_, edm::TypeWithDict::byName(), constProductList(), edm::copy_all(), edm::ProductRegistry::Transients::eventNextIndexValue_, getNextIndexValue(), cmsHarvester::index, edm::InEvent, edm::InLumi, edm::InRun, edm::eventsetup::heterocontainer::insert(), combine::key, edm::ProductRegistry::Transients::lumiNextIndexValue_, missingDictionariesForUpdate(), nextIndexValue(), productList_, productLookup(), edm::ProductRegistry::Transients::runNextIndexValue_, setProductProduced(), transient_, and edm::wrappedClassName().

Referenced by setFrozen().

268  {
269 
270  StringSet missingDicts;
272  constProductList().clear();
273 
274  for(auto const& product : productList_) {
275  auto const& key = product.first;
276  auto const& desc = product.second;
277 
278  constProductList().insert(std::make_pair(key, BranchDescription(desc)));
279 
280  if(desc.produced()) {
281  setProductProduced(desc.branchType());
282  }
283 
284  //only do the following if the data is supposed to be available in the event
285  if(desc.present()) {
286  TypeWithDict type(TypeWithDict::byName(desc.className()));
287  TypeWithDict wrappedType(TypeWithDict::byName(wrappedClassName(desc.className())));
288  if(!bool(type) || !bool(wrappedType)) {
289  missingDicts.insert(desc.className());
290  } else {
292  productLookup(desc.branchType())->insert(type,
293  desc.moduleLabel().c_str(),
294  desc.productInstanceName().c_str(),
295  desc.processName().c_str());
296 
297  transient_.branchIDToIndex_[desc.branchID()] = index;
298  }
299  }
300  }
301  productLookup(InEvent)->setFrozen();
302  productLookup(InLumi)->setFrozen();
303  productLookup(InRun)->setFrozen();
304 
306  transient_.lumiNextIndexValue_ = productLookup(InLumi)->nextIndexValue();
307  transient_.runNextIndexValue_ = productLookup(InRun)->nextIndexValue();
308 
309  for(auto const& product : productList_) {
310  auto const& desc = product.second;
311  if (transient_.branchIDToIndex_.find(desc.branchID()) == transient_.branchIDToIndex_.end()) {
312  transient_.branchIDToIndex_[desc.branchID()] = getNextIndexValue(desc.branchType());
313  ++nextIndexValue(desc.branchType());
314  }
315  }
316 
317  missingDictionariesForUpdate().reserve(missingDicts.size());
318  copy_all(missingDicts, std::back_inserter(missingDictionariesForUpdate()));
319  }
type
Definition: HCALResponse.h:21
void setProductProduced(BranchType branchType)
static TypeWithDict byName(std::string const &className)
ProductHolderIndex & nextIndexValue(BranchType branchType)
std::shared_ptr< ProductHolderIndexHelper > const & productLookup(BranchType branchType) const
ProductHolderIndex eventNextIndexValue_
unsigned int ProductHolderIndex
ProductHolderIndex const & getNextIndexValue(BranchType branchType) const
ConstProductList & constProductList()
std::set< std::string > StringSet
ProductHolderIndex lumiNextIndexValue_
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
ProductHolderIndex runNextIndexValue_
std::vector< std::string > & missingDictionariesForUpdate()
std::string wrappedClassName(std::string const &iFullName)
list key
Definition: combine.py:13
Func copy_all(ForwardSequence &s, Func f)
wrappers for copy
Definition: Algorithms.h:24
std::map< BranchID, ProductHolderIndex > 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 213 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::branchIDToIndex_, alignCSCRings::e, getNextIndexValue(), i, j, edm::match(), nextIndexValue(), 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().

215  {
216  std::ostringstream differences;
217 
218  ProductRegistry::ProductList::iterator j = productList_.begin();
219  ProductRegistry::ProductList::iterator s = productList_.end();
220  ProductRegistry::ProductList::const_iterator i = other.productList().begin();
221  ProductRegistry::ProductList::const_iterator e = other.productList().end();
222 
223  // Loop over entries in the main product registry.
224  while(j != s || i != e) {
225  if(j != s && j->second.produced()) {
226  // Ignore branches just produced (i.e. not in input file).
227  ++j;
228  } else if(j == s || (i != e && i->first < j->first)) {
229  if(i->second.present()) {
230  differences << "Branch '" << i->second.branchName() << "' is in file '" << fileName << "'\n";
231  differences << " but not in previous files.\n";
232  } else {
233  productList_.insert(*i);
234  transient_.branchIDToIndex_[i->second.branchID()] = getNextIndexValue(i->second.branchType());
235  ++nextIndexValue(i->second.branchType());
236  }
237  ++i;
238  } else if(i == e || (j != s && j->first < i->first)) {
239  if(j->second.present() && branchesMustMatch == BranchDescription::Strict) {
240  differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
241  differences << " but not in file '" << fileName << "'.\n";
242  }
243  ++j;
244  } else {
245  std::string difs = match(j->second, i->second, fileName);
246  if(difs.empty()) {
247  j->second.merge(i->second);
248  } else {
249  differences << difs;
250  }
251  ++i;
252  ++j;
253  }
254  }
256  return differences.str();
257  }
int i
Definition: DBlmapReader.cc:9
ProductHolderIndex & nextIndexValue(BranchType branchType)
ProductHolderIndex const & getNextIndexValue(BranchType branchType) const
int j
Definition: DBlmapReader.cc:9
std::map< BranchID, ProductHolderIndex > branchIDToIndex_
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName)
std::vector<std::string> const& edm::ProductRegistry::missingDictionaries ( ) const
inline

Definition at line 113 of file ProductRegistry.h.

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

113  {
115  }
std::vector< std::string > missingDictionaries_
std::vector<std::string>& edm::ProductRegistry::missingDictionariesForUpdate ( )
inline

Definition at line 117 of file ProductRegistry.h.

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

Referenced by initializeLookupTables().

117  {
119  }
std::vector< std::string > missingDictionaries_
ProductHolderIndex & edm::ProductRegistry::nextIndexValue ( BranchType  branchType)
private
void edm::ProductRegistry::print ( std::ostream &  os) const

Definition at line 329 of file ProductRegistry.cc.

References productList_.

Referenced by edm::operator<<().

329  {
330  for(auto const& product: productList_) {
331  os << product.second << "\n-----\n";
332  }
333  }
ProductList const& edm::ProductRegistry::productList ( ) const
inline
ProductList& edm::ProductRegistry::productListUpdator ( )
inline
std::shared_ptr< ProductHolderIndexHelper > const & edm::ProductRegistry::productLookup ( BranchType  branchType) const
bool edm::ProductRegistry::productProduced ( BranchType  branchType) const
inline
void edm::ProductRegistry::setFrozen ( bool  initializeLookupInfo = true)
void edm::ProductRegistry::setProductProduced ( BranchType  branchType)
inlineprivate
ProductList::size_type edm::ProductRegistry::size ( void  ) const
inline

Definition at line 94 of file ProductRegistry.h.

References productList_.

Referenced by allBranchDescriptions(), and allBranchNames().

94 {return productList_.size();}
void edm::ProductRegistry::throwIfFrozen ( ) const
private

Definition at line 157 of file ProductRegistry.cc.

References edm::hlt::Exception, and frozen().

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

157  {
158  if(frozen()) {
159  throw cms::Exception("ProductRegistry", "throwIfFrozen")
160  << "cannot modify the ProductRegistry because it is frozen\n";
161  }
162  }
void edm::ProductRegistry::throwIfNotFrozen ( ) const
private

Definition at line 165 of file ProductRegistry.cc.

References edm::hlt::Exception, and frozen().

Referenced by anyProducts().

165  {
166  if(!frozen()) {
167  throw cms::Exception("ProductRegistry", "throwIfNotFrozen")
168  << "cannot read the ProductRegistry because it is not yet frozen\n";
169  }
170  }
void edm::ProductRegistry::updateConstProductRegistry ( )
private

Definition at line 259 of file ProductRegistry.cc.

References constProductList(), combine::key, and productList_.

Referenced by merge().

259  {
260  constProductList().clear();
261  for(auto const& product : productList_) {
262  auto const& key = product.first;
263  auto const& desc = product.second;
264  constProductList().insert(std::make_pair(key, BranchDescription(desc)));
265  }
266  }
ConstProductList & constProductList()
list key
Definition: combine.py:13
void edm::ProductRegistry::updateFromInput ( ProductList const &  other)

Definition at line 199 of file ProductRegistry.cc.

References copyProduct().

Referenced by edm::StreamerInputSource::mergeIntoRegistry(), and edm::RootInputFileSequence::RootInputFileSequence().

199  {
200  for(auto const& product : other) {
201  copyProduct(product.second);
202  }
203  }
void copyProduct(BranchDescription const &productdesc)
void edm::ProductRegistry::updateFromInput ( std::vector< BranchDescription > const &  other)

Definition at line 206 of file ProductRegistry.cc.

References copyProduct().

206  {
207  for(BranchDescription const& branchDescription : other) {
208  copyProduct(branchDescription);
209  }
210  }
void copyProduct(BranchDescription const &productdesc)

Member Data Documentation

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