CMS 3D CMS Logo

ProductData.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_ProductData_h
2 #define DataFormats_Common_ProductData_h
3 
4 /*----------------------------------------------------------------------
5 
6 ProductData: A collection of information related to a single EDProduct. This
7 is the storage unit of such information.
8 
9 ----------------------------------------------------------------------*/
10 
12 #include <memory>
13 
14 namespace edm {
15  class BranchDescription;
16  class MergeableRunProductMetadataBase;
17  class WrapperBase;
18 
19  class ProductData {
20  public:
21  ProductData();
22 
23  explicit ProductData(std::shared_ptr<BranchDescription const> bd);
24 
25  // For use by FWLite
26  ProductData(WrapperBase* product, Provenance const& prov);
27 
28  std::shared_ptr<BranchDescription const> const& branchDescription() const {
30  }
31 
32  Provenance const& provenance() const { return prov_; }
33 
34  WrapperBase const* wrapper() const { return wrapper_.get(); }
35  WrapperBase* unsafe_wrapper() const { return const_cast<WrapperBase*>(wrapper_.get()); }
36  std::shared_ptr<WrapperBase const> sharedConstWrapper() const { return wrapper_; }
37 
39  std::swap(wrapper_, other.wrapper_);
40  prov_.swap(other.prov_);
41  }
42 
43  void setWrapper(std::unique_ptr<WrapperBase> iValue);
44 
45  //Not const thread-safe update
46  void unsafe_setWrapper(std::unique_ptr<WrapperBase> iValue) const;
47  void unsafe_setWrapper(std::shared_ptr<WrapperBase const> iValue) const; // for SwitchProducer
48 
49  void resetBranchDescription(std::shared_ptr<BranchDescription const> bd);
50 
51  void resetProductData() { wrapper_.reset(); }
52 
53  void unsafe_resetProductData() const { wrapper_.reset(); }
54 
56 
57  void setProvenance(ProductProvenanceRetriever const* provRetriever,
58  ProcessHistory const& ph,
59  ProductID const& pid) {
60  prov_.setProductID(pid);
61  prov_.setStore(provRetriever);
63  }
64 
67  }
68 
69  // NOTE: We should probably think hard about whether these
70  // variables should be declared "mutable" as part of
71  // the effort to make the Framework multithread capable ...
72 
73  private:
74  // "non-const data" (updated every event)
75  mutable std::shared_ptr<WrapperBase const> wrapper_;
77  };
78 
79  // Free swap function
80  inline void swap(ProductData& a, ProductData& b) { a.swap(b); }
81 } // namespace edm
82 #endif
Provenance const & provenance() const
Definition: ProductData.h:32
void setProcessHistory(ProcessHistory const &ph)
Definition: ProductData.h:55
std::shared_ptr< BranchDescription const > const & branchDescription() const
Definition: ProductData.h:28
WrapperBase const * wrapper() const
Definition: ProductData.h:34
std::shared_ptr< WrapperBase const > wrapper_
Definition: ProductData.h:75
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
Definition: ProductData.cc:20
void unsafe_setWrapper(std::unique_ptr< WrapperBase > iValue) const
Definition: ProductData.cc:27
void setProvenance(ProductProvenanceRetriever const *provRetriever, ProcessHistory const &ph, ProductID const &pid)
Definition: ProductData.h:57
Provenance prov_
Definition: ProductData.h:76
void resetProductData()
Definition: ProductData.h:51
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void setStore(ProductProvenanceRetriever const *store)
Definition: Provenance.h:81
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const *mrpm)
Definition: ProductData.h:65
void setWrapper(std::unique_ptr< WrapperBase > iValue)
Definition: ProductData.cc:24
std::shared_ptr< BranchDescription const > const & constBranchDescriptionPtr() const
Definition: Provenance.h:46
double b
Definition: hdecay.h:118
void setProductID(ProductID const &pid)
Definition: Provenance.h:87
HLT enums.
void setProcessHistory(ProcessHistory const &ph)
Definition: Provenance.h:83
double a
Definition: hdecay.h:119
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const *mrpm)
Definition: Provenance.h:89
void unsafe_resetProductData() const
Definition: ProductData.h:53
void swap(Provenance &)
Definition: Provenance.cc:56
std::shared_ptr< WrapperBase const > sharedConstWrapper() const
Definition: ProductData.h:36
void swap(ProductData &other)
Definition: ProductData.h:38
WrapperBase * unsafe_wrapper() const
Definition: ProductData.h:35