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 | Static Public Attributes | Private Member Functions | Private Attributes
edm::ProductRegistry Class Reference

author Stefano ARGIRO author Bill Tanenbaum More...

#include "edm/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 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)
 
TransientProductLookupMapelementLookup () const
 
ProductTransientIndex indexFrom (BranchID const &iID) const
 
std::string merge (ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode parametersMustMatch=BranchDescription::Permissive, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
 
void print (std::ostream &os) const
 
BranchListIndex producedBranchListIndex () const
 
ProductList const & productList () const
 
ProductListproductListUpdator ()
 
TransientProductLookupMapproductLookup () 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 ()
 

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_
 
Transient< Transientstransients_
 

Detailed Description

author Stefano ARGIRO author Bill Tanenbaum

Date
19 Jul 2005

Definition at line 41 of file ProductRegistry.h.

Member Typedef Documentation

Definition at line 55 of file ProductRegistry.h.

Definition at line 44 of file ProductRegistry.h.

Constructor & Destructor Documentation

edm::ProductRegistry::ProductRegistry ( )

Definition at line 33 of file ProductRegistry.cc.

33  :
34  productList_(),
35  transients_() {
36  }
Transient< Transients > transients_
edm::ProductRegistry::ProductRegistry ( ProductList const &  productList,
bool  toBeFrozen = true 
)
explicit

Definition at line 50 of file ProductRegistry.cc.

References frozen().

50  :
52  transients_() {
53  frozen() = toBeFrozen;
54  }
Transient< Transients > transients_
ProductList const & productList() const
bool & frozen() const
virtual edm::ProductRegistry::~ProductRegistry ( )
inlinevirtual

Definition at line 53 of file ProductRegistry.h.

53 {}

Member Function Documentation

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

Reimplemented in edm::SignallingProductRegistry.

Definition at line 125 of file ProductRegistry.cc.

Referenced by addProduct().

125  {
126  }
void edm::ProductRegistry::addProduct ( BranchDescription const &  productdesc,
bool  iFromListener = false 
)

Definition at line 57 of file ProductRegistry.cc.

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

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

58  {
59  assert(productDesc.produced());
60  throwIfFrozen();
61  checkDicts(productDesc);
62  std::pair<ProductList::iterator, bool> ret =
63  productList_.insert(std::make_pair(BranchKey(productDesc), productDesc));
64  if(!ret.second) {
65  throw Exception(errors::Configuration, "Duplicate Process")
66  << "The process name " << productDesc.processName() << " was previously used on these products.\n"
67  << "Please modify the configuration file to use a distinct process name.\n";
68  }
69  addCalled(productDesc, fromListener);
70  }
virtual void addCalled(BranchDescription const &, bool iFromListener)
void throwIfFrozen() const
std::vector< BranchDescription const * > edm::ProductRegistry::allBranchDescriptions ( ) const

Definition at line 142 of file ProductRegistry.cc.

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

Referenced by edm::ConstProductRegistry::allBranchDescriptions(), and edm::RootFile::dropOnInput().

142  {
143  std::vector<BranchDescription const*> result;
144  result.reserve(productList().size());
145 
146  ProductList::const_iterator it = productList().begin();
147  ProductList::const_iterator end = productList().end();
148 
149  for(; it != end; ++it) result.push_back(&(it->second));
150  return result;
151  }
ProductList::size_type size() const
ProductList const & productList() const
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:38
std::vector< std::string > edm::ProductRegistry::allBranchNames ( ) const

Definition at line 129 of file ProductRegistry.cc.

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

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

129  {
130  std::vector<std::string> result;
131  result.reserve(productList().size());
132 
133  ProductList::const_iterator it = productList().begin();
134  ProductList::const_iterator end = productList().end();
135 
136  for(; it != end; ++it) result.push_back(it->second.branchName());
137 
138  return result;
139  }
ProductList::size_type size() const
ProductList const & productList() const
tuple result
Definition: query.py:137
#define end
Definition: vmac.h:38
bool edm::ProductRegistry::anyProductProduced ( ) const
inline

Definition at line 144 of file ProductRegistry.h.

References transients_.

Referenced by edm::ConstProductRegistry::anyProductProduced(), and edm::RunPrincipal::fillRunPrincipal().

144 {return transients_.get().anyProductProduced_;}
Transient< Transients > transients_
bool edm::ProductRegistry::anyProducts ( BranchType const  brType) const

Definition at line 88 of file ProductRegistry.cc.

References productList_, and throwIfNotFrozen().

88  {
90  for(ProductList::const_iterator it = productList_.begin(), itEnd = productList_.end();
91  it != itEnd; ++it) {
92  if(it->second.branchType() == brType) {
93  return true;
94  }
95  }
96  return false;
97  }
void throwIfNotFrozen() const
template<typename T >
void edm::ProductRegistry::callForEachBranch ( T const &  iFunc)
inline

Definition at line 96 of file ProductRegistry.h.

References productList_.

Referenced by edm::ProducerBase::registerProducts().

96  {
97  //NOTE: If implementation changes from a map, need to check that iterators are still valid
98  // after an insert with the new container, else need to copy the container and iterate over the copy
99  for(ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(),
100  itEntryEnd = productList_.end();
101  itEntry != itEntryEnd; ++itEntry) {
102  iFunc(itEntry->second);
103  }
104  }
ConstProductList& edm::ProductRegistry::constProductList ( ) const
inline

Definition at line 111 of file ProductRegistry.h.

References transients_.

Referenced by edm::Principal::adjustToNewProductRegistry(), and initializeLookupTables().

111  {
112  //throwIfNotFrozen();
113  return transients_.get().constProductList_;
114  }
Transient< Transients > transients_
void edm::ProductRegistry::copyProduct ( BranchDescription const &  productdesc)

Definition at line 73 of file ProductRegistry.cc.

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

Referenced by stor::HLTInfo::mergeRegistry(), and updateFromInput().

73  {
74  assert(!productDesc.produced());
75  throwIfFrozen();
76  productDesc.init();
77  BranchKey k = BranchKey(productDesc);
78  ProductList::iterator iter = productList_.find(k);
79  if(iter == productList_.end()) {
80  productList_.insert(std::make_pair(k, productDesc));
81  } else {
82  assert(combinable(iter->second, productDesc));
83  iter->second.merge(productDesc);
84  }
85  }
bool combinable(BranchDescription const &a, BranchDescription const &b)
int k[5][pyjets_maxn]
void throwIfFrozen() const
TransientProductLookupMap& edm::ProductRegistry::elementLookup ( ) const
inline

Definition at line 118 of file ProductRegistry.h.

References transients_.

Referenced by initializeLookupTables().

118 {return transients_.get().elementLookup_;}
Transient< Transients > transients_
bool& edm::ProductRegistry::frozen ( ) const
inlineprivate

Definition at line 157 of file ProductRegistry.h.

References transients_.

Referenced by ProductRegistry(), setFrozen(), throwIfFrozen(), and throwIfNotFrozen().

157 {return transients_.get().frozen_;}
Transient< Transients > transients_
ProductTransientIndex edm::ProductRegistry::indexFrom ( BranchID const &  iID) const

Definition at line 301 of file ProductRegistry.cc.

References kInvalidIndex, and transients_.

301  {
302  std::map<BranchID, ProductTransientIndex>::iterator itFind = transients_.get().branchIDToIndex_.find(iID);
303  if(itFind == transients_.get().branchIDToIndex_.end()) {
304  return kInvalidIndex;
305  }
306  return itFind->second;
307  }
static ProductTransientIndex const kInvalidIndex
Transient< Transients > transients_
void edm::ProductRegistry::initializeLookupTables ( ) const
private

Definition at line 225 of file ProductRegistry.cc.

References constProductList(), ExpressReco_HICollisions_FallBack::e, elementLookup(), edm::TransientProductLookupMap::fillFrom(), edm::fillLookup(), i, getHLTprescales::index, edm::is_PtrVector(), edm::is_RefToBaseVector(), edm::is_RefVector(), edm::ConstBranchDescription::processName(), productList_, productLookup(), edm::public_base_classes(), setProductProduced(), transients_, and edm::value_type_of().

Referenced by merge(), and setFrozen().

225  {
226  constProductList().clear();
227  transients_.get().branchIDToIndex_.clear();
229 
230  //NOTE it might be possible to remove the need for this temporary map because the productList is ordered by the
231  // BranchKey and for the same C++ class type the BranchKey will sort just like CompareTypeInBranchTypeConstBranchDescription
232  typedef TransientProductLookupMap::FillFromMap TempLookupMap;
233  TempLookupMap tempProductLookupMap;
234  TempLookupMap tempElementLookupMap;
235 
236  typedef std::set<std::string> UsedProcessNames;
237  UsedProcessNames usedProcessNames;
238  for(ProductList::const_iterator i = productList_.begin(), e = productList_.end(); i != e; ++i, ++index) {
239  if(i->second.produced()) {
240  setProductProduced(i->second.branchType());
241  }
242 
243  //insert returns a pair<iterator, bool> and we want the address of the ConstBranchDescription that was created in the map
244  // this is safe since items in a map always retain their memory address
245  ConstBranchDescription const* pBD = &(constProductList().insert(std::make_pair(i->first, ConstBranchDescription(i->second))).first->second);
246 
247  transients_.get().branchIDToIndex_[i->second.branchID()] = index;
248 
249  usedProcessNames.insert(pBD->processName());
250 
251  Reflex::Type type(Reflex::Type::ByName(i->second.className()));
252  //only do the following if the data is supposed to be available in the event
253  if(i->second.present()) {
254  if(not bool(type)) {
255 
256  LogWarning("Missing Dictionary") << "Could not find a Reflex dictionary for class '" << i->second.className()
257  << "'. This class was registered as one which is supposed to be held by an Event, LuminosityBlock, or Run but will not be available. "
258  "Please check\n"
259  " 1) was a Reflex dictionary created for the class,\n"
260  " 2) if so was the package with the dictionary linked with all plugins that use that class,\n"
261  " 3) the file is from an old release and this data type has been removed from the present release.";
262  continue;
263  }
264  fillLookup(type, index, pBD, tempProductLookupMap);
265 
266  if(bool(type)) {
267  // Here we look in the object named "type" for a typedef
268  // named "value_type" and get the Reflex::Type for it.
269  // Then check to ensure the Reflex dictionary is defined
270  // for this value_type.
271  // I do not throw an exception here if the check fails
272  // because there are known cases where the dictionary does
273  // not exist and we do not need to support those cases.
274  Reflex::Type valueType;
275  if((is_RefVector(type, valueType) ||
276  is_PtrVector(type, valueType) ||
277  is_RefToBaseVector(type, valueType) ||
278  value_type_of(type, valueType))
279  && bool(valueType)) {
280 
281  fillLookup(valueType, index, pBD, tempElementLookupMap);
282 
283  // Repeat this for all public base classes of the value_type
284  std::vector<Reflex::Type> baseTypes;
285  public_base_classes(valueType, baseTypes);
286 
287  for(std::vector<Reflex::Type>::iterator iter = baseTypes.begin(),
288  iend = baseTypes.end();
289  iter != iend;
290  ++iter) {
291  fillLookup(*iter, index, pBD, tempElementLookupMap);
292  }
293  }
294  }
295  }
296  }
297  productLookup().fillFrom(tempProductLookupMap);
298  elementLookup().fillFrom(tempElementLookupMap);
299  }
type
Definition: HCALResponse.h:22
int i
Definition: DBlmapReader.cc:9
void public_base_classes(const Reflex::Type &type, std::vector< Reflex::Type > &baseTypes)
bool is_RefToBaseVector(Reflex::Type const &possible_ref_vector, Reflex::Type &value_type)
Definition: ReflexTools.cc:145
void setProductProduced(BranchType branchType) const
ConstProductList & constProductList() const
bool is_PtrVector(Reflex::Type const &possible_ref_vector, Reflex::Type &value_type)
Definition: ReflexTools.cc:128
bool value_type_of(Reflex::Type const &t, Reflex::Type &found_type)
Definition: ReflexTools.h:31
Transient< Transients > transients_
TransientProductLookupMap & elementLookup() const
static void fillLookup(Reflex::Type const &type, ProductTransientIndex const &index, ConstBranchDescription const *branchDesc, TransientProductLookupMap::FillFromMap &oMap)
TransientProductLookupMap & productLookup() const
bool is_RefVector(Reflex::Type const &possible_ref_vector, Reflex::Type &value_type)
Definition: ReflexTools.cc:115
std::map< std::pair< TypeInBranchType, ConstBranchDescription const * >, ProductTransientIndex, CompareTypeInBranchTypeConstBranchDescription > FillFromMap
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 170 of file ProductRegistry.cc.

References ExpressReco_HICollisions_FallBack::e, i, initializeLookupTables(), j, edm::match(), edm::BranchDescription::Permissive, productList(), productList_, asciidump::s, and edm::BranchDescription::Strict.

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

173  {
174  std::ostringstream differences;
175 
176  ProductRegistry::ProductList::iterator j = productList_.begin();
177  ProductRegistry::ProductList::iterator s = productList_.end();
178  ProductRegistry::ProductList::const_iterator i = other.productList().begin();
179  ProductRegistry::ProductList::const_iterator e = other.productList().end();
180 
181  // Loop over entries in the main product registry.
182  while(j != s || i != e) {
183  if(j != s && j->second.produced()) {
184  // Ignore branches just produced (i.e. not in input file).
185  ++j;
186  } else if(j == s || (i != e && i->first < j->first)) {
187  if(i->second.present()) {
188  differences << "Branch '" << i->second.branchName() << "' is in file '" << fileName << "'\n";
189  differences << " but not in previous files.\n";
190  } else {
191  productList_.insert(*i);
192  }
193  ++i;
194  } else if(i == e || (j != s && j->first < i->first)) {
195  if(j->second.present() && branchesMustMatch == BranchDescription::Strict) {
196  differences << "Branch '" << j->second.branchName() << "' is in previous files\n";
197  differences << " but not in file '" << fileName << "'.\n";
198  }
199  ++j;
200  } else {
201  std::string difs = match(j->second, i->second, fileName, parametersMustMatch);
202  if(difs.empty()) {
203  if(parametersMustMatch == BranchDescription::Permissive) j->second.merge(i->second);
204  } else {
205  differences << difs;
206  }
207  ++i;
208  ++j;
209  }
210  }
212  return differences.str();
213  }
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
void initializeLookupTables() const
string s
Definition: asciidump.py:422
void edm::ProductRegistry::print ( std::ostream &  os) const

Definition at line 309 of file ProductRegistry.cc.

References ExpressReco_HICollisions_FallBack::e, i, and productList_.

Referenced by edm::operator<<().

309  {
310  for(ProductList::const_iterator i = productList_.begin(), e = productList_.end(); i != e; ++i) {
311  os << i->second << "\n-----\n";
312  }
313  }
int i
Definition: DBlmapReader.cc:9
BranchListIndex edm::ProductRegistry::producedBranchListIndex ( ) const
inline

Definition at line 145 of file ProductRegistry.h.

References transients_.

145 {return transients_.get().producedBranchListIndex_;}
Transient< Transients > transients_
ProductList const& edm::ProductRegistry::productList ( ) const
inline
ProductList& edm::ProductRegistry::productListUpdator ( )
inline

Definition at line 77 of file ProductRegistry.h.

References productList_, and throwIfFrozen().

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

77  {
78  throwIfFrozen();
79  return productList_;
80  }
void throwIfFrozen() const
TransientProductLookupMap& edm::ProductRegistry::productLookup ( ) const
inline

Definition at line 116 of file ProductRegistry.h.

References transients_.

Referenced by initializeLookupTables().

116 {return transients_.get().productLookup_;}
Transient< Transients > transients_
bool edm::ProductRegistry::productProduced ( BranchType  branchType) const
inline

Definition at line 143 of file ProductRegistry.h.

References revisionDML::branchType(), and transients_.

143 {return transients_.get().productProduced_[branchType];}
Transient< Transients > transients_
void edm::ProductRegistry::setFrozen ( bool  initializeLookupInfo = true) const

Definition at line 100 of file ProductRegistry.cc.

References frozen(), and initializeLookupTables().

Referenced by stor::HLTInfo::HLTInfo(), and edm::Schedule::Schedule().

100  {
101  if(frozen()) return;
102  frozen() = true;
103  if(initializeLookupInfo) {
105  }
106  }
void initializeLookupTables() const
bool & frozen() const
void edm::ProductRegistry::setProducedBranchListIndex ( BranchListIndex  blix) const
inline

Definition at line 147 of file ProductRegistry.h.

References transients_.

Referenced by edm::BranchIDListHelper::updateRegistries().

147  {
148  transients_.get().producedBranchListIndex_ = blix;
149  }
Transient< Transients > transients_
void edm::ProductRegistry::setProductProduced ( BranchType  branchType) const
inlineprivate

Definition at line 152 of file ProductRegistry.h.

References revisionDML::branchType(), and transients_.

Referenced by initializeLookupTables().

152  {
153  transients_.get().productProduced_[branchType] = true;
154  transients_.get().anyProductProduced_ = true;
155  }
Transient< Transients > transients_
ProductList::size_type edm::ProductRegistry::size ( void  ) const
inline

Definition at line 105 of file ProductRegistry.h.

References productList_.

Referenced by allBranchDescriptions(), and allBranchNames().

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

Definition at line 109 of file ProductRegistry.cc.

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

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

109  {
110  if(frozen()) {
111  throw cms::Exception("ProductRegistry", "throwIfFrozen")
112  << "cannot modify the ProductRegistry because it is frozen\n";
113  }
114  }
bool & frozen() const
void edm::ProductRegistry::throwIfNotFrozen ( ) const
private

Definition at line 117 of file ProductRegistry.cc.

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

Referenced by anyProducts().

117  {
118  if(!frozen()) {
119  throw cms::Exception("ProductRegistry", "throwIfNotFrozen")
120  << "cannot read the ProductRegistry because it is not yet frozen\n";
121  }
122  }
bool & frozen() const
void edm::ProductRegistry::updateFromInput ( ProductList const &  other)

Definition at line 154 of file ProductRegistry.cc.

References copyProduct().

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

154  {
155  for(ProductList::const_iterator it = other.begin(), itEnd = other.end();
156  it != itEnd; ++it) {
157  copyProduct(it->second);
158  }
159  }
void copyProduct(BranchDescription const &productdesc)
void edm::ProductRegistry::updateFromInput ( std::vector< BranchDescription > const &  other)

Definition at line 162 of file ProductRegistry.cc.

References copyProduct().

162  {
163  for(std::vector<BranchDescription>::const_iterator it = other.begin(), itEnd = other.end();
164  it != itEnd; ++it) {
165  copyProduct(*it);
166  }
167  }
void copyProduct(BranchDescription const &productdesc)

Member Data Documentation

ProductTransientIndex const edm::ProductRegistry::kInvalidIndex = 0xFFFFFFFF
static
ProductList edm::ProductRegistry::productList_
private
Transient<Transients> edm::ProductRegistry::transients_
mutableprivate