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
edm::ProductData::unsafe_resetProductData
void unsafe_resetProductData() const
Definition: ProductData.h:54
edm::MergeableRunProductMetadataBase
Definition: MergeableRunProductMetadataBase.h:7
edm::ProductData::ProductData
ProductData()
Definition: ProductData.cc:12
edm::ProductData::wrapper_
std::shared_ptr< WrapperBase const > wrapper_
Definition: ProductData.h:71
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ProductData::wrapper
WrapperBase const * wrapper() const
Definition: ProductData.h:35
deep_tau::DeepTauBase::BasicDiscriminator
BasicDiscriminator
Definition: DeepTauBase.h:115
edm::swap
void swap(Association< C > &lhs, Association< C > &rhs)
Definition: Association.h:117
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
edm::ProductData::provenance
Provenance const & provenance() const
Definition: ProductData.h:33
edm::ProductData::sharedConstWrapper
std::shared_ptr< WrapperBase const > sharedConstWrapper() const
Definition: ProductData.h:37
edm::ProductData::resetBranchDescription
void resetBranchDescription(std::shared_ptr< BranchDescription const > bd)
Definition: ProductData.cc:20
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition: DataFrameContainer.h:209
edm::ProductData::setWrapper
void setWrapper(std::unique_ptr< WrapperBase > iValue)
Definition: ProductData.cc:24
edm::ProductData::swap
void swap(ProductData &other)
Definition: ProductData.h:39
Provenance.h
trackingPlots.other
other
Definition: trackingPlots.py:1464
b
double b
Definition: hdecay.h:118
edm::ProductData::setProvenance
void setProvenance(ProductProvenanceLookup const *provRetriever)
Definition: ProductData.h:56
a
double a
Definition: hdecay.h:119
thread_safety_macros.h
edm::ProductData::prov_
Provenance prov_
Definition: ProductData.h:72
edm::WrapperBase
Definition: WrapperBase.h:23
edm::ProductData::unsafe_wrapper
WrapperBase * unsafe_wrapper() const
Definition: ProductData.h:36
edm::ProductData::setMergeableRunProductMetadata
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const *mrpm)
Definition: ProductData.h:60
edm::ProductData::branchDescription
std::shared_ptr< BranchDescription const > const & branchDescription() const
Definition: ProductData.h:29
edm::ProductData
Definition: ProductData.h:20
edm::Provenance::setStore
void setStore(ProductProvenanceLookup const *store)
Definition: Provenance.h:77
edm::ProductData::resetProductData
void resetProductData()
Definition: ProductData.h:52
edm::ProductData::setProductID
void setProductID(ProductID const &pid)
Definition: ProductData.h:58
edm::Provenance
Definition: Provenance.h:34
edm::Provenance::constBranchDescriptionPtr
std::shared_ptr< BranchDescription const > const & constBranchDescriptionPtr() const
Definition: Provenance.h:46
edm::Provenance::setProductID
void setProductID(ProductID const &pid)
Definition: Provenance.h:81
edm::ProductID
Definition: ProductID.h:27
edm::ProductProvenanceLookup
Definition: ProductProvenanceLookup.h:27
edm::Provenance::swap
void swap(Provenance &)
Definition: Provenance.cc:53
edm::ProductData::unsafe_setWrapper
void unsafe_setWrapper(std::unique_ptr< WrapperBase > iValue) const
Definition: ProductData.cc:27
edm::Provenance::setMergeableRunProductMetadata
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const *mrpm)
Definition: Provenance.h:83