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,
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)
 
ConstProductListconstProductList () 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
 
ProductListproductListUpdator ()
 
boost::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) 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
 
ProductHolderIndexnextIndexValue (BranchType branchType) const
 
void setProductProduced (BranchType branchType) const
 
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 38 of file ProductRegistry.cc.

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

Definition at line 79 of file ProductRegistry.cc.

References frozen().

79  :
81  transient_() {
82  frozen() = toBeFrozen;
83  }
ProductList const & productList() const
bool & frozen() const
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 175 of file ProductRegistry.cc.

Referenced by addLabelAlias(), and addProduct().

175  {
176  }
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().

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

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

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

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

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

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

179  {
180  std::vector<std::string> result;
181  result.reserve(productList().size());
182 
183  for(auto const& product : productList()) {
184  result.push_back(product.second.branchName());
185  }
186  return result;
187  }
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(), and edm::EDAnalyzer::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 ( ) const
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 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().

116  {
117  assert(!productDesc.produced());
118  throwIfFrozen();
119  productDesc.init();
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  }
bool combinable(BranchDescription const &a, BranchDescription const &b)
int k[5][pyjets_maxn]
void throwIfFrozen() const
bool& edm::ProductRegistry::frozen ( ) const
inlineprivate
ProductHolderIndex const & edm::ProductRegistry::getNextIndexValue ( BranchType  branchType) const
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_.

324  {
325  std::map<BranchID, ProductHolderIndex>::iterator itFind = transient_.branchIDToIndex_.find(iID);
326  if(itFind == transient_.branchIDToIndex_.end()) {
328  }
329  return itFind->second;
330  }
std::map< BranchID, ProductHolderIndex > branchIDToIndex_
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().

271  {
272 
273  StringSet missingDicts;
275  constProductList().clear();
276 
277  for(auto const& product : productList_) {
278  auto const& key = product.first;
279  auto const& desc = product.second;
280 
281  constProductList().insert(std::make_pair(key, ConstBranchDescription(desc)));
282 
283  if(desc.produced()) {
284  setProductProduced(desc.branchType());
285  }
286 
287  //only do the following if the data is supposed to be available in the event
288  if(desc.present()) {
289  TypeWithDict type(TypeWithDict::byName(desc.className()));
290  TypeWithDict wrappedType(TypeWithDict::byName(wrappedClassName(desc.className())));
291  if(!bool(type) || !bool(wrappedType)) {
292  missingDicts.insert(desc.className());
293  } else {
295  productLookup(desc.branchType())->insert(type,
296  desc.moduleLabel().c_str(),
297  desc.productInstanceName().c_str(),
298  desc.processName().c_str());
299 
300  transient_.branchIDToIndex_[desc.branchID()] = index;
301  }
302  }
303  }
304  productLookup(InEvent)->setFrozen();
305  productLookup(InLumi)->setFrozen();
306  productLookup(InRun)->setFrozen();
307 
309  transient_.lumiNextIndexValue_ = productLookup(InLumi)->nextIndexValue();
310  transient_.runNextIndexValue_ = productLookup(InRun)->nextIndexValue();
311 
312  for(auto const& product : productList_) {
313  auto const& desc = product.second;
314  if (transient_.branchIDToIndex_.find(desc.branchID()) == transient_.branchIDToIndex_.end()) {
315  transient_.branchIDToIndex_[desc.branchID()] = nextIndexValue(desc.branchType());
316  ++nextIndexValue(desc.branchType());
317  }
318  }
319 
320  missingDictionaries().reserve(missingDicts.size());
321  copy_all(missingDicts, std::back_inserter(missingDictionaries()));
322  }
type
Definition: HCALResponse.h:21
static TypeWithDict byName(std::string const &className)
void setProductProduced(BranchType branchType) const
ConstProductList & constProductList() const
ProductHolderIndex eventNextIndexValue_
unsigned int ProductHolderIndex
boost::shared_ptr< ProductHolderIndexHelper > const & productLookup(BranchType branchType) const
std::vector< std::string > & missingDictionaries() const
std::set< std::string > StringSet
ProductHolderIndex lumiNextIndexValue_
bool insert(Storage &iStorage, ItemType *iItem, const IdTag &iIdTag)
Definition: HCMethods.h:49
ProductHolderIndex runNextIndexValue_
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_
ProductHolderIndex & nextIndexValue(BranchType branchType) const
void edm::ProductRegistry::initializeTransients ( ) const
inline
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().

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()] = nextIndexValue(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, parametersMustMatch);
249  if(difs.empty()) {
250  if(parametersMustMatch == BranchDescription::Permissive) 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
std::string match(BranchDescription const &a, BranchDescription const &b, std::string const &fileName, BranchDescription::MatchMode m)
int j
Definition: DBlmapReader.cc:9
std::map< BranchID, ProductHolderIndex > branchIDToIndex_
ProductHolderIndex & nextIndexValue(BranchType branchType) const
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().

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

Definition at line 332 of file ProductRegistry.cc.

References productList_.

Referenced by edm::operator<<().

332  {
333  for(auto const& product: productList_) {
334  os << product.second << "\n-----\n";
335  }
336  }
BranchListIndex edm::ProductRegistry::producedBranchListIndex ( ) const
inline
ProductList const& edm::ProductRegistry::productList ( ) const
inline
ProductList& edm::ProductRegistry::productListUpdator ( )
inline

Definition at line 67 of file ProductRegistry.h.

References productList_, and throwIfFrozen().

Referenced by edm::RootFile::dropOnInput(), edm::PoolSource::PoolSource(), and edm::RootFile::RootFile().

67  {
68  throwIfFrozen();
69  return productList_;
70  }
void throwIfFrozen() const
boost::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) const

Definition at line 150 of file ProductRegistry.cc.

References frozen(), and initializeLookupTables().

Referenced by edm::Schedule::Schedule().

150  {
151  if(frozen()) return;
152  frozen() = true;
153  if(initializeLookupInfo) {
155  }
156  }
void initializeLookupTables() const
bool & frozen() const
void edm::ProductRegistry::setProducedBranchListIndex ( BranchListIndex  blix) const
inline
void edm::ProductRegistry::setProductProduced ( BranchType  branchType) const
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 159 of file ProductRegistry.cc.

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

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

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

Definition at line 167 of file ProductRegistry.cc.

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

Referenced by anyProducts().

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

Definition at line 262 of file ProductRegistry.cc.

References constProductList(), combine::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, ConstBranchDescription(desc)));
268  }
269  }
ConstProductList & constProductList() const
list key
Definition: combine.py:13
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().

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

Definition at line 208 of file ProductRegistry.cc.

References copyProduct().

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

Member Data Documentation

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