CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
19 
20 #include <memory>
21 
22 #include <string>
23 
24 namespace edm {
25  class MergeableRunProductMetadata;
26  class ProductProvenanceRetriever;
27  class DelayedReader;
28  class ModuleCallingContext;
30  class Principal;
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 
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 
78  void retrieveAndMerge(Principal const& principal,
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  // Initialize the mechanism to retrieve per event provenance
140  setProductProvenanceRetriever_(provRetriever);
141  }
142 
143  // Initializes the ProductID
144  void setProductID(ProductID const& pid) { setProductID_(pid); }
145 
146  // Initializes the portion of the provenance related to mergeable run products.
149  }
150 
151  // Write the product to the stream.
152  void write(std::ostream& os) const;
153 
154  // Return the type of the product stored in this ProductResolver.
155  // We are relying on the fact that Type instances are small, and
156  // so we are free to copy them at will.
157  TypeID productType() const;
158 
159  // Retrieves the product ID of the product.
160  ProductID const& productID() const { return provenance()->productID(); }
161 
162  virtual void connectTo(ProductResolverBase const&, Principal const*) = 0;
163  virtual void setupUnscheduled(UnscheduledConfigurator const&);
164 
165  private:
166  virtual Resolution resolveProduct_(Principal const& principal,
167  bool skipCurrentProcess,
169  ModuleCallingContext const* mcc) const = 0;
170  virtual void prefetchAsync_(WaitingTaskHolder waitTask,
171  Principal const& principal,
172  bool skipCurrentProcess,
173  ServiceToken const& token,
175  ModuleCallingContext const* mcc) const = 0;
176 
177  virtual void retrieveAndMerge_(Principal const& principal,
178  MergeableRunProductMetadata const* mergeableRunProductMetadata) const;
179 
180  virtual bool unscheduledWasNotRun_() const = 0;
181  virtual bool productUnavailable_() const = 0;
182  virtual bool productResolved_() const = 0;
183  virtual bool productWasDeleted_() const = 0;
184  virtual bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const = 0;
185 
186  virtual BranchDescription const& branchDescription_() const = 0;
187  virtual void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) = 0;
188  virtual Provenance const* provenance_() const = 0;
189  virtual std::string const& resolvedModuleLabel_() const = 0;
190  virtual void setProductProvenanceRetriever_(ProductProvenanceRetriever const* provRetriever) = 0;
191  virtual void setProductID_(ProductID const& pid) = 0;
193  virtual ProductProvenance const* productProvenancePtr_() const = 0;
194  virtual void resetProductData_(bool deleteEarly) = 0;
195  virtual bool singleProduct_() const = 0;
196  };
197 
198  inline std::ostream& operator<<(std::ostream& os, ProductResolverBase const& phb) {
199  phb.write(os);
200  return os;
201  }
202 } // namespace edm
203 
204 #endif
void setProductID(ProductID const &pid)
std::string const & productInstanceName() const
virtual BranchDescription const & branchDescription_() const =0
Provenance const * provenance() const
void prefetchAsync(WaitingTaskHolder waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
virtual bool productWasDeleted_() const =0
void setMergeableRunProductMetadata(MergeableRunProductMetadata const *mrpm)
virtual void setProductID_(ProductID const &pid)=0
virtual Resolution resolveProduct_(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
virtual bool unscheduledWasNotRun_() const =0
virtual void setProductProvenanceRetriever_(ProductProvenanceRetriever const *provRetriever)=0
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 Provenance const * provenance_() const =0
virtual void resetProductData_(bool deleteEarly)=0
std::string const & processName() const
virtual bool productUnavailable_() const =0
Resolution resolveProduct(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
std::string const & processName() const
StableProvenance const * stableProvenance() const
virtual void prefetchAsync_(WaitingTaskHolder waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
ProductID const & productID() const
virtual void connectTo(ProductResolverBase const &, Principal const *)=0
static std::uintptr_t constexpr kAmbiguityValue
Resolution(ProductData const *iData)
std::string const & moduleLabel() const
std::string const & productInstanceName() const
virtual bool singleProduct_() const =0
virtual bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const =0
void retrieveAndMerge(Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
virtual ProductProvenance const * productProvenancePtr_() const =0
virtual bool productResolved_() const =0
ProductProvenance const * productProvenancePtr() const
virtual void setMergeableRunProductMetadata_(MergeableRunProductMetadata const *)
virtual void retrieveAndMerge_(Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
ProductData const * data() const
bool productWasFetchedAndIsValid(bool iSkipCurrentProcess) const
static std::uintptr_t constexpr kAmbiguityMask
virtual std::string const & resolvedModuleLabel_() const =0
std::string const & resolvedModuleLabel() const
BranchDescription const & branchDescription() const
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
ProductID const & productID() const
Definition: Provenance.h:79
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
std::string const & moduleLabel() const
void setProductProvenanceRetriever(ProductProvenanceRetriever const *provRetriever)
void write(std::ostream &os) const