Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-05-17 03:00:17

0001 #ifndef DataFormats_Provenance_ProductProvenanceRetriever_h
0002 #define DataFormats_Provenance_ProductProvenanceRetriever_h
0003 
0004 /*----------------------------------------------------------------------
0005   
0006 ProductProvenanceRetriever: Manages the per event/lumi/run per product provenance.
0007 
0008 ----------------------------------------------------------------------*/
0009 #include "DataFormats/Provenance/interface/ProductProvenance.h"
0010 #include "DataFormats/Provenance/interface/ProductProvenanceLookup.h"
0011 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0012 #include "FWCore/Utilities/interface/propagate_const.h"
0013 
0014 #include <memory>
0015 #include <set>
0016 #include <atomic>
0017 
0018 /*
0019   ProductProvenanceRetriever
0020 */
0021 
0022 namespace edm {
0023   class ModuleCallingContext;
0024   class ProductRegistry;
0025 
0026   class ProvenanceReaderBase {
0027   public:
0028     ProvenanceReaderBase() {}
0029     virtual ~ProvenanceReaderBase();
0030     virtual std::set<ProductProvenance> readProvenance(unsigned int transitionIndex) const = 0;
0031     virtual void readProvenanceAsync(WaitingTaskHolder task,
0032                                      ModuleCallingContext const* moduleCallingContext,
0033                                      unsigned int transitionIndex,
0034                                      std::atomic<const std::set<ProductProvenance>*>& writeTo) const = 0;
0035   };
0036 
0037   class ProductProvenanceRetriever : public ProductProvenanceLookup {
0038   public:
0039     explicit ProductProvenanceRetriever(unsigned int iTransitionIndex);
0040     ProductProvenanceRetriever(unsigned int iTransitionIndex, edm::ProductRegistry const&);
0041     explicit ProductProvenanceRetriever(std::unique_ptr<ProvenanceReaderBase> reader);
0042 
0043     ProductProvenanceRetriever& operator=(ProductProvenanceRetriever const&) = delete;
0044 
0045     void mergeProvenanceRetrievers(std::shared_ptr<ProductProvenanceRetriever> other);
0046 
0047     void mergeParentProcessRetriever(ProductProvenanceRetriever const& provRetriever);
0048 
0049     void deepCopy(ProductProvenanceRetriever const&);
0050 
0051     void reset();
0052 
0053     void readProvenanceAsync(WaitingTaskHolder task, ModuleCallingContext const* moduleCallingContext) const;
0054 
0055   private:
0056     std::unique_ptr<const std::set<ProductProvenance>> readProvenance() const final;
0057     const ProductProvenanceLookup* nextRetriever() const final { return nextRetriever_.get(); }
0058     void setTransitionIndex(unsigned int transitionIndex) { transitionIndex_ = transitionIndex; }
0059 
0060     edm::propagate_const<std::shared_ptr<ProductProvenanceRetriever>> nextRetriever_;
0061     std::shared_ptr<const ProvenanceReaderBase> provenanceReader_;
0062     unsigned int transitionIndex_;
0063   };
0064 
0065 }  // namespace edm
0066 #endif