test
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 
16 
17 #include "boost/array.hpp"
18 #include "boost/shared_ptr.hpp"
19 
20 #include <iosfwd>
21 #include <map>
22 #include <string>
23 #include <vector>
24 
25 namespace edm {
26  class ProductHolderIndexHelper;
27 
29 
30  public:
31  typedef std::map<BranchKey, BranchDescription> ProductList;
32 
34 
35  // A constructor from the persistent data memebers from another product registry.
36  // saves time by not copying the transient components.
37  // The constructed registry will be frozen by default.
38  explicit ProductRegistry(ProductList const& productList, bool toBeFrozen = true);
39 
40  virtual ~ProductRegistry() {}
41 
42  typedef std::map<BranchKey, BranchDescription const> ConstProductList;
43 
44  void addProduct(BranchDescription const& productdesc, bool iFromListener = false);
45 
46  void addLabelAlias(BranchDescription const& productdesc, std::string const& labelAlias, std::string const& instanceAlias);
47 
48  void copyProduct(BranchDescription const& productdesc);
49 
50  void setFrozen(bool initializeLookupInfo = true);
51 
52  std::string merge(ProductRegistry const& other,
53  std::string const& fileName,
55 
56  void updateFromInput(ProductList const& other);
57 
58  void updateFromInput(std::vector<BranchDescription> const& other);
59 
60  ProductList const& productList() const {
61  //throwIfNotFrozen();
62  return productList_;
63  }
64 
66  throwIfFrozen();
67  return productList_;
68  }
69 
70  // Return all the branch names currently known to *this. This
71  // does a return-by-value of the vector so that it may be used in
72  // a colon-initialization list.
73  std::vector<std::string> allBranchNames() const;
74 
75  // Return pointers to (const) BranchDescriptions for all the
76  // BranchDescriptions known to *this. This does a
77  // return-by-value of the vector so that it may be used in a
78  // colon-initialization list.
79  std::vector<BranchDescription const*> allBranchDescriptions() const;
80 
81  //NOTE: this is not const since we only want items that have non-const access to this class to be
82  // able to call this internal iteration
83  template<typename T>
84  void callForEachBranch(T const& iFunc) {
85  //NOTE: If implementation changes from a map, need to check that iterators are still valid
86  // after an insert with the new container, else need to copy the container and iterate over the copy
87  for(ProductRegistry::ProductList::const_iterator itEntry = productList_.begin(),
88  itEntryEnd = productList_.end();
89  itEntry != itEntryEnd; ++itEntry) {
90  iFunc(itEntry->second);
91  }
92  }
93  ProductList::size_type size() const {return productList_.size();}
94 
95  void print(std::ostream& os) const;
96 
97  bool anyProducts(BranchType const brType) const;
98 
100  //throwIfNotFrozen();
102  }
103 
104  boost::shared_ptr<ProductHolderIndexHelper> const& productLookup(BranchType branchType) const;
105 
106  // returns the appropriate ProductHolderIndex else ProductHolderIndexInvalid if no BranchID is available
107  ProductHolderIndex indexFrom(BranchID const& iID) const;
108 
111 
112  std::vector<std::string> const& missingDictionaries() const {
114  }
115 
116  std::vector<std::string>& missingDictionariesForUpdate() {
118  }
119 
121 
123 
124  bool frozen() const {return transient_.frozen_;}
125 
126  struct Transients {
127  Transients();
128  void reset();
129  bool frozen_;
131  // Is at least one (run), (lumi), (event) product produced this process?
132  boost::array<bool, NumBranchTypes> productProduced_;
134 
135  boost::shared_ptr<ProductHolderIndexHelper> eventProductLookup_;
136  boost::shared_ptr<ProductHolderIndexHelper> lumiProductLookup_;
137  boost::shared_ptr<ProductHolderIndexHelper> runProductLookup_;
138 
142 
143  std::map<BranchID, ProductHolderIndex> branchIDToIndex_;
144 
145  std::vector<std::string> missingDictionaries_;
146  };
147 
148  private:
152  }
153 
154  void freezeIt(bool frozen = true) {transient_.frozen_ = frozen;}
155 
157  void initializeLookupTables();
158  virtual void addCalled(BranchDescription const&, bool iFromListener);
159  void throwIfNotFrozen() const;
160  void throwIfFrozen() const;
161 
163 
166  };
167 
168  inline
169  bool
171  return a.productList() == b.productList();
172  }
173 
174  inline
175  bool
177  return !(a == b);
178  }
179 
180  inline
181  std::ostream&
182  operator<<(std::ostream& os, ProductRegistry const& pr) {
183  pr.print(os);
184  return os;
185  }
186 
187 } // edm
188 
189 #endif
std::vector< std::string > missingDictionaries_
void setProductProduced(BranchType branchType)
boost::shared_ptr< ProductHolderIndexHelper > lumiProductLookup_
ProductHolderIndex & nextIndexValue(BranchType branchType)
void throwIfNotFrozen() const
std::vector< std::string > allBranchNames() const
std::map< BranchKey, BranchDescription const > ConstProductList
std::map< BranchKey, BranchDescription > ProductList
ProductHolderIndex indexFrom(BranchID const &iID) const
bool anyProducts(BranchType const brType) const
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
ProductHolderIndex eventNextIndexValue_
unsigned int ProductHolderIndex
ProductList::size_type size() const
ProductHolderIndex const & getNextIndexValue(BranchType branchType) const
void addLabelAlias(BranchDescription const &productdesc, std::string const &labelAlias, std::string const &instanceAlias)
uint16_t size_type
BranchType
Definition: BranchType.h:11
virtual void addCalled(BranchDescription const &, bool iFromListener)
boost::shared_ptr< ProductHolderIndexHelper > const & productLookup(BranchType branchType) const
ProductList const & productList() const
ConstProductList & constProductList()
ProductHolderIndex lumiNextIndexValue_
bool operator==(debugging_allocator< X > const &, debugging_allocator< Y > const &)
std::vector< BranchDescription const * > allBranchDescriptions() const
std::string merge(ProductRegistry const &other, std::string const &fileName, BranchDescription::MatchMode branchesMustMatch=BranchDescription::Permissive)
boost::array< bool, NumBranchTypes > productProduced_
void setFrozen(bool initializeLookupInfo=true)
void freezeIt(bool frozen=true)
void callForEachBranch(T const &iFunc)
void print(std::ostream &os) const
bool productProduced(BranchType branchType) const
ProductHolderIndex runNextIndexValue_
std::vector< std::string > & missingDictionariesForUpdate()
boost::shared_ptr< ProductHolderIndexHelper > runProductLookup_
double b
Definition: hdecay.h:120
ProductList & productListUpdator()
bool anyProductProduced() const
double a
Definition: hdecay.h:121
void throwIfFrozen() const
void updateFromInput(ProductList const &other)
boost::shared_ptr< ProductHolderIndexHelper > eventProductLookup_
std::map< BranchID, ProductHolderIndex > branchIDToIndex_
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)
void copyProduct(BranchDescription const &productdesc)
std::vector< std::string > const & missingDictionaries() const