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 
13 #include <memory>
14 
15 namespace edm {
16  class BranchDescription;
17  class MergeableRunProductMetadataBase;
18  class WrapperBase;
19 
20  class ProductData {
21  public:
22  ProductData();
23 
24  explicit ProductData(std::shared_ptr<BranchDescription const> bd);
25 
26  // For use by FWLite
27  ProductData(WrapperBase* product, Provenance const& prov);
28 
29  std::shared_ptr<BranchDescription const> const& branchDescription() const {
31  }
32 
33  Provenance const& provenance() const { return prov_; }
34 
35  WrapperBase const* wrapper() const { return wrapper_.get(); }
36  WrapperBase* unsafe_wrapper() const { return const_cast<WrapperBase*>(wrapper_.get()); }
37  std::shared_ptr<WrapperBase const> sharedConstWrapper() const { return wrapper_; }
38 
40  std::swap(wrapper_, other.wrapper_);
41  prov_.swap(other.prov_);
42  }
43 
44  void setWrapper(std::unique_ptr<WrapperBase> iValue);
45 
46  //Not const thread-safe update
47  void unsafe_setWrapper(std::unique_ptr<WrapperBase> iValue) const;
48  void unsafe_setWrapper(std::shared_ptr<WrapperBase const> iValue) const; // for SwitchProducer
49 
50  void resetBranchDescription(std::shared_ptr<BranchDescription const> bd);
51 
52  void resetProductData() { wrapper_.reset(); }
53 
54  void unsafe_resetProductData() const { wrapper_.reset(); }
55 
56  void setProvenance(ProductProvenanceLookup const* provRetriever) { prov_.setStore(provRetriever); }
57 
58  void setProductID(ProductID const& pid) { prov_.setProductID(pid); }
59 
62  }
63 
64  // NOTE: We should probably think hard about whether these
65  // variables should be declared "mutable" as part of
66  // the effort to make the Framework multithread capable ...
67 
68  private:
69  // "non-const data" (updated every event).
70  // The mutating function begin with 'unsafe_'
71  CMS_SA_ALLOW mutable std::shared_ptr<WrapperBase const> wrapper_;
73  };
74 
75  // Free swap function
76  inline void swap(ProductData& a, ProductData& b) { a.swap(b); }
77 } // namespace edm
78 #endif
#define CMS_SA_ALLOW
Provenance const & provenance() const
Definition: ProductData.h:33
std::shared_ptr< WrapperBase const > wrapper_
Definition: ProductData.h:71
WrapperBase const * wrapper() const
Definition: ProductData.h:35
void setProductID(ProductID const &pid)
Definition: ProductData.h:58
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
Provenance prov_
Definition: ProductData.h:72
void unsafe_resetProductData() const
Definition: ProductData.h:54
void resetProductData()
Definition: ProductData.h:52
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const *mrpm)
Definition: ProductData.h:60
WrapperBase * unsafe_wrapper() const
Definition: ProductData.h:36
void setWrapper(std::unique_ptr< WrapperBase > iValue)
Definition: ProductData.cc:24
void setProvenance(ProductProvenanceLookup const *provRetriever)
Definition: ProductData.h:56
double b
Definition: hdecay.h:118
void setProductID(ProductID const &pid)
Definition: Provenance.h:81
HLT enums.
double a
Definition: hdecay.h:119
void unsafe_setWrapper(std::unique_ptr< WrapperBase > iValue) const
Definition: ProductData.cc:27
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const *mrpm)
Definition: Provenance.h:83
std::shared_ptr< BranchDescription const > const & constBranchDescriptionPtr() const
Definition: Provenance.h:46
std::shared_ptr< WrapperBase const > sharedConstWrapper() const
Definition: ProductData.h:37
void swap(Provenance &)
Definition: Provenance.cc:53
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
Definition: ProductData.cc:20
void swap(ProductData &other)
Definition: ProductData.h:39
void setStore(ProductProvenanceLookup const *store)
Definition: Provenance.h:77
std::shared_ptr< BranchDescription const > const & branchDescription() const
Definition: ProductData.h:29