CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
WorkerT.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_WorkerT_h
2 #define FWCore_Framework_WorkerT_h
3 
4 /*----------------------------------------------------------------------
5 
6 WorkerT: Code common to all workers.
7 
8 ----------------------------------------------------------------------*/
9 
14 
15 #include <memory>
16 
17 namespace edm {
18  UnscheduledHandler* getUnscheduledHandler(EventPrincipal const& ep);
19 
20  template<typename T>
21  class WorkerT : public Worker {
22  public:
23  typedef T ModuleType;
25  WorkerT(std::unique_ptr<T>&&,
26  ModuleDescription const&,
27  WorkerParams const&);
28 
29  virtual ~WorkerT();
30 
31  template<typename ModType>
32  static std::unique_ptr<T> makeModule(ModuleDescription const&,
33  ParameterSet const& pset) {
34  std::unique_ptr<ModType> module = std::unique_ptr<ModType>(new ModType(pset));
35  return std::unique_ptr<T>(module.release());
36  }
37 
38  void setModule( std::unique_ptr<T>&& iModule) {
39  module_ = std::move(iModule);
40  module_->setModuleDescription(description());
41 
42  }
43 
44  void setEventSelectionInfo(std::map<std::string, std::vector<std::pair<std::string, int> > > const& outputModulePathPositions,
45  bool anyProductProduced);
46 
47  virtual Types moduleType() const override;
48 
49  virtual void updateLookup(BranchType iBranchType,
50  ProductHolderIndexHelper const&) override;
51 
52 
53  protected:
54  T& module() {return *module_;}
55  T const& module() const {return *module_;}
56 
57  private:
58  virtual bool implDoBegin(EventPrincipal& ep, EventSetup const& c,
59  CurrentProcessingContext const* cpc) override;
60  virtual bool implDoEnd(EventPrincipal& ep, EventSetup const& c,
61  CurrentProcessingContext const* cpc) override;
62  virtual bool implDoBegin(RunPrincipal& rp, EventSetup const& c,
63  CurrentProcessingContext const* cpc) override;
64  virtual bool implDoEnd(RunPrincipal& rp, EventSetup const& c,
65  CurrentProcessingContext const* cpc) override;
66  virtual bool implDoBegin(LuminosityBlockPrincipal& lbp, EventSetup const& c,
67  CurrentProcessingContext const* cpc) override;
68  virtual bool implDoEnd(LuminosityBlockPrincipal& lbp, EventSetup const& c,
69  CurrentProcessingContext const* cpc) override;
70  virtual void implBeginJob() override;
71  virtual void implEndJob() override;
72  virtual void implRespondToOpenInputFile(FileBlock const& fb) override;
73  virtual void implRespondToCloseInputFile(FileBlock const& fb) override;
74  virtual void implRespondToOpenOutputFiles(FileBlock const& fb) override;
75  virtual void implRespondToCloseOutputFiles(FileBlock const& fb) override;
76  virtual void implPreForkReleaseResources() override;
77  virtual void implPostForkReacquireResources(unsigned int iChildIndex,
78  unsigned int iNumberOfChildren) override;
79  virtual std::string workerType() const override;
80 
81  std::unique_ptr<T> module_;
82  };
83 
84 }
85 
86 #endif
WorkerT(std::unique_ptr< T > &&, ModuleDescription const &, WorkerParams const &)
Definition: WorkerT.cc:19
std::unique_ptr< T > module_
Definition: WorkerT.h:81
ModuleDescription const & description() const
Definition: Worker.h:77
virtual Types moduleType() const override
virtual void implRespondToOpenOutputFiles(FileBlock const &fb) override
Definition: WorkerT.cc:117
virtual bool implDoEnd(EventPrincipal &ep, EventSetup const &c, CurrentProcessingContext const *cpc) override
Definition: WorkerT.cc:43
virtual void implEndJob() override
Definition: WorkerT.cc:96
static std::unique_ptr< T > makeModule(ModuleDescription const &, ParameterSet const &pset)
Definition: WorkerT.h:32
virtual std::string workerType() const override
Definition: WorkerT.cc:82
T & module()
Definition: WorkerT.h:54
T const & module() const
Definition: WorkerT.h:55
virtual void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &) override
Definition: WorkerT.cc:144
virtual ~WorkerT()
Definition: WorkerT.cc:28
BranchType
Definition: BranchType.h:11
dictionary map
Definition: Association.py:205
virtual void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:103
void setEventSelectionInfo(std::map< std::string, std::vector< std::pair< std::string, int > > > const &outputModulePathPositions, bool anyProductProduced)
Definition: WorkerT.cc:150
UnscheduledHandler * getUnscheduledHandler(EventPrincipal const &ep)
Definition: WorkerT.cc:12
T ModuleType
Definition: WorkerT.h:23
WorkerT< T > WorkerType
Definition: WorkerT.h:24
virtual bool implDoBegin(EventPrincipal &ep, EventSetup const &c, CurrentProcessingContext const *cpc) override
Definition: WorkerT.cc:34
virtual void implBeginJob() override
Definition: WorkerT.cc:89
virtual void implPreForkReleaseResources() override
Definition: WorkerT.cc:131
virtual void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:110
void setModule(std::unique_ptr< T > &&iModule)
Definition: WorkerT.h:38
virtual void implRespondToCloseOutputFiles(FileBlock const &fb) override
Definition: WorkerT.cc:124
long double T
Definition: vlib.h:209
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override
Definition: WorkerT.cc:138