Go to the documentation of this file.00001 #ifndef FWCore_Framework_WorkerT_h
00002 #define FWCore_Framework_WorkerT_h
00003
00004
00005
00006
00007
00008
00009
00010 #include "FWCore/Framework/interface/Frameworkfwd.h"
00011 #include "FWCore/Framework/interface/UnscheduledHandler.h"
00012 #include "FWCore/Framework/src/Worker.h"
00013 #include "FWCore/Framework/src/WorkerParams.h"
00014
00015 #include <memory>
00016
00017 namespace edm {
00018 UnscheduledHandler* getUnscheduledHandler(EventPrincipal const& ep);
00019
00020 template<typename T>
00021 class WorkerT : public Worker {
00022 public:
00023 typedef T ModuleType;
00024 typedef WorkerT<T> WorkerType;
00025 WorkerT(std::unique_ptr<T>&&,
00026 ModuleDescription const&,
00027 WorkerParams const&);
00028
00029 virtual ~WorkerT();
00030
00031 template<typename ModType>
00032 static std::unique_ptr<T> makeModule(ModuleDescription const&,
00033 ParameterSet const& pset) {
00034 std::unique_ptr<ModType> module = std::unique_ptr<ModType>(new ModType(pset));
00035 return std::unique_ptr<T>(module.release());
00036 }
00037
00038 void setModule( std::unique_ptr<T>&& iModule) {
00039 module_ = std::move(iModule);
00040 module_->setModuleDescription(description());
00041
00042 }
00043
00044 void setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
00045 bool anyProductProduced);
00046
00047 virtual Types moduleType() const override;
00048
00049 virtual void updateLookup(BranchType iBranchType,
00050 ProductHolderIndexHelper const&) override;
00051
00052
00053 protected:
00054 T& module() {return *module_;}
00055 T const& module() const {return *module_;}
00056
00057 private:
00058 virtual bool implDoBegin(EventPrincipal& ep, EventSetup const& c,
00059 CurrentProcessingContext const* cpc) override;
00060 virtual bool implDoEnd(EventPrincipal& ep, EventSetup const& c,
00061 CurrentProcessingContext const* cpc) override;
00062 virtual bool implDoBegin(RunPrincipal& rp, EventSetup const& c,
00063 CurrentProcessingContext const* cpc) override;
00064 virtual bool implDoEnd(RunPrincipal& rp, EventSetup const& c,
00065 CurrentProcessingContext const* cpc) override;
00066 virtual bool implDoBegin(LuminosityBlockPrincipal& lbp, EventSetup const& c,
00067 CurrentProcessingContext const* cpc) override;
00068 virtual bool implDoEnd(LuminosityBlockPrincipal& lbp, EventSetup const& c,
00069 CurrentProcessingContext const* cpc) override;
00070 virtual void implBeginJob() override;
00071 virtual void implEndJob() override;
00072 virtual void implRespondToOpenInputFile(FileBlock const& fb) override;
00073 virtual void implRespondToCloseInputFile(FileBlock const& fb) override;
00074 virtual void implRespondToOpenOutputFiles(FileBlock const& fb) override;
00075 virtual void implRespondToCloseOutputFiles(FileBlock const& fb) override;
00076 virtual void implPreForkReleaseResources() override;
00077 virtual void implPostForkReacquireResources(unsigned int iChildIndex,
00078 unsigned int iNumberOfChildren) override;
00079 virtual std::string workerType() const override;
00080
00081 std::unique_ptr<T> module_;
00082 };
00083
00084 }
00085
00086 #endif