1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#ifndef DataFormats_Common_ProductData_h
#define DataFormats_Common_ProductData_h
/*----------------------------------------------------------------------
ProductData: A collection of information related to a single EDProduct. This
is the storage unit of such information.
----------------------------------------------------------------------*/
#include "DataFormats/Provenance/interface/Provenance.h"
#include "DataFormats/Provenance/interface/ProductDescriptionFwd.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"
#include <memory>
namespace edm {
class MergeableRunProductMetadataBase;
class WrapperBase;
class ProductData {
public:
ProductData();
explicit ProductData(std::shared_ptr<ProductDescription const> bd);
// For use by FWLite
ProductData(WrapperBase* product, Provenance const& prov);
std::shared_ptr<ProductDescription const> const& productDescription() const {
return prov_.constProductDescriptionPtr();
}
Provenance const& provenance() const { return prov_; }
WrapperBase const* wrapper() const { return wrapper_.get(); }
WrapperBase* unsafe_wrapper() const { return const_cast<WrapperBase*>(wrapper_.get()); }
std::shared_ptr<WrapperBase const> sharedConstWrapper() const { return wrapper_; }
void swap(ProductData& other) {
std::swap(wrapper_, other.wrapper_);
prov_.swap(other.prov_);
}
void setWrapper(std::unique_ptr<WrapperBase> iValue);
//Not const thread-safe update
void unsafe_setWrapper(std::unique_ptr<WrapperBase> iValue) const;
void unsafe_setWrapper(std::shared_ptr<WrapperBase const> iValue) const; // for SwitchProducer
void resetProductDescription(std::shared_ptr<ProductDescription const> bd);
void resetProductData() { wrapper_.reset(); }
void unsafe_resetProductData() const { wrapper_.reset(); }
void setProvenance(ProductProvenanceLookup const* provRetriever) { prov_.setStore(provRetriever); }
void setProductID(ProductID const& pid) { prov_.setProductID(pid); }
void setMergeableRunProductMetadata(MergeableRunProductMetadataBase const* mrpm) {
prov_.setMergeableRunProductMetadata(mrpm);
}
// NOTE: We should probably think hard about whether these
// variables should be declared "mutable" as part of
// the effort to make the Framework multithread capable ...
private:
// "non-const data" (updated every event).
// The mutating function begin with 'unsafe_'
CMS_SA_ALLOW mutable std::shared_ptr<WrapperBase const> wrapper_;
Provenance prov_;
};
// Free swap function
inline void swap(ProductData& a, ProductData& b) { a.swap(b); }
} // namespace edm
#endif
|