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< 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)
 
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< TypeID > const & missingDictionaries () const
 
std::vector< TypeID > & 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 30 of file ProductRegistry.h.

Member Typedef Documentation

Definition at line 44 of file ProductRegistry.h.

Definition at line 33 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 42 of file ProductRegistry.h.

42 {}

Member Function Documentation

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

Reimplemented in edm::SignallingProductRegistry.

Definition at line 176 of file ProductRegistry.cc.

Referenced by addLabelAlias(), and addProduct().

176  {
177  }
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::ProductRegistry::Transients::aliasToOriginal_, assert(), edm::BranchDescription::branchID(), edm::BranchID::isValid(), edm::BranchDescription::moduleLabel(), edm::BranchDescription::produced(), productList_, run_regression::ret, throwIfFrozen(), and transient_.

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  transient_.aliasToOriginal_.emplace_back(labelAlias,
112  productDesc.moduleLabel());
113  addCalled(bd, false);
114  }
assert(m_qm.get())
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 85 of file ProductRegistry.cc.

References addCalled(), assert(), 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  }
assert(m_qm.get())
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 122 of file ProductRegistry.h.

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

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

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

191  {
192  std::vector<BranchDescription const*> result;
193  result.reserve(productList().size());
194 
195  for(auto const& product : productList()) {
196  result.push_back(&product.second);
197  }
198  return result;
199  }
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 180 of file ProductRegistry.cc.

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

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

180  {
181  std::vector<std::string> result;
182  result.reserve(productList().size());
183 
184  for(auto const& product : productList()) {
185  result.push_back(product.second.branchName());
186  }
187  return result;
188  }
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 131 of file ProductRegistry.cc.

References productList_, and throwIfNotFrozen().

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

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

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

Definition at line 101 of file ProductRegistry.h.

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

Referenced by initializeLookupTables(), and updateConstProductRegistry().

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

Definition at line 117 of file ProductRegistry.cc.

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

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

117  {
118  assert(!productDesc.produced());
119  throwIfFrozen();
120  BranchKey k = BranchKey(productDesc);
121  ProductList::iterator iter = productList_.find(k);
122  if(iter == productList_.end()) {
123  productList_.insert(std::make_pair(k, productDesc));
124  } else {
125  assert(combinable(iter->second, productDesc));
126  iter->second.merge(productDesc);
127  }
128  }
assert(m_qm.get())
bool combinable(BranchDescription const &a, BranchDescription const &b)
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 337 of file ProductRegistry.cc.

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

337  {
338  std::map<BranchID, ProductHolderIndex>::const_iterator itFind = transient_.branchIDToIndex_.find(iID);
339  if(itFind == transient_.branchIDToIndex_.end()) {
341  }
342  return itFind->second;
343  }
std::map< BranchID, ProductHolderIndex > branchIDToIndex_
void edm::ProductRegistry::initializeLookupTables ( )
private

Definition at line 271 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::branchIDToIndex_, constProductList(), edm::copy_all(), edm::ProductRegistry::Transients::eventNextIndexValue_, edm::productholderindexhelper::getContainedTypeFromWrapper(), getNextIndexValue(), cmsHarvester::index, edm::InEvent, edm::InLumi, edm::InRun, edm::eventsetup::heterocontainer::insert(), getDQMSummary::iter, relval_steps::key, edm::ProductRegistry::Transients::lumiNextIndexValue_, missingDictionariesForUpdate(), nextIndexValue(), productList_, productLookup(), edm::ProductRegistry::Transients::runNextIndexValue_, setProductProduced(), and transient_.

Referenced by setFrozen().

