CMS 3D CMS Logo

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 ProductResolverIndexAndSkipBit;
26  class ProductRegistry;
27  class ThinnedAssociationsHelper;
28 
29  template<typename T>
30  class WorkerT : public Worker {
31  public:
32  typedef T ModuleType;
34  WorkerT(std::shared_ptr<T>,
35  ModuleDescription const&,
37 
38  virtual ~WorkerT();
39 
40  void setModule( std::shared_ptr<T> iModule) {
41  module_ = iModule;
42  resetModuleDescription(&(module_->moduleDescription()));
43  }
44 
45  virtual Types moduleType() const override;
46 
47  virtual void updateLookup(BranchType iBranchType,
48  ProductResolverIndexHelper const&) override;
49  virtual void resolvePutIndicies(BranchType iBranchType,
50  std::unordered_multimap<std::string, edm::ProductResolverIndex> const& iIndicies) override;
51 
52  template<typename D>
54  template<typename D>
56  template<typename D>
57  void callWorkerStreamBegin(D, StreamID id, RunPrincipal const& rp,
58  EventSetup const& c,
59  ModuleCallingContext const* mcc);
60  template<typename D>
61  void callWorkerStreamEnd(D, StreamID id, RunPrincipal const& rp,
62  EventSetup const& c,
63  ModuleCallingContext const* mcc);
64  template<typename D>
66  EventSetup const& c,
67  ModuleCallingContext const* mcc);
68  template<typename D>
70  EventSetup const& c,
71  ModuleCallingContext const* mcc);
72 
73  protected:
74  T& module() {return *module_;}
75  T const& module() const {return *module_;}
76 
77  private:
78  virtual bool implDo(EventPrincipal const& ep, EventSetup const& c,
79  ModuleCallingContext const* mcc) override;
80  virtual bool implDoPrePrefetchSelection(StreamID id,
81  EventPrincipal const& ep,
82  ModuleCallingContext const* mcc) override;
83  virtual bool implDoBegin(RunPrincipal const& rp, EventSetup const& c,
84  ModuleCallingContext const* mcc) override;
85  virtual bool implDoStreamBegin(StreamID id, RunPrincipal const& rp, EventSetup const& c,
86  ModuleCallingContext const* mcc) override;
87  virtual bool implDoStreamEnd(StreamID id, RunPrincipal const& rp, EventSetup const& c,
88  ModuleCallingContext const* mcc) override;
89  virtual bool implDoEnd(RunPrincipal const& rp, EventSetup const& c,
90  ModuleCallingContext const* mcc) override;
91  virtual bool implDoBegin(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
92  ModuleCallingContext const* mcc) override;
93  virtual bool implDoStreamBegin(StreamID id, LuminosityBlockPrincipal const& lbp, EventSetup const& c,
94  ModuleCallingContext const* mcc) override;
95  virtual bool implDoStreamEnd(StreamID id, LuminosityBlockPrincipal const& lbp, EventSetup const& c,
96  ModuleCallingContext const* mcc) override;
97  virtual bool implDoEnd(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
98  ModuleCallingContext const* mcc) override;
99  virtual void implBeginJob() override;
100  virtual void implEndJob() override;
101  virtual void implBeginStream(StreamID) override;
102  virtual void implEndStream(StreamID) override;
103  virtual void implRespondToOpenInputFile(FileBlock const& fb) override;
104  virtual void implRespondToCloseInputFile(FileBlock const& fb) override;
105  virtual void implPreForkReleaseResources() override;
106  virtual void implPostForkReacquireResources(unsigned int iChildIndex,
107  unsigned int iNumberOfChildren) override;
109  virtual std::string workerType() const override;
110  virtual SerialTaskQueueChain* serializeRunModule() override;
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<ProductResolverIndexAndSkipBit>& indexes) const override {
124  module_->itemsToGet(branchType, indexes);
125  }
126 
127  virtual void itemsMayGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
128  module_->itemsMayGet(branchType, indexes);
129  }
130 
131  virtual std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType iType) const override final { return module_->itemsToGetFrom(iType); }
132 
133  virtual std::vector<ProductResolverIndex> const& itemsShouldPutInEvent() const override;
134 
135  virtual void preActionBeforeRunEventAsync(WaitingTask* iTask, ModuleCallingContext const& iModuleCallingContext, Principal const& iPrincipal) const override {
136  module_->preActionBeforeRunEventAsync(iTask,iModuleCallingContext,iPrincipal);
137  }
138 
139 
141  };
142 
143 }
144 
145 #endif
virtual bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:196
virtual std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:119
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:239
roAction_t actions[nactions]
Definition: GenABIO.cc:187
void callWorkerStreamEnd(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:174
virtual void implEndJob() override
Definition: WorkerT.cc:293
virtual std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const override final
Definition: WorkerT.h:131
virtual void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) override
Definition: WorkerT.cc:424
T & module()
Definition: WorkerT.h:74
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:40
virtual bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:184
T const & module() const
Definition: WorkerT.h:75
virtual bool implDo(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:113
virtual ~WorkerT()
Definition: WorkerT.cc:107
BranchType
Definition: BranchType.h:11
virtual void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:127
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:140
virtual void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:332
virtual bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:121
virtual SerialTaskQueueChain * serializeRunModule() override
Definition: WorkerT.cc:369
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:315
virtual void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:123
virtual void preActionBeforeRunEventAsync(WaitingTask *iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
Definition: WorkerT.h:135
virtual void implBeginStream(StreamID) override
Definition: WorkerT.cc:306
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
Definition: Types.py:1
void callWorkerStreamBegin(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:165
virtual bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:157
T ModuleType
Definition: WorkerT.h:32
WorkerT< T > WorkerType
Definition: WorkerT.h:33
virtual std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:486
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
virtual void implEndStream(StreamID) override
Definition: WorkerT.cc:322
virtual void implBeginJob() override
Definition: WorkerT.cc:286
virtual void implPreForkReleaseResources() override
Definition: WorkerT.cc:346
virtual void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:339
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:299
HLT enums.
virtual void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:362
virtual bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:208
long double T
virtual std::string workerType() const override
Definition: WorkerT.cc:279
virtual void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, edm::ProductResolverIndex > const &iIndicies) override
Definition: WorkerT.cc:478
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:100
def branchType(schema, name)
Definition: revisionDML.py:112
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override
Definition: WorkerT.cc:353
virtual Types moduleType() const override