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 
16 
17 #include <map>
18 #include <memory>
19 #include <string>
20 #include <vector>
21 
22 namespace edm {
23 
24  class ModuleCallingContext;
25  class ModuleDescription;
26  class ProductHolderIndexAndSkipBit;
27  class ProductRegistry;
28  class ThinnedAssociationsHelper;
29 
30  UnscheduledHandler const* getUnscheduledHandler(EventPrincipal const& ep);
31 
32  template<typename T>
33  class WorkerT : public Worker {
34  public:
35  typedef T ModuleType;
37  WorkerT(std::shared_ptr<T>,
38  ModuleDescription const&,
40 
41  virtual ~WorkerT();
42 
43  void setModule( std::shared_ptr<T> iModule) {
44  module_ = iModule;
45  resetModuleDescription(&(module_->moduleDescription()));
46  }
47 
48  virtual Types moduleType() const override;
49 
50  virtual void updateLookup(BranchType iBranchType,
51  ProductHolderIndexHelper const&) override;
52 
53 
54  template<typename D>
56  template<typename D>
58  template<typename D>
59  void callWorkerStreamBegin(D, StreamID id, RunPrincipal const& rp,
60  EventSetup const& c,
61  ModuleCallingContext const* mcc);
62  template<typename D>
63  void callWorkerStreamEnd(D, StreamID id, RunPrincipal const& rp,
64  EventSetup const& c,
65  ModuleCallingContext const* mcc);
66  template<typename D>
68  EventSetup const& c,
69  ModuleCallingContext const* mcc);
70  template<typename D>
72  EventSetup const& c,
73  ModuleCallingContext const* mcc);
74 
75  protected:
76  T& module() {return *module_;}
77  T const& module() const {return *module_;}
78 
79  private:
80  virtual bool implDo(EventPrincipal const& ep, EventSetup const& c,
81  ModuleCallingContext const* mcc) override;
82  virtual bool implDoPrePrefetchSelection(StreamID id,
83  EventPrincipal const& ep,
84  ModuleCallingContext const* mcc) override;
85  virtual bool implDoBegin(RunPrincipal const& rp, EventSetup const& c,
86  ModuleCallingContext const* mcc) override;
87  virtual bool implDoStreamBegin(StreamID id, RunPrincipal const& rp, EventSetup const& c,
88  ModuleCallingContext const* mcc) override;
89  virtual bool implDoStreamEnd(StreamID id, RunPrincipal const& rp, EventSetup const& c,
90  ModuleCallingContext const* mcc) override;
91  virtual bool implDoEnd(RunPrincipal const& rp, EventSetup const& c,
92  ModuleCallingContext const* mcc) override;
93  virtual bool implDoBegin(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
94  ModuleCallingContext const* mcc) override;
95  virtual bool implDoStreamBegin(StreamID id, LuminosityBlockPrincipal const& lbp, EventSetup const& c,
96  ModuleCallingContext const* mcc) override;
97  virtual bool implDoStreamEnd(StreamID id, LuminosityBlockPrincipal const& lbp, EventSetup const& c,
98  ModuleCallingContext const* mcc) override;
99  virtual bool implDoEnd(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
100  ModuleCallingContext const* mcc) override;
101  virtual void implBeginJob() override;
102  virtual void implEndJob() override;
103  virtual void implBeginStream(StreamID) override;
104  virtual void implEndStream(StreamID) override;
105  virtual void implRespondToOpenInputFile(FileBlock const& fb) override;
106  virtual void implRespondToCloseInputFile(FileBlock const& fb) override;
107  virtual void implPreForkReleaseResources() override;
108  virtual void implPostForkReacquireResources(unsigned int iChildIndex,
109  unsigned int iNumberOfChildren) override;
111  virtual std::string workerType() const override;
112 
113  virtual void modulesDependentUpon(std::vector<const char*>& oModuleLabels, bool iPrint) const override {
114  module_->modulesDependentUpon(module_->moduleDescription().processName(),module_->moduleDescription().moduleLabel(), iPrint, oModuleLabels);
115  }
116 
117  virtual void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
118  ProductRegistry const& preg,
119  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
120  module_->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, module_->moduleDescription().processName());
121  }
122 
123  virtual std::vector<ConsumesInfo> consumesInfo() const override {
124  return module_->consumesInfo();
125  }
126 
127  virtual void itemsToGet(BranchType branchType, std::vector<ProductHolderIndexAndSkipBit>& indexes) const override {
128  module_->itemsToGet(branchType, indexes);
129  }
130 
131  virtual void itemsMayGet(BranchType branchType, std::vector<ProductHolderIndexAndSkipBit>& indexes) const override {
132  module_->itemsMayGet(branchType, indexes);
133  }
134 
135  virtual std::vector<ProductHolderIndexAndSkipBit> const& itemsToGetFromEvent() const override { return module_->itemsToGetFromEvent(); }
136 
138  };
139 
140 }
141 
142 #endif
virtual bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:201
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:98
void callWorkerStreamEnd(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:179
virtual std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:123
virtual Types moduleType() const override
virtual void implEndJob() override
Definition: WorkerT.cc:298
virtual std::string workerType() const override
Definition: WorkerT.cc:284
virtual std::vector< ProductHolderIndexAndSkipBit > const & itemsToGetFromEvent() const override
Definition: WorkerT.h:135
T & module()
Definition: WorkerT.h:76
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:43
virtual bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:189
T const & module() const
Definition: WorkerT.h:77
virtual bool implDo(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:118
virtual void itemsToGet(BranchType branchType, std::vector< ProductHolderIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:127
actions
Definition: Schedule.cc:374
virtual void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &) override
Definition: WorkerT.cc:373
virtual ~WorkerT()
Definition: WorkerT.cc:112
BranchType
Definition: BranchType.h:11
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:137
virtual void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:337
virtual void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc) const override
Definition: WorkerT.h:117
virtual bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:126
virtual void itemsMayGet(BranchType branchType, std::vector< ProductHolderIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:131
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:320
virtual void implBeginStream(StreamID) override
Definition: WorkerT.cc:311
void callWorkerStreamBegin(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:170
virtual bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:162
UnscheduledHandler const * getUnscheduledHandler(EventPrincipal const &ep)
Definition: WorkerT.cc:98
T ModuleType
Definition: WorkerT.h:35
WorkerT< T > WorkerType
Definition: WorkerT.h:36
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
virtual void implEndStream(StreamID) override
Definition: WorkerT.cc:327
virtual void implBeginJob() override
Definition: WorkerT.cc:291
virtual void modulesDependentUpon(std::vector< const char * > &oModuleLabels, bool iPrint) const override
Definition: WorkerT.h:113
virtual void implPreForkReleaseResources() override
Definition: WorkerT.cc:351
virtual void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:344
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:304
virtual void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:367
virtual bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:213
preg
Definition: Schedule.cc:374
long double T
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:105
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override
Definition: WorkerT.cc:358