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