CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProductRegistry.h
Go to the documentation of this file.
1 #ifndef DataFormats_Provenance_ProductRegistry_h
2 #define DataFormats_Provenance_ProductRegistry_h
3 
20 
21 #include "boost/array.hpp"
22 
23 #include <iosfwd>
24 #include <map>
25 #include <set>
26 #include <string>
27 #include <vector>
28 
29 namespace edm {
30 
41 
42  public:
43  typedef std::map<BranchKey, BranchDescription> ProductList;
44 
46 
47  // A constructor from the persistent data memebers from another product registry.
48  // saves time by not copying the transient components.
49  // The constructed registry will be frozen by default.
50  explicit ProductRegistry(ProductList const& productList, bool toBeFrozen = true);
51 
52  virtual ~ProductRegistry() {}
53 
54  typedef std::map<BranchKey, ConstBranchDescription> ConstProductList;
55 
56  void addProduct(BranchDescription const& productdesc, bool iFromListener = false);
57 
58  void copyProduct(BranchDescription const& productdesc);
59 
60  void setFrozen(bool initializeLookupInfo = true) const;
61 
62  std::string merge(ProductRegistry const& other,
63  std::string const& fileName,
66 
67  void updateFromInput(ProductList const& other);
68 
69  void updateFromInput(std::vector<BranchDescription> const& other);
70 
71  ProductList const& productList() const {
72  //throwIfNotFrozen();
73  return productList_;
74  }
75 
77  throwIfFrozen();
78  return productList_;
79  }
80 
81  // Return all the branch names currently known to *this. This
82  // does a return-by-value of the vector so that it may be used in
83  // a colon-initialization list.
84  std::vector<std::string> allBranchNames() const;
85 
86  // Return pointers to (const) BranchDescriptions for all the
87  // BranchDescriptions known to *this. This does a
88  // return-by-value of the vector so that it may be used in a
89  // colon-initialization list.
90  std::vector<BranchDescription const*> allBranchDescriptions() const;
91 
92  //NOTE: this is not const since we only want items that have non-const access to this class to be
93  // able to call this internal iteration
94  template<typename T>
95  void callForEachBranch(T const& iFunc) {
96  //NOTE: If implementation changes from a map, need to check that iterators are still valid
97  // after an insert with the new container, else need to copy the container and iterate over the copy
98  for(ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(),
99  itEntryEnd = productList_.end();
100  itEntry != itEntryEnd; ++itEntry) {
101  iFunc(itEntry->second);
102  }
103  }
104  ProductList::size_type size() const {return productList_.size();}
105 
106  void print(std::ostream& os) const;
107 
108  bool anyProducts(BranchType const brType) const;
109 
111  //throwIfNotFrozen();
113  }
114 
116 
118 
119  //returns the appropriate ProductTransientIndex else 0xFFFFFFFF if no BranchID is available
120  static ProductTransientIndex const kInvalidIndex = 0xFFFFFFFF;
121  ProductTransientIndex indexFrom(BranchID const& iID) const;
122 
126 
129  }
130 
131  std::vector<std::string>& missingDictionaries() const {
133  }
134 
136 
137  struct Transients {
138  Transients();
139  void reset();
140  bool frozen_;
142  // Is at least one (run), (lumi), (event) product produced this process?
143  boost::array<bool, NumBranchTypes> productProduced_;
145 
146  // indices used to quickly find a group in the vector groups_
147  // by type, first one by the type of the EDProduct and the
148  // second by the type of object contained in a sequence in
149  // an EDProduct
152 
153  std::map<BranchID, ProductTransientIndex> branchIDToIndex_;
154 
156 
157  std::vector<std::string> missingDictionaries_;
158  };
159 
160  private:
164  }
165 
166  bool& frozen() const {return transient_.frozen_;}
167 
168  void initializeLookupTables() const;
169  virtual void addCalled(BranchDescription const&, bool iFromListener);
170  void throwIfNotFrozen() const;
171  void throwIfFrozen() const;
172 
175  };
176 
177  inline
178  bool
180  return a.productList() == b.productList();
181  }
182 
183  inline
184  bool
186  return !(a == b);
187  }
188 
189  inline
190  std::ostream&
191  operator<<(std::ostream& os, ProductRegistry const& pr) {
192  pr.print(os);
193  return os;
194  }
195 
196 } // edm
197 
198 #endif
unsigned short BranchListIndex
std::vector< std::string > missingDictionaries_
void setProductProduced(BranchType branchType) const
ConstProductList & constProductList() const
void throwIfNotFrozen() const
std::vector< std::string > allBranchNames() const
std::map< BranchKey, BranchDescription > ProductList
BranchListIndex producedBranchListIndex() const
static ProductTransientIndex const kInvalidIndex
bool anyProducts(BranchType const brType) const
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode parametersMustMatch=BranchDescription::Permissive, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
TransientProductLookupMap productLookup_
ProductList::size_type size() const
uint16_t size_type
BranchType
Definition: BranchType.h:11
virtual void addCalled(BranchDescription const &, bool iFromListener)
ProductList const & productList() const
void setProducedBranchListIndex(BranchListIndex blix) const
TransientProductLookupMap & elementLookup() const
std::vector< std::string > & missingDictionaries() const
void initializeTransients() const
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &)
std::vector< BranchDescription const * > allBranchDescriptions() const
boost::array< bool, NumBranchTypes > productProduced_
void callForEachBranch(T const &iFunc)
void print(std::ostream &os) const
bool productProduced(BranchType branchType) const
void setFrozen(bool initializeLookupInfo=true) const
TransientProductLookupMap elementLookup_
void initializeLookupTables() const
TransientProductLookupMap & productLookup() const
double b
Definition: hdecay.h:120
ProductList & productListUpdator()
bool anyProductProduced() const
author Stefano ARGIRO author Bill Tanenbaum
double a
Definition: hdecay.h:121
void throwIfFrozen() const
void updateFromInput(ProductList const &other)
bool & frozen() const
ProductTransientIndex indexFrom(BranchID const &iID) const
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
long double T
void addProduct(BranchDescription const &productdesc, bool iFromListener=false)
std::map< BranchID, ProductTransientIndex > branchIDToIndex_
void copyProduct(BranchDescription const &productdesc)
std::map< BranchKey, ConstBranchDescription > ConstProductList