CMS 3D CMS Logo

ProductResolverBase.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_ProductResolverBase_h
2 #define FWCore_Framework_ProductResolverBase_h
3 
4 /*----------------------------------------------------------------------
5 
6 ProductResolver: Class to handle access to a WrapperBase and its related information.
7 
8  [The class was formerly called Group and later ProductHolder]
9 ----------------------------------------------------------------------*/
10 
18 
19 #include <memory>
20 
21 #include <string>
22 
23 namespace edm {
24  class MergeableRunProductMetadata;
25  class ProductProvenanceRetriever;
26  class DelayedReader;
27  class ModuleCallingContext;
29  class Principal;
31  class WaitingTask;
32  class ServiceToken;
33 
35  public:
36  class Resolution {
37  public:
38  static std::uintptr_t constexpr kAmbiguityValue = 0x1;
40  explicit Resolution(ProductData const* iData) : m_data(iData) {}
41 
42  bool isAmbiguous() const { return reinterpret_cast<std::uintptr_t>(m_data) == kAmbiguityValue; }
43 
44  ProductData const* data() const {
45  return reinterpret_cast<ProductData const*>(kAmbiguityMask & reinterpret_cast<std::uintptr_t>(m_data));
46  }
47 
48  static Resolution makeAmbiguous() { return Resolution(reinterpret_cast<ProductData const*>(kAmbiguityValue)); }
49 
50  private:
52  };
53 
55  virtual ~ProductResolverBase();
56 
57  ProductResolverBase(ProductResolverBase const&) = delete; // Disallow copying and moving
58  ProductResolverBase& operator=(ProductResolverBase const&) = delete; // Disallow copying and moving
59 
61  bool skipCurrentProcess,
63  ModuleCallingContext const* mcc) const {
64  return resolveProduct_(principal, skipCurrentProcess, sra, mcc);
65  }
66 
69  void prefetchAsync(WaitingTask* waitTask,
70  Principal const& principal,
71  bool skipCurrentProcess,
72  ServiceToken const& token,
74  ModuleCallingContext const* mcc) const {
75  return prefetchAsync_(waitTask, principal, skipCurrentProcess, token, sra, mcc);
76  }
77 
79  MergeableRunProductMetadata const* mergeableRunProductMetadata) const {
80  retrieveAndMerge_(principal, mergeableRunProductMetadata);
81  }
83 
84  void unsafe_deleteProduct() const { const_cast<ProductResolverBase*>(this)->resetProductData_(true); }
85 
86  // product is not available (dropped or never created)
87  bool productUnavailable() const { return productUnavailable_(); }
88 
89  // returns true if resolveProduct was already called for this product
90  bool productResolved() const { return productResolved_(); }
91 
92  // provenance is currently available
93  bool provenanceAvailable() const;
94 
95  // Only returns true if the module is unscheduled and was not run
96  // all other cases return false
97  bool unscheduledWasNotRun() const { return unscheduledWasNotRun_(); }
98 
99  // Product was deleted early in order to save memory
100  bool productWasDeleted() const { return productWasDeleted_(); }
101 
102  bool productWasFetchedAndIsValid(bool iSkipCurrentProcess) const {
103  return productWasFetchedAndIsValid_(iSkipCurrentProcess);
104  }
105 
106  // Retrieves pointer to the per event(lumi)(run) provenance.
108 
109  // Retrieves a reference to the event independent provenance.
111 
112  // Retrieves a reference to the event independent provenance.
113  bool singleProduct() const { return singleProduct_(); }
114 
115  // Sets the pointer to the event independent provenance.
116  void resetBranchDescription(std::shared_ptr<BranchDescription const> bd) { resetBranchDescription_(bd); }
117 
118  // Retrieves a reference to the module label.
119  std::string const& moduleLabel() const { return branchDescription().moduleLabel(); }
120 
121  // Same as moduleLabel except in the case of an AliasProductResolver, in which
122  // case it resolves the module which actually produces the product and returns
123  // its module label
125 
126  // Retrieves a reference to the product instance name
128 
129  // Retrieves a reference to the process name
130  std::string const& processName() const { return branchDescription().processName(); }
131 
132  // Retrieves pointer to a class containing both the event independent and the per even provenance.
133  Provenance const* provenance() const;
134 
135  // Retrieves pointer to a class containing the event independent provenance.
136  StableProvenance const* stableProvenance() const { return &provenance()->stable(); }
137 
138  // Initializes the event independent portion of the provenance, plus the process history ID, the product ID, and the provRetriever.
139  void setProvenance(ProductProvenanceRetriever const* provRetriever,
140  ProcessHistory const& ph,
141  ProductID const& pid) {
142  setProvenance_(provRetriever, ph, pid);
143  }
144 
145  // Initializes the portion of the provenance related to mergeable run products.
148  }
149 
150  // Initializes the process history.
152 
153  // Write the product to the stream.
154  void write(std::ostream& os) const;
155 
156  // Return the type of the product stored in this ProductResolver.
157  // We are relying on the fact that Type instances are small, and
158  // so we are free to copy them at will.
159  TypeID productType() const;
160 
161  // Retrieves the product ID of the product.
162  ProductID const& productID() const { return provenance()->productID(); }
163 
164  // Puts the product into the ProductResolver.
165  void putProduct(std::unique_ptr<WrapperBase> edp) const { putProduct_(std::move(edp)); }
166 
167  // If the product already exists we merge, else will put
168  void putOrMergeProduct(std::unique_ptr<WrapperBase> edp,
169  MergeableRunProductMetadata const* mergeableRunProductMetadata = nullptr) const {
170  putOrMergeProduct_(std::move(edp), mergeableRunProductMetadata);
171  }
172 
173  virtual void connectTo(ProductResolverBase const&, Principal const*) = 0;
174  virtual void setupUnscheduled(UnscheduledConfigurator const&);
175 
176  private:
178  bool skipCurrentProcess,
180  ModuleCallingContext const* mcc) const = 0;
181  virtual void prefetchAsync_(WaitingTask* waitTask,
182  Principal const& principal,
183  bool skipCurrentProcess,
184  ServiceToken const& token,
186  ModuleCallingContext const* mcc) const = 0;
187 
188  virtual void retrieveAndMerge_(Principal const& principal,
189  MergeableRunProductMetadata const* mergeableRunProductMetadata) const;
190 
191  virtual bool unscheduledWasNotRun_() const = 0;
192  virtual bool productUnavailable_() const = 0;
193  virtual bool productResolved_() const = 0;
194  virtual bool productWasDeleted_() const = 0;
195  virtual bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const = 0;
196 
197  virtual void putProduct_(std::unique_ptr<WrapperBase> edp) const = 0;
198  virtual void putOrMergeProduct_(std::unique_ptr<WrapperBase> edp,
199  MergeableRunProductMetadata const* mergeableRunProductMetadata) const = 0;
200  virtual BranchDescription const& branchDescription_() const = 0;
201  virtual void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) = 0;
202  virtual Provenance const* provenance_() const = 0;
203  virtual std::string const& resolvedModuleLabel_() const = 0;
204  virtual void setProvenance_(ProductProvenanceRetriever const* provRetriever,
205  ProcessHistory const& ph,
206  ProductID const& pid) = 0;
208  virtual void setProcessHistory_(ProcessHistory const& ph) = 0;
209  virtual ProductProvenance const* productProvenancePtr_() const = 0;
210  virtual void resetProductData_(bool deleteEarly) = 0;
211  virtual bool singleProduct_() const = 0;
212  };
213 
214  inline std::ostream& operator<<(std::ostream& os, ProductResolverBase const& phb) {
215  phb.write(os);
216  return os;
217  }
218 } // namespace edm
219 
220 #endif
std::string const & productInstanceName() const
Provenance const * provenance() const
virtual bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const =0
virtual std::string const & resolvedModuleLabel_() const =0
void setMergeableRunProductMetadata(MergeableRunProductMetadata const *mrpm)
void prefetchAsync(WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
ProductResolverBase & operator=(ProductResolverBase const &)=delete
virtual void resetBranchDescription_(std::shared_ptr< BranchDescription const > bd)=0
StableProvenance const & stable() const
Definition: Provenance.h:42
virtual void setupUnscheduled(UnscheduledConfigurator const &)
virtual ProductProvenance const * productProvenancePtr_() const =0
virtual void putProduct_(std::unique_ptr< WrapperBase > edp) const =0
virtual void prefetchAsync_(WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
virtual void resetProductData_(bool deleteEarly)=0
std::string const & processName() const
Resolution resolveProduct(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
std::string const & processName() const
virtual void setProvenance_(ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)=0
void putOrMergeProduct(std::unique_ptr< WrapperBase > edp, MergeableRunProductMetadata const *mergeableRunProductMetadata=nullptr) const
StableProvenance const * stableProvenance() const
ProductID const & productID() const
void putProduct(std::unique_ptr< WrapperBase > edp) const
virtual void connectTo(ProductResolverBase const &, Principal const *)=0
def principal(options)
static std::uintptr_t constexpr kAmbiguityValue
virtual BranchDescription const & branchDescription_() const =0
Resolution(ProductData const *iData)
std::string const & moduleLabel() const
std::string const & productInstanceName() const
void retrieveAndMerge(Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
virtual void putOrMergeProduct_(std::unique_ptr< WrapperBase > edp, MergeableRunProductMetadata const *mergeableRunProductMetadata) const =0
virtual bool productResolved_() const =0
void setProcessHistory(ProcessHistory const &ph)
ProductProvenance const * productProvenancePtr() const
virtual void setMergeableRunProductMetadata_(MergeableRunProductMetadata const *)
virtual void retrieveAndMerge_(Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
virtual bool unscheduledWasNotRun_() const =0
ProductData const * data() const
bool productWasFetchedAndIsValid(bool iSkipCurrentProcess) const
static std::uintptr_t constexpr kAmbiguityMask
HLT enums.
std::string const & resolvedModuleLabel() const
BranchDescription const & branchDescription() const
void setProvenance(ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
virtual Provenance const * provenance_() const =0
ProductID const & productID() const
Definition: Provenance.h:83
virtual bool productUnavailable_() const =0
virtual bool singleProduct_() const =0
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
virtual Resolution resolveProduct_(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
def move(src, dest)
Definition: eostools.py:511
#define constexpr
std::string const & moduleLabel() const
virtual void setProcessHistory_(ProcessHistory const &ph)=0
virtual bool productWasDeleted_() const =0
void write(std::ostream &os) const