CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProductProvenanceRetriever.h
Go to the documentation of this file.
1 #ifndef DataFormats_Provenance_BranchMapper_h
2 #define DataFormats_Provenance_BranchMapper_h
3 
4 /*----------------------------------------------------------------------
5 
6 ProductProvenanceRetriever: Manages the per event/lumi/run per product provenance.
7 
8 ----------------------------------------------------------------------*/
13 
14 #include "tbb/concurrent_unordered_set.h"
15 #include <memory>
16 #include <set>
17 #include <atomic>
18 
19 /*
20  ProductProvenanceRetriever
21 */
22 
23 namespace edm {
24  class ProvenanceReaderBase;
25 
27  size_t operator()(ProductProvenance const& tid) const {
28  return tid.branchID().id();
29  }
30  };
31 
33  //The default operator== for ProductProvenance does not work for this case
34  // Since (a<b)==false and (a>b)==false does not mean a==b for the operators
35  // defined for ProductProvenance
36  bool operator()(ProductProvenance const& iLHS, ProductProvenance const iRHS) const {
37  return iLHS.branchID().id()== iRHS.branchID().id();
38  }
39  };
40 
42  public:
43  explicit ProductProvenanceRetriever(unsigned int iTransitionIndex);
44  explicit ProductProvenanceRetriever(std::unique_ptr<ProvenanceReaderBase> reader);
45 
47 
49 
50  ProductProvenance const* branchIDToProvenance(BranchID const& bid) const;
51 
52  void insertIntoSet(ProductProvenance const& provenanceProduct) const;
53 
54  void mergeProvenanceRetrievers(std::shared_ptr<ProductProvenanceRetriever> other);
55 
57 
58  void reset();
59  private:
60  void readProvenance() const;
61  void setTransitionIndex(unsigned int transitionIndex) {
62  transitionIndex_=transitionIndex;
63  }
64 
65  mutable tbb::concurrent_unordered_set<ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual> entryInfoSet_;
66  mutable std::atomic<const std::set<ProductProvenance>*> readEntryInfoSet_;
68  std::shared_ptr<const ProvenanceReaderBase> provenanceReader_;
69  unsigned int transitionIndex_;
70  };
71 
73  public:
75  virtual ~ProvenanceReaderBase();
76  virtual std::set<ProductProvenance> readProvenance(unsigned int transitionIndex) const = 0;
77  };
78 
79 }
80 #endif
BranchID const & branchID() const
tbb::concurrent_unordered_set< ProductProvenance, ProductProvenanceHasher, ProductProvenanceEqual > entryInfoSet_
void deepCopy(ProductProvenanceRetriever const &)
ProductProvenanceRetriever & operator=(ProductProvenanceRetriever const &)=delete
unsigned int id() const
Definition: BranchID.h:23
void mergeProvenanceRetrievers(std::shared_ptr< ProductProvenanceRetriever > other)
size_t operator()(ProductProvenance const &tid) const
std::shared_ptr< const ProvenanceReaderBase > provenanceReader_
bool operator()(ProductProvenance const &iLHS, ProductProvenance const iRHS) const
std::atomic< const std::set< ProductProvenance > * > readEntryInfoSet_
virtual std::set< ProductProvenance > readProvenance(unsigned int transitionIndex) const =0
ProductProvenanceRetriever(unsigned int iTransitionIndex)
edm::propagate_const< std::shared_ptr< ProductProvenanceRetriever > > nextRetriever_
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
void setTransitionIndex(unsigned int transitionIndex)
void insertIntoSet(ProductProvenance const &provenanceProduct) const