CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ProductProvenanceRetriever.cc
Go to the documentation of this file.
3 
4 #include <cassert>
5 #include <iostream>
6 #include <limits>
7 
8 /*
9  ProductProvenanceRetriever
10 */
11 
12 namespace edm {
14  entryInfoSet_(),
15  nextRetriever_(),
16  provenanceReader_(),
17  transitionIndex_(iTransitionIndex),
18  delayedRead_(false){
19  }
20 
21  ProductProvenanceRetriever::ProductProvenanceRetriever(std::unique_ptr<ProvenanceReaderBase> reader) :
22  entryInfoSet_(),
23  nextRetriever_(),
24  provenanceReader_(reader.release()),
25  transitionIndex_(std::numeric_limits<unsigned int>::max()),
26  delayedRead_(true)
27  {
29  }
30 
32 
33  void
36  provenanceReader_->readProvenance(*this,transitionIndex_);
37  delayedRead_ = false; // only read once
38  }
39  }
40 
42  {
43  entryInfoSet_.swap(iFrom.entryInfoSet_);
45  if(provenanceReader_) {
46  delayedRead_=true;
47  }
48  if(iFrom.nextRetriever_) {
49  if(not nextRetriever_) {
50  nextRetriever_.reset(new ProductProvenanceRetriever(transitionIndex_));
51  }
52  nextRetriever_->deepSwap(*(iFrom.nextRetriever_));
53  }
54  }
55 
56  void
58  entryInfoSet_.clear();
59  delayedRead_ = true;
60  if(nextRetriever_) {
61  nextRetriever_->reset();
62  }
63  }
64 
65  void
67  //NOTE:do not read provenance here because we only need the full
68  // provenance when someone tries to access it not when doing the insert
69  // doing the delay saves 20% of time when doing an analysis job
70  //readProvenance();
71  entryInfoSet_.insert(entryInfo);
72  }
73 
74  void
75  ProductProvenanceRetriever::mergeProvenanceRetrievers(std::shared_ptr<ProductProvenanceRetriever> other) {
76  nextRetriever_ = other;
77  }
78 
79  ProductProvenance const*
82  ProductProvenance ei(bid);
83  eiSet::const_iterator it = entryInfoSet_.find(ei);
84  if(it == entryInfoSet_.end()) {
85  if(nextRetriever_) {
86  return nextRetriever_->branchIDToProvenance(bid);
87  } else {
88  return 0;
89  }
90  }
91  return &*it;
92  }
93 
95  }
96 }
assert(m_qm.get())
void mergeProvenanceRetrievers(std::shared_ptr< ProductProvenanceRetriever > other)
void deepSwap(ProductProvenanceRetriever &)
std::shared_ptr< ProvenanceReaderBase > provenanceReader_
std::shared_ptr< ProductProvenanceRetriever > nextRetriever_
ProductProvenanceRetriever(unsigned int iTransitionIndex)
ProductProvenance const * branchIDToProvenance(BranchID const &bid) const
volatile std::atomic< bool > shutdown_flag false
EventID const & max(EventID const &lh, EventID const &rh)
Definition: EventID.h:142
void insertIntoSet(ProductProvenance const &provenanceProduct) const