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 ProductProvenanceRetriever;
25  class DelayedReader;
26  class ModuleCallingContext;
28  class Principal;
30  class WaitingTask;
31 
33  public:
34 
35  class Resolution {
36  public:
37  static std::uintptr_t constexpr kAmbiguityValue = 0x1;
39  explicit Resolution( ProductData const* iData):
40  m_data(iData) {}
41 
42  bool isAmbiguous() const { return reinterpret_cast<std::uintptr_t>(m_data) == kAmbiguityValue; }
43 
44  ProductData const* data() const { return reinterpret_cast<ProductData const*>(kAmbiguityMask & reinterpret_cast<std::uintptr_t>(m_data)); }
45 
46  static Resolution makeAmbiguous() { return Resolution(reinterpret_cast<ProductData const*>(kAmbiguityValue)); }
47  private:
49  };
50 
52  virtual ~ProductResolverBase();
53 
54  ProductResolverBase(ProductResolverBase const&) = delete; // Disallow copying and moving
55  ProductResolverBase& operator=(ProductResolverBase const&) = delete; // Disallow copying and moving
56 
58  bool skipCurrentProcess,
60  ModuleCallingContext const* mcc) const {
61  return resolveProduct_( principal, skipCurrentProcess, sra, mcc);
62  }
63 
66  void prefetchAsync(WaitingTask* waitTask,
67  Principal const& principal,
68  bool skipCurrentProcess,
70  ModuleCallingContext const* mcc) const {
71  return prefetchAsync_(waitTask, principal, skipCurrentProcess, sra, mcc);
72  }
73 
74  void retrieveAndMerge(Principal const& principal) const {
75  retrieveAndMerge_(principal);
76  }
78 
79  virtual void resetFailedFromThisProcess();
80 
81  void unsafe_deleteProduct() const {
82  const_cast<ProductResolverBase*>(this)->resetProductData_(true);
83  }
84 
85  // product is not available (dropped or never created)
86  bool productUnavailable() const {return productUnavailable_();}
87 
88  // returns true if resolveProduct was already called for this product
89  bool productResolved() const { return productResolved_(); }
90 
91  // provenance is currently available
92  bool provenanceAvailable() const;
93 
94  // Only returns true if the module is unscheduled and was not run
95  // all other cases return false
97 
98  // Product was deleted early in order to save memory
99  bool productWasDeleted() const {return productWasDeleted_();}
100 
101  bool productWasFetchedAndIsValid(bool iSkipCurrentProcess) const { return productWasFetchedAndIsValid_(iSkipCurrentProcess); }
102 
103  // Retrieves pointer to the per event(lumi)(run) provenance.
105 
106  // Retrieves a reference to the event independent provenance.
108 
109  // Retrieves a reference to the event independent provenance.
110  bool singleProduct() const {return singleProduct_();}
111 
112  // Sets the pointer to the event independent provenance.
113  void resetBranchDescription(std::shared_ptr<BranchDescription const> bd) {resetBranchDescription_(bd);}
114 
115  // Retrieves a reference to the module label.
117 
118  // Same as moduleLabel except in the case of an AliasProductResolver, in which
119  // case it resolves the module which actually produces the product and returns
120  // its module label
122 
123  // Retrieves a reference to the product instance name
125 
126  // Retrieves a reference to the process name
128 
129  // Retrieves pointer to a class containing both the event independent and the per even provenance.
130  Provenance const* provenance() const;
131 
132  // Retrieves pointer to a class containing the event independent provenance.
133  StableProvenance const* stableProvenance() const {return &provenance()->stable();}
134 
135  // Initializes the event independent portion of the provenance, plus the process history ID, the product ID, and the provRetriever.
136  void setProvenance(ProductProvenanceRetriever const* provRetriever, ProcessHistory const& ph, ProductID const& pid) { setProvenance_(provRetriever, ph, pid); }
137 
138  // Initializes the process history.
140 
141  // Write the product to the stream.
142  void write(std::ostream& os) const;
143 
144  // Return the type of the product stored in this ProductResolver.
145  // We are relying on the fact that Type instances are small, and
146  // so we are free to copy them at will.
147  TypeID productType() const;
148 
149  // Retrieves the product ID of the product.
150  ProductID const& productID() const {return provenance()->productID();}
151 
152  // Puts the product into the ProductResolver.
153  void putProduct(std::unique_ptr<WrapperBase> edp) const {
154  putProduct_(std::move(edp));
155  }
156 
157  // If the product already exists we merge, else will put
158  void putOrMergeProduct(std::unique_ptr<WrapperBase> edp) const {
160  }
161 
162  virtual void connectTo(ProductResolverBase const&, Principal const*) = 0;
163  virtual void setupUnscheduled(UnscheduledConfigurator const&);
164 
165  private:
167  bool skipCurrentProcess,
169  ModuleCallingContext const* mcc) const = 0;
170  virtual void prefetchAsync_(WaitingTask* waitTask,
171  Principal const& principal,
172  bool skipCurrentProcess,
174  ModuleCallingContext const* mcc) const = 0;
175 
176  virtual void retrieveAndMerge_(Principal const& principal) const;
177 
178 
179  virtual bool unscheduledWasNotRun_() const = 0;
180  virtual bool productUnavailable_() const = 0;
181  virtual bool productResolved_() const = 0;
182  virtual bool productWasDeleted_() const = 0;
183  virtual bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const = 0;
184 
185  virtual void putProduct_(std::unique_ptr<WrapperBase> edp) const = 0;
186  virtual void putOrMergeProduct_(std::unique_ptr<WrapperBase> edp) const = 0;
187  virtual BranchDescription const& branchDescription_() const = 0;
188  virtual void resetBranchDescription_(std::shared_ptr<BranchDescription const> bd) = 0;
189  virtual Provenance const* provenance_() const = 0;
190  virtual std::string const& resolvedModuleLabel_() const = 0;
191  virtual void setProvenance_(ProductProvenanceRetriever const* provRetriever, ProcessHistory const& ph, ProductID const& pid) = 0;
192  virtual void setProcessHistory_(ProcessHistory const& ph) = 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
199  std::ostream&
200  operator<<(std::ostream& os, ProductResolverBase const& phb) {
201  phb.write(os);
202  return os;
203  }
204 }
205 
206 #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 prefetchAsync(WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, 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:40
virtual void setupUnscheduled(UnscheduledConfigurator const &)
virtual ProductProvenance const * productProvenancePtr_() const =0
virtual void putProduct_(std::unique_ptr< WrapperBase > edp) 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
#define constexpr
virtual void setProvenance_(ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)=0
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
virtual void resetFailedFromThisProcess()
virtual void putOrMergeProduct_(std::unique_ptr< WrapperBase > edp) const =0
virtual bool productResolved_() const =0
virtual void prefetchAsync_(WaitingTask *waitTask, Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
void setProcessHistory(ProcessHistory const &ph)
ProductProvenance const * productProvenancePtr() const
virtual bool unscheduledWasNotRun_() const =0
ProductData const * data() const
bool productWasFetchedAndIsValid(bool iSkipCurrentProcess) const
static std::uintptr_t constexpr kAmbiguityMask
void retrieveAndMerge(Principal const &principal) const
HLT enums.
std::string const & resolvedModuleLabel() const
BranchDescription const & branchDescription() const
virtual void retrieveAndMerge_(Principal const &principal) 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:80
virtual bool productUnavailable_() const =0
virtual bool singleProduct_() const =0
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
void putOrMergeProduct(std::unique_ptr< WrapperBase > edp) const
virtual Resolution resolveProduct_(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
def move(src, dest)
Definition: eostools.py:510
std::string const & moduleLabel() const
virtual void setProcessHistory_(ProcessHistory const &ph)=0
virtual bool productWasDeleted_() const =0
void write(std::ostream &os) const