271  {
272 
273  std::map<TypeID, TypeID> containedTypeMap;
274  TypeSet missingDicts;
275 
277  constProductList().clear();
278 
279  for(auto const& product : productList_) {
280  auto const& key = product.first;
281  auto const& desc = product.second;
282 
283  constProductList().insert(std::make_pair(key, BranchDescription(desc)));
284 
285  if(desc.produced()) {
286  setProductProduced(desc.branchType());
287  }
288 
289  //only do the following if the data is supposed to be available in the event
290  if(desc.present()) {
291  if(!bool(desc.unwrappedType())) {
292  missingDicts.insert(TypeID(desc.unwrappedType().typeInfo()));
293  } else if(!bool(desc.wrappedType())) {
294  missingDicts.insert(TypeID(desc.wrappedType().typeInfo()));
295  } else {
296  TypeID wrappedTypeID(desc.wrappedType().typeInfo());
297  TypeID typeID(desc.unwrappedType().typeInfo());
298  TypeID containedTypeID;
299  auto const& iter = containedTypeMap.find(typeID);
300  if(iter != containedTypeMap.end()) {
301  containedTypeID = iter->second;
302  } else {
303  containedTypeID = productholderindexhelper::getContainedTypeFromWrapper(wrappedTypeID, typeID.className());
304  containedTypeMap.emplace(typeID, containedTypeID);
305  }
307  productLookup(desc.branchType())->insert(typeID,
308  desc.moduleLabel().c_str(),
309  desc.productInstanceName().c_str(),
310  desc.processName().c_str(),
311  containedTypeID);
312 
313  transient_.branchIDToIndex_[desc.branchID()] = index;
314  }
315  }
316  }
317  productLookup(InEvent)->setFrozen();
318  productLookup(InLumi)->setFrozen();
319  productLookup(InRun)->setFrozen();
320 
322  transient_.lumiNextIndexValue_ = productLookup(InLumi)->nextIndexValue();
323  transient_.runNextIndexValue_ = productLookup(InRun)->nextIndexValue();
324 
325  for(auto const& product : productList_) {
326  auto const& desc = product.second;
327  if (transient_.branchIDToIndex_.find(desc.branchID()) == transient_.branchIDToIndex_.end()) {
328  transient_.branchIDToIndex_[desc.branchID()] = getNextIndexValue(desc.branchType());
329  ++nextIndexValue(desc.branchType());
330  }
331  }
332 
333  missingDictionariesForUpdate().reserve(missingDicts.size());
334  copy_all(missingDicts, std::back_inserter(missingDictionariesForUpdate()));
335  }
void setProductProduced(BranchType branchType)
ProductHolderIndex & nextIndexValue(BranchType branchType)
std::vector< TypeID > & missingDictionariesForUpdate()
TypeID getContainedTypeFromWrapper(TypeID const &wrappedtypeID, std::string const &className)
std::shared_ptr< ProductHolderIndexHelper > const & productLookup(BranchType branchType) const
ProductHolderIndex eventNextIndexValue_
unsigned int ProductHolderIndex
ProductHolderIndex const & getNextIndexValue(BranchType branchType) const
ConstProductList & constProductList()
std::set< TypeID > TypeSet
ProductHolderIndex lumiNextIndexValue_
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
ProductHolderIndex runNextIndexValue_
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 216 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().

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

Definition at line 114 of file ProductRegistry.h.

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

114  {
116  }
std::vector< TypeID > missingDictionaries_
std::vector<TypeID>& edm::ProductRegistry::missingDictionariesForUpdate ( )
inline

Definition at line 118 of file ProductRegistry.h.

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

Referenced by initializeLookupTables().

118  {
120  }
std::vector< TypeID > missingDictionaries_
ProductHolderIndex & edm::ProductRegistry::nextIndexValue ( BranchType  branchType)
private
void edm::ProductRegistry::print ( std::ostream &  os) const

Definition at line 345 of file ProductRegistry.cc.

References productList_.

Referenced by edm::operator<<().

345  {
346  for(auto const& product: productList_) {
347  os << product.second << "\n-----\n";
348  }
349  }
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 95 of file ProductRegistry.h.

References productList_.

Referenced by allBranchDescriptions(), and allBranchNames().

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

Definition at line 160 of file ProductRegistry.cc.

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

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

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

Definition at line 168 of file ProductRegistry.cc.

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

Referenced by anyProducts().

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

Definition at line 262 of file ProductRegistry.cc.

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

Referenced by merge().

262  {
263  constProductList().clear();
264  for(auto const& product : productList_) {
265  auto const& key = product.first;
266  auto const& desc = product.second;
267  constProductList().insert(std::make_pair(key, BranchDescription(desc)));
268  }
269  }
ConstProductList & constProductList()
void edm::ProductRegistry::updateFromInput ( ProductList const &  other)

Definition at line 202 of file ProductRegistry.cc.

References copyProduct().

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

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

Definition at line 209 of file ProductRegistry.cc.

References copyProduct().

209  {
210  for(BranchDescription const& branchDescription : other) {
211  copyProduct(branchDescription);
212  }
213  }
void copyProduct(BranchDescription const &productdesc)

Member Data Documentation

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