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 
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
edm::ProductResolverBase::ProductResolverBase
ProductResolverBase()
Definition: ProductResolverBase.cc:14
edm::ProductResolverBase::provenance
Provenance const * provenance() const
Definition: ProductResolverBase.cc:31
edm::SharedResourcesAcquirer
Definition: SharedResourcesAcquirer.h:34
edm::BranchDescription::productInstanceName
std::string const & productInstanceName() const
Definition: BranchDescription.h:81
edm::ProductResolverBase::resetProductData_
virtual void resetProductData_(bool deleteEarly)=0
edm::ProductResolverBase::setProductProvenanceRetriever_
virtual void setProductProvenanceRetriever_(ProductProvenanceRetriever const *provRetriever)=0
edm::ProductResolverBase::operator=
ProductResolverBase & operator=(ProductResolverBase const &)=delete
edm::ProductResolverBase::singleProduct_
virtual bool singleProduct_() const =0
WaitingTaskHolder.h
edm::ProductResolverBase::stableProvenance
StableProvenance const * stableProvenance() const
Definition: ProductResolverBase.h:136
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProductResolverBase::productUnavailable_
virtual bool productUnavailable_() const =0
edm::ProductResolverBase::provenance_
virtual Provenance const * provenance_() const =0
edm::ProductResolverBase::Resolution::kAmbiguityValue
static constexpr std::uintptr_t kAmbiguityValue
Definition: ProductResolverBase.h:38
deep_tau::DeepTauBase::BasicDiscriminator
BasicDiscriminator
Definition: DeepTauBase.h:115
ProductResolverIndex.h
BranchID.h
edm::Provenance::productID
ProductID const & productID() const
Definition: Provenance.h:79
TypeID.h
edm::Principal
Definition: Principal.h:56
edm::ProductResolverBase::productResolved
bool productResolved() const
Definition: ProductResolverBase.h:90
edm::ProductResolverBase::prefetchAsync_
virtual void prefetchAsync_(WaitingTaskHolder waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
edm::ProductResolverBase::Resolution::isAmbiguous
bool isAmbiguous() const
Definition: ProductResolverBase.h:42
edm::ProductResolverBase::provenanceAvailable
bool provenanceAvailable() const
Definition: ProductResolverBase.cc:18
edm::ProductResolverBase::resetBranchDescription_
virtual void resetBranchDescription_(std::shared_ptr< BranchDescription const > bd)=0
edm::ProductResolverBase::productType
TypeID productType() const
Definition: ProductResolverBase.cc:29
edm::ProductResolverBase::prefetchAsync
void prefetchAsync(WaitingTaskHolder waitTask, Principal const &principal, bool skipCurrentProcess, ServiceToken const &token, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: ProductResolverBase.h:69
edm::ProductResolverBase::productUnavailable
bool productUnavailable() const
Definition: ProductResolverBase.h:87
edm::operator<<
std::ostream & operator<<(std::ostream &ost, const HLTGlobalStatus &hlt)
Formatted printout of trigger tbale.
Definition: HLTGlobalStatus.h:106
edm::ServiceToken
Definition: ServiceToken.h:42
edm::ProductProvenance
Definition: ProductProvenance.h:24
edm::ProductResolverBase::branchDescription_
virtual BranchDescription const & branchDescription_() const =0
edm::BranchDescription::processName
std::string const & processName() const
Definition: BranchDescription.h:73
edm::ProductResolverBase::unscheduledWasNotRun
bool unscheduledWasNotRun() const
Definition: ProductResolverBase.h:97
edm::ProductResolverBase::unscheduledWasNotRun_
virtual bool unscheduledWasNotRun_() const =0
Provenance.h
edm::MergeableRunProductMetadata
Definition: MergeableRunProductMetadata.h:52
edm::ProductResolverBase::processName
std::string const & processName() const
Definition: ProductResolverBase.h:130
edm::ProductResolverBase::setProductID_
virtual void setProductID_(ProductID const &pid)=0
edm::ProductResolverBase::unsafe_deleteProduct
void unsafe_deleteProduct() const
Definition: ProductResolverBase.h:84
edm::ProductResolverBase::resolveProduct
Resolution resolveProduct(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const
Definition: ProductResolverBase.h:60
WrapperBase.h
edm::ProductResolverBase::write
void write(std::ostream &os) const
Definition: ProductResolverBase.cc:37
SharedResourcesAcquirer
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ProductResolverBase::setProductID
void setProductID(ProductID const &pid)
Definition: ProductResolverBase.h:144
edm::ProductResolverBase::setMergeableRunProductMetadata_
virtual void setMergeableRunProductMetadata_(MergeableRunProductMetadata const *)
Definition: ProductResolverBase.cc:35
Resolution
Definition: trackSplitPlot.h:33
BranchDescription.h
edm::ProductResolverBase::productWasDeleted_
virtual bool productWasDeleted_() const =0
edm::ProductResolverBase::~ProductResolverBase
virtual ~ProductResolverBase()
Definition: ProductResolverBase.cc:16
edm::WaitingTaskHolder
Definition: WaitingTaskHolder.h:32
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edm::ProductResolverBase::resolvedModuleLabel_
virtual std::string const & resolvedModuleLabel_() const =0
edm::StableProvenance
Definition: StableProvenance.h:30
edm::ProductResolverBase::Resolution::m_data
ProductData const * m_data
Definition: ProductResolverBase.h:51
edm::ProductResolverBase::productID
ProductID const & productID() const
Definition: ProductResolverBase.h:160
edm::ProductResolverBase::setMergeableRunProductMetadata
void setMergeableRunProductMetadata(MergeableRunProductMetadata const *mrpm)
Definition: ProductResolverBase.h:147
ProductData.h
edm::ProductResolverBase::productWasFetchedAndIsValid_
virtual bool productWasFetchedAndIsValid_(bool iSkipCurrentProcess) const =0
edm::ProductResolverBase::resolvedModuleLabel
std::string const & resolvedModuleLabel() const
Definition: ProductResolverBase.h:124
edm::ProductResolverBase::resetProductData
void resetProductData()
Definition: ProductResolverBase.h:82
edm::UnscheduledConfigurator
Definition: UnscheduledConfigurator.h:32
edm::ProductResolverBase::resetBranchDescription
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
Definition: ProductResolverBase.h:116
edm::ProductResolverBase::productWasFetchedAndIsValid
bool productWasFetchedAndIsValid(bool iSkipCurrentProcess) const
Definition: ProductResolverBase.h:102
ServiceToken
edm::ProductResolverBase::Resolution::makeAmbiguous
static Resolution makeAmbiguous()
Definition: ProductResolverBase.h:48
edm::ProductResolverBase::Resolution::Resolution
Resolution(ProductData const *iData)
Definition: ProductResolverBase.h:40
edm::ProductResolverBase::moduleLabel
std::string const & moduleLabel() const
Definition: ProductResolverBase.h:119
edm::ProductResolverBase::Resolution::data
ProductData const * data() const
Definition: ProductResolverBase.h:44
edm::ProductResolverBase::retrieveAndMerge_
virtual void retrieveAndMerge_(Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
Definition: ProductResolverBase.cc:33
edm::ProductProvenanceRetriever
Definition: ProductProvenanceRetriever.h:56
edm::ProductResolverBase::resolveProduct_
virtual Resolution resolveProduct_(Principal const &principal, bool skipCurrentProcess, SharedResourcesAcquirer *sra, ModuleCallingContext const *mcc) const =0
edm::TypeID
Definition: TypeID.h:22
edm::ProductResolverBase::branchDescription
BranchDescription const & branchDescription() const
Definition: ProductResolverBase.h:110
edm::BranchDescription::moduleLabel
std::string const & moduleLabel() const
Definition: BranchDescription.h:72
edm::ProductResolverBase
Definition: ProductResolverBase.h:34
edm::Provenance::stable
StableProvenance const & stable() const
Definition: Provenance.h:42
edm::ProductData
Definition: ProductData.h:20
UnscheduledConfigurator
edm::ProductResolverBase::productWasDeleted
bool productWasDeleted() const
Definition: ProductResolverBase.h:100
edm::ProductResolverBase::setupUnscheduled
virtual void setupUnscheduled(UnscheduledConfigurator const &)
Definition: ProductResolverBase.cc:43
edm::ProductResolverBase::connectTo
virtual void connectTo(ProductResolverBase const &, Principal const *)=0
edm::BranchDescription
Definition: BranchDescription.h:32
edm::ProductResolverBase::productResolved_
virtual bool productResolved_() const =0
edm::ProductResolverBase::singleProduct
bool singleProduct() const
Definition: ProductResolverBase.h:113
edm::ProductResolverBase::productInstanceName
std::string const & productInstanceName() const
Definition: ProductResolverBase.h:127
edm::ProductResolverBase::Resolution
Definition: ProductResolverBase.h:36
edm::Provenance
Definition: Provenance.h:34
edm::ProductResolverBase::productProvenancePtr_
virtual ProductProvenance const * productProvenancePtr_() const =0
edm::ProductResolverBase::productProvenancePtr
ProductProvenance const * productProvenancePtr() const
Definition: ProductResolverBase.h:107
edm::ProductResolverBase::Resolution::kAmbiguityMask
static constexpr std::uintptr_t kAmbiguityMask
Definition: ProductResolverBase.h:39
edm::ProductResolverBase::retrieveAndMerge
void retrieveAndMerge(Principal const &principal, MergeableRunProductMetadata const *mergeableRunProductMetadata) const
Definition: ProductResolverBase.h:78
edm::ProductResolverBase::setProductProvenanceRetriever
void setProductProvenanceRetriever(ProductProvenanceRetriever const *provRetriever)
Definition: ProductResolverBase.h:139
edm::ProductID
Definition: ProductID.h:27
edm::ModuleCallingContext
Definition: ModuleCallingContext.h:29
unpackBuffers-CaloStage2.token
token
Definition: unpackBuffers-CaloStage2.py:316