Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-09-11 22:29:28

0001 #ifndef FWCore_Framework_one_EDProducerBase_h
0002 #define FWCore_Framework_one_EDProducerBase_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     FWCore/Framework
0006 // Class  :     one::EDProducerBase
0007 //
0008 /**\class one::EDProducerBase EDProducerBase.h "FWCore/Framework/interface/one/EDProducerBase.h"
0009 
0010  Description: Base class for edm::one::EDProducer<>
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Thu, 02 May 2013 21:21:21 GMT
0019 //
0020 
0021 // system include files
0022 
0023 // user include files
0024 #include "FWCore/Framework/interface/ProducerBase.h"
0025 #include "FWCore/Framework/interface/EDConsumerBase.h"
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/SharedResourcesAcquirer.h"
0028 #include "DataFormats/Provenance/interface/ModuleDescription.h"
0029 #include "FWCore/ParameterSet/interface/ParameterSetfwd.h"
0030 #include "FWCore/Concurrency/interface/WaitingTaskHolder.h"
0031 
0032 // forward declarations
0033 namespace edm {
0034 
0035   class ModuleCallingContext;
0036   class PreallocationConfiguration;
0037   class ActivityRegistry;
0038   class ThinnedAssociationsHelper;
0039   class EventForTransformer;
0040 
0041   namespace maker {
0042     template <typename T>
0043     class ModuleHolderT;
0044   }
0045 
0046   namespace one {
0047 
0048     class EDProducerBase : public ProducerBase, public EDConsumerBase {
0049     public:
0050       template <typename T>
0051       friend class edm::maker::ModuleHolderT;
0052       template <typename T>
0053       friend class edm::WorkerT;
0054       typedef EDProducerBase ModuleType;
0055 
0056       EDProducerBase();
0057       ~EDProducerBase() override;
0058 
0059       static void fillDescriptions(ConfigurationDescriptions& descriptions);
0060       static void prevalidate(ConfigurationDescriptions& descriptions);
0061       static const std::string& baseType();
0062 
0063       // Warning: the returned moduleDescription will be invalid during construction
0064       ModuleDescription const& moduleDescription() const { return moduleDescription_; }
0065 
0066       virtual bool wantsProcessBlocks() const = 0;
0067       virtual bool wantsInputProcessBlocks() const = 0;
0068       virtual bool wantsGlobalRuns() const = 0;
0069       virtual bool wantsGlobalLuminosityBlocks() const = 0;
0070       bool wantsStreamRuns() const { return false; }
0071       bool wantsStreamLuminosityBlocks() const { return false; };
0072 
0073       virtual SerialTaskQueue* globalRunsQueue();
0074       virtual SerialTaskQueue* globalLuminosityBlocksQueue();
0075 
0076     private:
0077       bool doEvent(EventTransitionInfo const&, ActivityRegistry*, ModuleCallingContext const*);
0078       //For now this is a placeholder
0079       /*virtual*/ void preActionBeforeRunEventAsync(WaitingTaskHolder,
0080                                                     ModuleCallingContext const&,
0081                                                     Principal const&) const {}
0082 
0083       void doTransform(size_t iTransformIndex,
0084                        EventPrincipal const& iEvent,
0085                        ActivityRegistry*,
0086                        ModuleCallingContext const*);
0087       void doPreallocate(PreallocationConfiguration const&);
0088       virtual void preallocLumis(unsigned int);
0089       void doBeginJob();
0090       void doEndJob();
0091 
0092       void doBeginProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0093       void doAccessInputProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0094       void doEndProcessBlock(ProcessBlockPrincipal const&, ModuleCallingContext const*);
0095       void doBeginRun(RunTransitionInfo const&, ModuleCallingContext const*);
0096       void doEndRun(RunTransitionInfo const&, ModuleCallingContext const*);
0097       void doBeginLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0098       void doEndLuminosityBlock(LumiTransitionInfo const&, ModuleCallingContext const*);
0099 
0100       void doRespondToOpenInputFile(FileBlock const&) {}
0101       void doRespondToCloseInputFile(FileBlock const&) {}
0102       void doRespondToCloseOutputFile() { clearInputProcessBlockCaches(); }
0103       void doRegisterThinnedAssociations(ProductRegistry const&, ThinnedAssociationsHelper&) {}
0104 
0105       void registerProductsAndCallbacks(EDProducerBase* module, ProductRegistry* reg) {
0106         registerProducts(module, reg, moduleDescription_);
0107       }
0108       std::string workerType() const { return "WorkerT<EDProducer>"; }
0109 
0110       SharedResourcesAcquirer& sharedResourcesAcquirer() { return resourcesAcquirer_; }
0111 
0112       virtual void produce(Event&, EventSetup const&) = 0;
0113       virtual void beginJob() {}
0114       virtual void endJob() {}
0115 
0116       virtual void preallocThreads(unsigned int) {}
0117 
0118       virtual void doBeginProcessBlock_(ProcessBlock const&);
0119       virtual void doAccessInputProcessBlock_(ProcessBlock const&);
0120       virtual void doEndProcessBlock_(ProcessBlock const&);
0121       virtual void doBeginRun_(Run const& rp, EventSetup const& c);
0122       virtual void doEndRun_(Run const& rp, EventSetup const& c);
0123       virtual void doBeginLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0124       virtual void doEndLuminosityBlock_(LuminosityBlock const& lbp, EventSetup const& c);
0125 
0126       virtual void doBeginProcessBlockProduce_(ProcessBlock&);
0127       virtual void doEndProcessBlockProduce_(ProcessBlock&);
0128       virtual void doBeginRunProduce_(Run& rp, EventSetup const& c);
0129       virtual void doEndRunProduce_(Run& rp, EventSetup const& c);
0130       virtual void doBeginLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c);
0131       virtual void doEndLuminosityBlockProduce_(LuminosityBlock& lbp, EventSetup const& c);
0132 
0133       virtual size_t transformIndex_(edm::BranchDescription const& iBranch) const;
0134       virtual ProductResolverIndex transformPrefetch_(std::size_t iIndex) const;
0135       virtual void transform_(std::size_t iIndex, edm::EventForTransformer& iEvent) const;
0136 
0137       virtual void clearInputProcessBlockCaches();
0138       virtual bool hasAccumulator() const { return false; }
0139 
0140       bool hasAcquire() const { return false; }
0141 
0142       virtual SharedResourcesAcquirer createAcquirer();
0143 
0144       void setModuleDescription(ModuleDescription const& md) { moduleDescription_ = md; }
0145       ModuleDescription moduleDescription_;
0146       std::vector<BranchID> previousParentage_;
0147       ParentageID previousParentageId_;
0148 
0149       SharedResourcesAcquirer resourcesAcquirer_;
0150     };
0151 
0152   }  // namespace one
0153 }  // namespace edm
0154 
0155 #endif