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  class WaitingTaskWithArenaHolder;
29 
30  template <typename T>
31  class WorkerT : public Worker {
32  public:
33  typedef T ModuleType;
35  WorkerT(std::shared_ptr<T>, ModuleDescription const&, ExceptionToActionTable const* actions);
36 
37  ~WorkerT() override;
38 
39  void setModule(std::shared_ptr<T> iModule) {
40  module_ = iModule;
41  resetModuleDescription(&(module_->moduleDescription()));
42  }
43 
44  Types moduleType() const override;
45 
46  bool wantsGlobalRuns() const final;
47  bool wantsGlobalLuminosityBlocks() const final;
48  bool wantsStreamRuns() const final;
49  bool wantsStreamLuminosityBlocks() const final;
50 
53 
54  void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) final;
56  void resolvePutIndicies(
57  BranchType iBranchType,
58  std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
59  iIndicies) final;
60 
61  template <typename D>
63  template <typename D>
65  template <typename D>
67  D, StreamID id, RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
68  template <typename D>
70  D, StreamID id, RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
71  template <typename D>
73  D, StreamID id, LuminosityBlockPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
74  template <typename D>
76  D, StreamID id, LuminosityBlockPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc);
77 
78  protected:
79  T& module() { return *module_; }
80  T const& module() const { return *module_; }
81 
82  private:
83  bool implDo(EventPrincipal const& ep, EventSetupImpl const& c, ModuleCallingContext const* mcc) override;
84 
85  void itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>&) const final;
86  bool implNeedToRunSelection() const final;
87 
88  void implDoAcquire(EventPrincipal const& ep,
89  EventSetupImpl const& c,
90  ModuleCallingContext const* mcc,
91  WaitingTaskWithArenaHolder& holder) final;
92 
93  bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const& ep, ModuleCallingContext const* mcc) override;
94  bool implDoBegin(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc) override;
96  RunPrincipal const& rp,
97  EventSetupImpl const& c,
98  ModuleCallingContext const* mcc) override;
99  bool implDoStreamEnd(StreamID id,
100  RunPrincipal const& rp,
101  EventSetupImpl const& c,
102  ModuleCallingContext const* mcc) override;
103  bool implDoEnd(RunPrincipal const& rp, EventSetupImpl const& c, ModuleCallingContext const* mcc) override;
104  bool implDoBegin(LuminosityBlockPrincipal const& lbp,
105  EventSetupImpl const& c,
106  ModuleCallingContext const* mcc) override;
107  bool implDoStreamBegin(StreamID id,
108  LuminosityBlockPrincipal const& lbp,
109  EventSetupImpl const& c,
110  ModuleCallingContext const* mcc) override;
111  bool implDoStreamEnd(StreamID id,
112  LuminosityBlockPrincipal const& lbp,
113  EventSetupImpl const& c,
114  ModuleCallingContext const* mcc) override;
115  bool implDoEnd(LuminosityBlockPrincipal const& lbp,
116  EventSetupImpl const& c,
117  ModuleCallingContext const* mcc) override;
118  void implBeginJob() override;
119  void implEndJob() override;
120  void implBeginStream(StreamID) override;
121  void implEndStream(StreamID) override;
122  void implRespondToOpenInputFile(FileBlock const& fb) override;
123  void implRespondToCloseInputFile(FileBlock const& fb) override;
125  std::string workerType() const override;
127 
129  std::vector<ModuleDescription const*>& modules,
130  ProductRegistry const& preg,
131  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
132  module_->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, module_->moduleDescription().processName());
133  }
134 
136  module_->convertCurrentProcessAlias(processName);
137  }
138 
139  std::vector<ConsumesInfo> consumesInfo() const override { return module_->consumesInfo(); }
140 
141  void itemsToGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
142  module_->itemsToGet(branchType, indexes);
143  }
144 
145  void itemsMayGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
146  module_->itemsMayGet(branchType, indexes);
147  }
148 
149  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType iType) const final {
150  return module_->itemsToGetFrom(iType);
151  }
152 
153  std::vector<ProductResolverIndex> const& itemsShouldPutInEvent() const override;
154 
156  ModuleCallingContext const& iModuleCallingContext,
157  Principal const& iPrincipal) const override {
158  module_->preActionBeforeRunEventAsync(iTask, iModuleCallingContext, iPrincipal);
159  }
160 
161  bool hasAcquire() const override { return module_->hasAcquire(); }
162 
163  bool hasAccumulator() const override { return module_->hasAccumulator(); }
164 
166  };
167 
168 } // namespace edm
169 
170 #endif
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) final
Definition: WorkerT.cc:646
bool hasAccumulator() const override
Definition: WorkerT.h:163
bool wantsStreamLuminosityBlocks() const final
Definition: WorkerT.cc:137
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:276
bool implDoEnd(RunPrincipal const &rp, EventSetupImpl const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:386
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:139
SerialTaskQueue * globalRunsQueue() final
Definition: WorkerT.cc:142
roAction_t actions[nactions]
Definition: GenABIO.cc:181
bool implDoBegin(RunPrincipal const &rp, EventSetupImpl const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:338
SerialTaskQueue * globalLuminosityBlocksQueue() final
Definition: WorkerT.cc:146
void convertCurrentProcessAlias(std::string const &processName) override
Definition: WorkerT.h:135
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const final
Definition: WorkerT.h:149
void implEndJob() override
Definition: WorkerT.cc:459
bool wantsGlobalRuns() const final
Definition: WorkerT.cc:122
bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetupImpl const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:373
void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:145
T & module()
Definition: WorkerT.h:79
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:39
T const & module() const
Definition: WorkerT.h:80
BranchType
Definition: BranchType.h:11
Types moduleType() const override
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:165
void callWorkerStreamBegin(D, StreamID id, RunPrincipal const &rp, EventSetupImpl const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:347
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:490
bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetupImpl const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:360
void callWorkerStreamEnd(D, StreamID id, RunPrincipal const &rp, EventSetupImpl const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:354
bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:265
void preActionBeforeRunEventAsync(WaitingTask *iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
Definition: WorkerT.h:155
bool wantsGlobalLuminosityBlocks() const final
Definition: WorkerT.cc:127
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:478
bool hasAcquire() const override
Definition: WorkerT.h:161
void implBeginStream(StreamID) override
Definition: WorkerT.cc:470
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) final
Definition: WorkerT.cc:704
Definition: Types.py:1
void modulesWhoseProductsAreConsumed(std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc) const override
Definition: WorkerT.h:128
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:506
~WorkerT() override
Definition: WorkerT.cc:119
T ModuleType
Definition: WorkerT.h:33
WorkerT< T > WorkerType
Definition: WorkerT.h:34
std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:712
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:152
bool implNeedToRunSelection() const final
Definition: WorkerT.cc:260
void implDoAcquire(EventPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *mcc, WaitingTaskWithArenaHolder &holder) final
Definition: WorkerT.cc:222
void implEndStream(StreamID) override
Definition: WorkerT.cc:483
void implBeginJob() override
Definition: WorkerT.cc:454
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:495
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:465
HLT enums.
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:271
bool implDo(EventPrincipal const &ep, EventSetupImpl const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:216
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:500
bool wantsStreamRuns() const final
Definition: WorkerT.cc:132
long double T
std::string workerType() const override
Definition: WorkerT.cc:449
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:113
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:141
def branchType(schema, name)
Definition: revisionDML.py:114