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)
 
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
 
std::shared_ptr
< ProductHolderIndexHelper
productLookup (BranchType branchType)
 
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
 

Private Attributes

ProductList productList_
 
Transients transient_
 

Detailed Description

author Stefano ARGIRO author Bill Tanenbaum

Date
19 Jul 2005

Definition at line 31 of file ProductRegistry.h.

Member Typedef Documentation

Definition at line 45 of file ProductRegistry.h.

Definition at line 34 of file ProductRegistry.h.

Constructor & Destructor Documentation

edm::ProductRegistry::ProductRegistry ( )

Definition at line 30 of file ProductRegistry.cc.

30  :
31  productList_(),
32  transient_() {
33  }
edm::ProductRegistry::ProductRegistry ( ProductList const &  productList,
bool  toBeFrozen = true 
)
explicit

Definition at line 70 of file ProductRegistry.cc.

References freezeIt().

70  :
72  transient_() {
73  freezeIt(toBeFrozen);
74  }
ProductList const & productList() const
void freezeIt(bool frozen=true)
virtual edm::ProductRegistry::~ProductRegistry ( )
inlinevirtual

Definition at line 43 of file ProductRegistry.h.

43 {}

Member Function Documentation

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

Reimplemented in edm::SignallingProductRegistry.

Definition at line 174 of file ProductRegistry.cc.

Referenced by addLabelAlias(), and addProduct().

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

Definition at line 92 of file ProductRegistry.cc.

References addCalled(), edm::ProductRegistry::Transients::aliasToOriginal_, assert(), edm::BranchDescription::branchID(), edm::BranchID::isValid(), edm::BranchDescription::moduleLabel(), edm::BranchDescription::produced(), productList_, runTheMatrix::ret, throwIfFrozen(), and transient_.

94  {
95  assert(productDesc.produced());
96  assert(productDesc.branchID().isValid());
97  throwIfFrozen();
98  BranchDescription bd(productDesc, labelAlias, instanceAlias);
99  std::pair<ProductList::iterator, bool> ret =
100  productList_.insert(std::make_pair(BranchKey(bd), bd));
101  assert(ret.second);
102  transient_.aliasToOriginal_.emplace_back(labelAlias,
103  productDesc.moduleLabel());
104  addCalled(bd, false);
105  }
tuple ret
prodAgent to be discontinued
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 77 of file ProductRegistry.cc.

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

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

78  {
79  assert(productDesc.produced());
80  throwIfFrozen();
81  std::pair<ProductList::iterator, bool> ret =
82  productList_.insert(std::make_pair(BranchKey(productDesc), productDesc));
83  if(!ret.second) {
84  throw Exception(errors::Configuration, "Duplicate Process")
85  << "The process name " << productDesc.processName() << " was previously used on these products.\n"
86  << "Please modify the configuration file to use a distinct process name.\n";
87  }
88  addCalled(productDesc, fromListener);
89  }
tuple ret
prodAgent to be discontinued
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 119 of file ProductRegistry.h.

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

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

Definition at line 189 of file ProductRegistry.cc.

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

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

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

Definition at line 178 of file ProductRegistry.cc.

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

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

Definition at line 122 of file ProductRegistry.cc.

References productList_, and throwIfNotFrozen().

122  {
124  for(ProductList::const_iterator it = productList_.begin(), itEnd = productList_.end();
125  it != itEnd; ++it) {
126  if(it->second.branchType() == brType) {
127  return true;
128  }
129  }
130  return false;
131  }
void throwIfNotFrozen() const
template<typename T >
void edm::ProductRegistry::callForEachBranch ( T const &  iFunc)
inline

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

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

Definition at line 108 of file ProductRegistry.cc.

References assert(), edm::combinable(), relval_2017::k, edm::BranchDescription::produced(), productList_, and throwIfFrozen().

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

108  {
109  assert(!productDesc.produced());
110  throwIfFrozen();
111  BranchKey k = BranchKey(productDesc);
112  ProductList::iterator iter = productList_.find(k);
113  if(iter == productList_.end()) {
114  productList_.insert(std::make_pair(k, productDesc));
115  } else {
116  assert(combinable(iter->second, productDesc));
117  iter->second.merge(productDesc);
118  }
119  }
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 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 259 of file ProductRegistry.cc.

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

