MasterProductRegistry.h
Go to the documentation of this file.
1 #ifndef art_Persistency_Provenance_MasterProductRegistry_h
2 #define art_Persistency_Provenance_MasterProductRegistry_h
3 // vim: set sw=2:
4 
5 //====================================================================
6 // MasterProductRegistry
7 //
8 // Although this is not technically a registry, it is the
9 // representation for ProductMetaData, which is the read-only facade
10 // to the single static instance of this class within art. As such,
11 // this class should be treated as a registry.
12 //
13 // All modifications to the registry happen either at system startup,
14 // or when input files are opened. Once we intend to support
15 // concurrent reading from different input files, it will be necessary
16 // for any registry modifications to happen in a thread-safe manner.
17 //
18 // This class is not altogether necessary--it is meant to facilitate
19 // more efficient lookup of products. Steps should be taken to
20 // determine how this class, and the associated ProductMetaData class,
21 // could be removed in favor of alternative efficiency improvements in
22 // product lookup that do not rely on a registry.
23 // ====================================================================
24 
30 
31 #include <array>
32 #include <functional>
33 #include <iosfwd>
34 #include <limits>
35 #include <memory>
36 #include <string>
37 #include <vector>
38 
39 namespace art {
40 
41  class MasterProductRegistry;
42  using ProductListUpdatedCallback = std::function<void(ProductList const&)>;
43 
44  std::ostream& operator<<(std::ostream& os, MasterProductRegistry const& mpr);
45 }
46 
48 public:
49  explicit MasterProductRegistry() = default;
50 
53 
55 
56  void finalizeForProcessing();
58  void updateFromModule(std::unique_ptr<ProductList>&&);
59  void updateFromInputFile(ProductList const&);
60 
61  auto const&
62  productList() const
63  {
64  return productList_;
65  }
66  auto
67  size() const
68  {
69  return productList_.size();
70  }
71 
72  void print(std::ostream&) const;
73 
74  bool
75  productProduced(BranchType branchType) const
76  {
77  return productProduced_[branchType];
78  }
79 
80 private:
82  void updateProductLists_(ProductList const& pl);
83 
85 
86  // Data members initialized once per process:
88  std::array<bool, NumBranchTypes> productProduced_{
89  {false}}; // filled by aggregation
90  std::vector<ProductListUpdatedCallback> productListUpdatedCallbacks_{};
91 };
92 
93 // Local Variables:
94 // mode: c++
95 // End:
96 #endif /* art_Persistency_Provenance_MasterProductRegistry_h */
std::ostream & operator<<(std::ostream &os, EDAnalyzer::Table< T > const &t)
Definition: EDAnalyzer.h:184
void print(std::ostream &) const
std::map< BranchKey, BranchDescription > ProductList
Definition: ProductList.h:15
void updateFromModule(std::unique_ptr< ProductList > &&)
std::vector< BranchDescription > ProductDescriptions
void registerProductListUpdatedCallback(ProductListUpdatedCallback cb)
std::array< bool, NumBranchTypes > productProduced_
void updateProductLists_(ProductList const &pl)
void updateFromInputFile(ProductList const &)
std::function< void(ProductList const &)> ProductListUpdatedCallback
std::vector< ProductListUpdatedCallback > productListUpdatedCallbacks_
void addProduct_(BranchDescription &&)
bool productProduced(BranchType branchType) const
auto const & productList() const
BranchType
Definition: BranchType.h:18
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
MasterProductRegistry & operator=(MasterProductRegistry const &)=delete
void addProductsFromModule(ProductDescriptions &&)