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 
17 
18 #include <map>
19 #include <memory>
20 #include <string>
21 #include <vector>
22 
23 namespace edm {
24 
25  class ModuleCallingContext;
26  class ModuleProcessName;
27  class ProductResolverIndexAndSkipBit;
28  class ThinnedAssociationsHelper;
29  class WaitingTaskWithArenaHolder;
30 
31  template <typename T>
32  class WorkerT : public Worker {
33  public:
34  typedef T ModuleType;
36  WorkerT(std::shared_ptr<T>, ModuleDescription const&, ExceptionToActionTable const* actions);
37 
38  ~WorkerT() override;
39 
40  void setModule(std::shared_ptr<T> iModule) {
41  module_ = iModule;
42  resetModuleDescription(&(module_->moduleDescription()));
43  }
44 
45  Types moduleType() const override;
46  ConcurrencyTypes moduleConcurrencyType() const override;
47 
48  bool wantsProcessBlocks() const final;
49  bool wantsInputProcessBlocks() const final;
50  bool wantsGlobalRuns() const final;
52  bool wantsStreamRuns() const final;
54 
57 
58  void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const&) final;
59  void updateLookup(eventsetup::ESRecordsToProxyIndices const&) final;
61 
62  void resolvePutIndicies(
63  BranchType iBranchType,
64  std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, edm::ProductResolverIndex>> const&
65  iIndicies) final;
66 
67  template <typename D>
69  template <typename D>
71  template <typename D>
73  template <typename D>
75  template <typename D>
77  template <typename D>
79 
80  protected:
81  T& module() { return *module_; }
82  T const& module() const { return *module_; }
83 
84  private:
85  void doClearModule() override { get_underlying_safe(module_).reset(); }
86 
87  bool implDo(EventTransitionInfo const&, ModuleCallingContext const*) override;
88 
89  void itemsToGetForSelection(std::vector<ProductResolverIndexAndSkipBit>&) const final;
90  bool implNeedToRunSelection() const final;
91 
93 
106  void implBeginJob() override;
107  void implEndJob() override;
108  void implBeginStream(StreamID) override;
109  void implEndStream(StreamID) override;
110  void implRespondToOpenInputFile(FileBlock const& fb) override;
111  void implRespondToCloseInputFile(FileBlock const& fb) override;
112  void implRespondToCloseOutputFile() override;
114  std::string workerType() const override;
115  TaskQueueAdaptor serializeRunModule() override;
116 
119  std::vector<ModuleProcessName>& modulesInPreviousProcesses,
120  ProductRegistry const& preg,
121  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
122  module_->modulesWhoseProductsAreConsumed(
123  modules, modulesInPreviousProcesses, preg, labelsToDesc, module_->moduleDescription().processName());
124  }
125 
127  module_->convertCurrentProcessAlias(processName);
128  }
129 
130  std::vector<ConsumesInfo> consumesInfo() const override { return module_->consumesInfo(); }
131 
132  void itemsToGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
133  module_->itemsToGet(branchType, indexes);
134  }
135 
136  void itemsMayGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
137  module_->itemsMayGet(branchType, indexes);
138  }
139 
140  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType iType) const final {
141  return module_->itemsToGetFrom(iType);
142  }
143 
144  std::vector<ESProxyIndex> const& esItemsToGetFrom(Transition iTransition) const override {
145  return module_->esGetTokenIndicesVector(iTransition);
146  }
147  std::vector<ESRecordIndex> const& esRecordsToGetFrom(Transition iTransition) const override {
148  return module_->esGetTokenRecordIndicesVector(iTransition);
149  }
150 
151  std::vector<ProductResolverIndex> const& itemsShouldPutInEvent() const override;
152 
154  ModuleCallingContext const& iModuleCallingContext,
155  Principal const& iPrincipal) const override {
156  module_->preActionBeforeRunEventAsync(iTask, iModuleCallingContext, iPrincipal);
157  }
158 
159  bool hasAcquire() const override { return module_->hasAcquire(); }
160 
161  bool hasAccumulator() const override { return module_->hasAccumulator(); }
162 
164  };
165 
166 } // namespace edm
167 
168 #endif
T const & module() const
Definition: WorkerT.h:82
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) final
Definition: WorkerT.cc:654
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:132
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:239
bool hasAcquire() const override
Definition: WorkerT.h:159
bool hasAccumulator() const override
Definition: WorkerT.h:161
bool implDoEndProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:347
SerialTaskQueue * globalRunsQueue() final
Definition: WorkerT.cc:159
roAction_t actions[nactions]
Definition: GenABIO.cc:181
unsigned int ProductResolverIndex
SerialTaskQueue * globalLuminosityBlocksQueue() final
Definition: WorkerT.cc:163
void convertCurrentProcessAlias(std::string const &processName) override
Definition: WorkerT.h:126
void implEndJob() override
Definition: WorkerT.cc:464
std::string workerType() const override
Definition: WorkerT.cc:454
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:130
void callWorkerStreamEnd(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:369
bool wantsStreamLuminosityBlocks() const final
Definition: WorkerT.cc:154
T & module()
Definition: WorkerT.h:81
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:40
std::vector< ESRecordIndex > const & esRecordsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:147
bool implNeedToRunSelection() const final
Definition: WorkerT.cc:272
bool implDoStreamEnd(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:386
constexpr std::shared_ptr< T > & get_underlying_safe(propagate_const< std::shared_ptr< T >> &iP)
bool implDoPrePrefetchSelection(StreamID, EventPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:277
bool implDoAccessInputProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:341
BranchType
Definition: BranchType.h:11
void callWorkerStreamBegin(D, StreamID, RunTransitionInfo const &, ModuleCallingContext const *)
Definition: WorkerT.cc:360
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:163
void itemsToGetForSelection(std::vector< ProductResolverIndexAndSkipBit > &) const final
Definition: WorkerT.cc:283
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:501
void implRespondToCloseOutputFile() override
Definition: WorkerT.cc:511
std::vector< ESProxyIndex > const & esItemsToGetFrom(Transition iTransition) const override
Definition: WorkerT.h:144
Types moduleType() const override
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:486
std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:726
void implBeginStream(StreamID) override
Definition: WorkerT.cc:475
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) final
Definition: WorkerT.cc:718
bool implDoStreamBegin(StreamID, RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:374
Transition
Definition: Transition.h:12
def template(fileName, svg, replaceme="REPLACEME")
Definition: svgfig.py:521
bool wantsInputProcessBlocks() const final
Definition: WorkerT.cc:134
Definition: Types.py:1
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:522
bool wantsGlobalLuminosityBlocks() const final
Definition: WorkerT.cc:144
ConcurrencyTypes
Definition: Worker.h:95
~WorkerT() override
Definition: WorkerT.cc:126
T ModuleType
Definition: WorkerT.h:34
WorkerT< T > WorkerType
Definition: WorkerT.h:35
bool implDoBeginProcessBlock(ProcessBlockPrincipal const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:335
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:141
void implEndStream(StreamID) override
Definition: WorkerT.cc:491
void implBeginJob() override
Definition: WorkerT.cc:459
bool wantsProcessBlocks() const final
Definition: WorkerT.cc:129
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:506
bool implDoEnd(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:396
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:470
void implDoAcquire(EventTransitionInfo const &, ModuleCallingContext const *, WaitingTaskWithArenaHolder &) final
Definition: WorkerT.cc:232
void doClearModule() override
Definition: WorkerT.h:85
HLT enums.
bool wantsGlobalRuns() const final
Definition: WorkerT.cc:139
bool wantsStreamRuns() const final
Definition: WorkerT.cc:149
void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:136
void preActionBeforeRunEventAsync(WaitingTaskHolder iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
Definition: WorkerT.h:153
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:516
bool implDoBegin(RunTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:353
void modulesWhoseProductsAreConsumed(std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modules, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc) const override
Definition: WorkerT.h:117
long double T
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:120
void selectInputProcessBlocks(ProductRegistry const &, ProcessBlockHelperBase const &) final
Definition: WorkerT.cc:664
ConcurrencyTypes moduleConcurrencyType() const override
bool implDo(EventTransitionInfo const &, ModuleCallingContext const *) override
Definition: WorkerT.cc:225
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const final
Definition: WorkerT.h:140