CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ProductProvenanceLookup.h
Go to the documentation of this file.
1 #ifndef DataFormats_Provenance_ProductProvenanceLookup_h
2 #define DataFormats_Provenance_ProductProvenanceLookup_h
3 
4 /*----------------------------------------------------------------------
5 
6 ProductProvenanceLookup: Gives access to the per event/lumi/run per product provenance.
7 
8 ----------------------------------------------------------------------*/
14 
15 #include <vector>
16 #include <memory>
17 #include <set>
18 #include <atomic>
19 
20 /*
21  ProductProvenanceLookup
22 */
23 
24 namespace edm {
25  class ProductRegistry;
26 
28  public:
31  virtual ~ProductProvenanceLookup();
32 
34 
35  ProductProvenance const* branchIDToProvenance(BranchID const& bid) const;
36  void insertIntoSet(ProductProvenance provenanceProduct) const;
38 
39  void update(edm::ProductRegistry const&);
40 
42  public:
45  : provenance_{std::move(iOther.provenance_)},
46  isParentageSet_{iOther.isParentageSet_.load(std::memory_order_acquire)} {}
48  bool isSet = iOther.isParentageSet_.load(std::memory_order_acquire);
49  if (isSet) {
50  provenance_.set(iOther.provenance_.parentageID());
51  }
52  isParentageSet_.store(isSet, std::memory_order_release);
53  }
54 
56  provenance_ = std::move(iOther.provenance_);
57  isParentageSet_.store(iOther.isParentageSet_.load(std::memory_order_acquire), std::memory_order_release);
58  return *this;
59  }
61  bool isSet = iOther.isParentageSet_.load(std::memory_order_acquire);
62  if (isSet) {
63  provenance_ = iOther.provenance_;
64  } else {
66  }
67  isParentageSet_.store(isSet, std::memory_order_release);
68  return *this;
69  }
70 
72  if (LIKELY(isParentageSet())) {
73  return &provenance_;
74  }
75  return nullptr;
76  }
77  BranchID branchID() const noexcept { return provenance_.branchID(); }
78 
79  bool isParentageSet() const noexcept { return isParentageSet_.load(std::memory_order_acquire); }
80 
81  void threadsafe_set(ParentageID id) const {
83  isParentageSet_.store(true, std::memory_order_release);
84  }
85 
86  void resetParentage() { isParentageSet_.store(false, std::memory_order_release); }
87 
88  private:
90  mutable std::atomic<bool> isParentageSet_;
91  };
92 
93  protected:
94  virtual std::unique_ptr<const std::set<ProductProvenance>> readProvenance() const = 0;
95  virtual const ProductProvenanceLookup* nextRetriever() const = 0;
96 
98  mutable std::atomic<const std::set<ProductProvenance>*> readEntryInfoSet_;
100 
101  private:
102  void setupEntryInfoSet(edm::ProductRegistry const&);
103  };
104 } // namespace edm
105 #endif
ProductProvenance const * branchIDToProvenanceForProducedOnly(BranchID const &bid) const
BranchID const & branchID() const
ProducedProvenanceInfo & operator=(ProducedProvenanceInfo &&iOther)
ProductProvenance const * productProvenance() const noexcept
ProductProvenanceLookup & operator=(ProductProvenanceLookup const &)=delete
#define LIKELY(x)
Definition: Likely.h:20
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
void set(ParentageID id)
virtual std::unique_ptr< const std::set< ProductProvenance > > readProvenance() const =0
def move
Definition: eostools.py:511
#define CMS_THREAD_GUARD(_var_)
void update(edm::ProductRegistry const &)
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
virtual const ProductProvenanceLookup * nextRetriever() const =0
void insertIntoSet(ProductProvenance provenanceProduct) const
edm::propagate_const< ProductProvenanceLookup const * > parentProcessRetriever_
std::vector< ProducedProvenanceInfo > entryInfoSet_
ProducedProvenanceInfo & operator=(ProducedProvenanceInfo const &iOther)
ProducedProvenanceInfo(ProducedProvenanceInfo const &iOther)
void setupEntryInfoSet(edm::ProductRegistry const &)