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 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& itemsToGetFromEvent() const override { return module_->itemsToGetFromEvent(); }
132 
133  virtual std::vector<ProductResolverIndex> const& itemsShouldPutInEvent() const override;
134 
135 
137  };
138 
139 }
140 
141 #endif
virtual bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:196
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:225
void callWorkerStreamEnd(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:174
virtual std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:119
virtual Types moduleType() const override
virtual std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFromEvent() const override
Definition: WorkerT.h:131
virtual void implEndJob() override
Definition: WorkerT.cc:293
virtual std::string workerType() const override
Definition: WorkerT.cc:279
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 void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:127
actions
Definition: Schedule.cc:384
virtual ~WorkerT()
Definition: WorkerT.cc:107
BranchType
Definition: BranchType.h:11
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:136
virtual void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:332
virtual void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:123
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 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 implBeginStream(StreamID) override
Definition: WorkerT.cc:306
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
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
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
virtual void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:362
virtual std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:486
virtual bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:208
preg
Definition: Schedule.cc:384
long double T
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
virtual void implPostForkReacquireResources(unsigned int iChildIndex, unsigned int iNumberOfChildren) override
Definition: WorkerT.cc:353