Referenced by setFrozen().

259  {
260 
261  std::map<TypeID, TypeID> containedTypeMap;
262  TypeSet missingDicts;
263 
265 
266  for(auto const& product : productList_) {
267  auto const& desc = product.second;
268 
269  if(desc.produced()) {
270  setProductProduced(desc.branchType());
271  }
272 
273  //only do the following if the data is supposed to be available in the event
274  if(desc.present()) {
275  if(!bool(desc.unwrappedType())) {
276  missingDicts.insert(TypeID(desc.unwrappedType().typeInfo()));
277  } else if(!bool(desc.wrappedType())) {
278  missingDicts.insert(TypeID(desc.wrappedType().typeInfo()));
279  } else {
280  TypeID wrappedTypeID(desc.wrappedType().typeInfo());
281  TypeID typeID(desc.unwrappedType().typeInfo());
282  TypeID containedTypeID;
283  auto const& iter = containedTypeMap.find(typeID);
284  if(iter != containedTypeMap.end()) {
285  containedTypeID = iter->second;
286  } else {
287  containedTypeID = productholderindexhelper::getContainedTypeFromWrapper(wrappedTypeID, typeID.className());
288  containedTypeMap.emplace(typeID, containedTypeID);
289  }
291  productLookup(desc.branchType())->insert(typeID,
292  desc.moduleLabel().c_str(),
293  desc.productInstanceName().c_str(),
294  desc.processName().c_str(),
295  containedTypeID);
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  }
void setProductProduced(BranchType branchType)
ProductHolderIndex & nextIndexValue(BranchType branchType)
std::vector< TypeID > & missingDictionariesForUpdate()
TypeID getContainedTypeFromWrapper(TypeID const &wrappedtypeID, std::string const &className)
ProductHolderIndex eventNextIndexValue_
std::shared_ptr< ProductHolderIndexHelper const > productLookup(BranchType branchType) const
unsigned int ProductHolderIndex
ProductHolderIndex const & getNextIndexValue(BranchType branchType) const
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 214 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, and transient_.

Referenced by edm::StreamerInputSource::mergeIntoRegistry(), edm::RootPrimaryFileSequence::nextFile(), and edm::RootPrimaryFileSequence::previousFile().

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

Definition at line 111 of file ProductRegistry.h.

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

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

Definition at line 115 of file ProductRegistry.h.

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

Referenced by initializeLookupTables().

115  {
117  }
std::vector< TypeID > 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
std::shared_ptr< ProductHolderIndexHelper > edm::ProductRegistry::productLookup ( BranchType  branchType)

Definition at line 141 of file ProductRegistry.cc.

References edm::ProductRegistry::Transients::eventProductLookup(), edm::InEvent, edm::InLumi, edm::ProductRegistry::Transients::lumiProductLookup(), edm::ProductRegistry::Transients::runProductLookup(), and transient_.

141  {
144  return transient_.runProductLookup();
145  }
std::shared_ptr< ProductHolderIndexHelper const > runProductLookup() const
std::shared_ptr< ProductHolderIndexHelper const > lumiProductLookup() const
std::shared_ptr< ProductHolderIndexHelper const > eventProductLookup() 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 96 of file ProductRegistry.h.

References productList_.

Referenced by allBranchDescriptions(), and allBranchNames().

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

Definition at line 158 of file ProductRegistry.cc.

References Exception, and frozen().

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

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

Definition at line 166 of file ProductRegistry.cc.

References Exception, and frozen().

Referenced by anyProducts().

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

Definition at line 200 of file ProductRegistry.cc.

References copyProduct().

Referenced by edm::StreamerInputSource::mergeIntoRegistry(), edm::RootEmbeddedFileSequence::RootEmbeddedFileSequence(), edm::RootPrimaryFileSequence::RootPrimaryFileSequence(), and edm::RootSecondaryFileSequence::RootSecondaryFileSequence().

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

Definition at line 207 of file ProductRegistry.cc.

References copyProduct().

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

Member Data Documentation

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