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 implDoBegin(RunPrincipal& rp, EventSetup const& c,
82  ModuleCallingContext const* mcc) override;
83  virtual bool implDoStreamBegin(StreamID id, RunPrincipal& rp, EventSetup const& c,
84  ModuleCallingContext const* mcc) override;
85  virtual bool implDoStreamEnd(StreamID id, RunPrincipal& rp, EventSetup const& c,
86  ModuleCallingContext const* mcc) override;
87  virtual bool implDoEnd(RunPrincipal& rp, EventSetup const& c,
88  ModuleCallingContext const* mcc) override;
89  virtual bool implDoBegin(LuminosityBlockPrincipal& lbp, EventSetup const& c,
90  ModuleCallingContext const* mcc) override;
91  virtual bool implDoStreamBegin(StreamID id, LuminosityBlockPrincipal& lbp, EventSetup const& c,
92  ModuleCallingContext const* mcc) override;
93  virtual bool implDoStreamEnd(StreamID id, LuminosityBlockPrincipal& lbp, EventSetup const& c,
94  ModuleCallingContext const* mcc) override;
95  virtual bool implDoEnd(LuminosityBlockPrincipal& lbp, EventSetup const& c,
96  ModuleCallingContext const* mcc) override;
97  virtual void implBeginJob() override;
98  virtual void implEndJob() override;
99  virtual void implBeginStream(StreamID) override;
100  virtual void implEndStream(StreamID) override;
101  virtual void implRespondToOpenInputFile(FileBlock const& fb) override;
102  virtual void implRespondToCloseInputFile(FileBlock const& fb) override;
103  virtual void implPreForkReleaseResources() override;
104  virtual void implPostForkReacquireResources(unsigned int iChildIndex,
105  unsigned int iNumberOfChildren) override;
107  virtual std::string workerType() const override;
108 
109  virtual void modulesDependentUpon(std::vector<const char*>& oModuleLabels) const override {
110  module_->modulesDependentUpon(module_->moduleDescription().processName(),oModuleLabels);
111  }
112 
113  virtual void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
114  ProductRegistry const& preg,
115  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
116  module_->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, module_->moduleDescription().processName());
117  }
118 
119  virtual std::vector<ConsumesInfo> consumesInfo() const override {
120  return module_->consumesInfo();
121  }
122 
123  virtual void itemsToGet(BranchType branchType, std::vector<ProductHolderIndexAndSkipBit>& indexes) const override {
124  module_->itemsToGet(branchType, indexes);
125  }
126 
127  virtual void itemsMayGet(BranchType branchType, std::vector<ProductHolderIndexAndSkipBit>& indexes) const override {
128  module_->itemsMayGet(branchType, indexes);
129  }
130 
131  virtual std::vector<ProductHolderIndexAndSkipBit> const& itemsToGetFromEvent() const override { return module_->itemsToGetFromEvent(); }
132 
133  std::shared_ptr<T> module_;
134  };
135 
136 }
137 
138 #endif
virtual bool implDo(EventPrincipal &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:117
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:98
virtual std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:119
virtual Types moduleType() const override
virtual void implEndJob() override
Definition: WorkerT.cc:261
void callWorkerStreamEnd(D, StreamID id, RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:142
virtual std::string workerType() const override
Definition: WorkerT.cc:247
virtual std::vector< ProductHolderIndexAndSkipBit > const & itemsToGetFromEvent() const override
Definition: WorkerT.h:131
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:123
actions
Definition: Schedule.cc:370
virtual bool implDoBegin(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:125
virtual void updateLookup(BranchType iBranchType, ProductHolderIndexHelper const &) override
Definition: WorkerT.cc:336
virtual ~WorkerT()
Definition: WorkerT.cc:111
BranchType
Definition: BranchType.h:11
virtual void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:300
virtual void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc) const override
Definition: WorkerT.h:113
virtual bool implDoStreamBegin(StreamID id, RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:152
virtual void itemsMayGet(BranchType branchType, std::vector< ProductHolderIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:127
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:283
virtual void implBeginStream(StreamID) override
Definition: WorkerT.cc:274
UnscheduledHandler * getUnscheduledHandler(EventPrincipal const &ep)
Definition: WorkerT.cc:97
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:290
virtual void implBeginJob() override
Definition: WorkerT.cc:254
virtual void implPreForkReleaseResources() override
Definition: WorkerT.cc:314
virtual bool implDoStreamEnd(StreamID id, RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:164
std::shared_ptr< T > module_
Definition: WorkerT.h:133
virtual void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:307
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:267
virtual bool implDoEnd(RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:176
void callWorkerStreamBegin(D, StreamID id, RunPrincipal &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:133
virtual void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:330
virtual void modulesDependentUpon(std::vector< const char * > &oModuleLabels) const override
Definition: WorkerT.h:109
preg
Definition: Schedule.cc:370
long double T
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:104
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override
Definition: WorkerT.cc:321