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  ~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 
47  void updateLookup(BranchType iBranchType,
48  ProductResolverIndexHelper const&) override;
49  void resolvePutIndicies(BranchType iBranchType,
50  std::unordered_multimap<std::string, std::tuple<TypeID const*, const char*, 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  bool implDo(EventPrincipal const& ep, EventSetup const& c,
79  ModuleCallingContext const* mcc) override;
81  EventPrincipal const& ep,
82  ModuleCallingContext const* mcc) override;
83  bool implDoBegin(RunPrincipal const& rp, EventSetup const& c,
84  ModuleCallingContext const* mcc) override;
85  bool implDoStreamBegin(StreamID id, RunPrincipal const& rp, EventSetup const& c,
86  ModuleCallingContext const* mcc) override;
87  bool implDoStreamEnd(StreamID id, RunPrincipal const& rp, EventSetup const& c,
88  ModuleCallingContext const* mcc) override;
89  bool implDoEnd(RunPrincipal const& rp, EventSetup const& c,
90  ModuleCallingContext const* mcc) override;
91  bool implDoBegin(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
92  ModuleCallingContext const* mcc) override;
93  bool implDoStreamBegin(StreamID id, LuminosityBlockPrincipal const& lbp, EventSetup const& c,
94  ModuleCallingContext const* mcc) override;
95  bool implDoStreamEnd(StreamID id, LuminosityBlockPrincipal const& lbp, EventSetup const& c,
96  ModuleCallingContext const* mcc) override;
97  bool implDoEnd(LuminosityBlockPrincipal const& lbp, EventSetup const& c,
98  ModuleCallingContext const* mcc) override;
99  void implBeginJob() override;
100  void implEndJob() override;
101  void implBeginStream(StreamID) override;
102  void implEndStream(StreamID) override;
103  void implRespondToOpenInputFile(FileBlock const& fb) override;
104  void implRespondToCloseInputFile(FileBlock const& fb) override;
106  std::string workerType() const override;
108 
109 
110  void modulesWhoseProductsAreConsumed(std::vector<ModuleDescription const*>& modules,
111  ProductRegistry const& preg,
112  std::map<std::string, ModuleDescription const*> const& labelsToDesc) const override {
113  module_->modulesWhoseProductsAreConsumed(modules, preg, labelsToDesc, module_->moduleDescription().processName());
114  }
115 
117  module_->convertCurrentProcessAlias(processName);
118  }
119 
120  std::vector<ConsumesInfo> consumesInfo() const override {
121  return module_->consumesInfo();
122  }
123 
124  void itemsToGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
125  module_->itemsToGet(branchType, indexes);
126  }
127 
128  void itemsMayGet(BranchType branchType, std::vector<ProductResolverIndexAndSkipBit>& indexes) const override {
129  module_->itemsMayGet(branchType, indexes);
130  }
131 
132  std::vector<ProductResolverIndexAndSkipBit> const& itemsToGetFrom(BranchType iType) const final { return module_->itemsToGetFrom(iType); }
133 
134  std::vector<ProductResolverIndex> const& itemsShouldPutInEvent() const override;
135 
136  void preActionBeforeRunEventAsync(WaitingTask* iTask, ModuleCallingContext const& iModuleCallingContext, Principal const& iPrincipal) const override {
137  module_->preActionBeforeRunEventAsync(iTask,iModuleCallingContext,iPrincipal);
138  }
139 
140 
142  };
143 
144 }
145 
146 #endif
bool implDoStreamEnd(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:225
void resetModuleDescription(ModuleDescription const *)
Definition: Worker.cc:239
std::vector< ConsumesInfo > consumesInfo() const override
Definition: WorkerT.h:120
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:203
void convertCurrentProcessAlias(std::string const &processName) override
Definition: WorkerT.h:116
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom(BranchType iType) const final
Definition: WorkerT.h:132
void implEndJob() override
Definition: WorkerT.cc:322
void updateLookup(BranchType iBranchType, ProductResolverIndexHelper const &) override
Definition: WorkerT.cc:454
void itemsMayGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:128
T & module()
Definition: WorkerT.h:74
void setModule(std::shared_ptr< T > iModule)
Definition: WorkerT.h:40
bool implDoStreamBegin(StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:213
T const & module() const
Definition: WorkerT.h:75
bool implDo(EventPrincipal const &ep, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:133
BranchType
Definition: BranchType.h:11
Types moduleType() const override
edm::propagate_const< std::shared_ptr< T > > module_
Definition: WorkerT.h:141
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:361
bool implDoPrePrefetchSelection(StreamID id, EventPrincipal const &ep, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:141
void preActionBeforeRunEventAsync(WaitingTask *iTask, ModuleCallingContext const &iModuleCallingContext, Principal const &iPrincipal) const override
Definition: WorkerT.h:136
void callWorkerEndStream(D, StreamID)
Definition: WorkerT.cc:344
void implBeginStream(StreamID) override
Definition: WorkerT.cc:335
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:110
TaskQueueAdaptor serializeRunModule() override
Definition: WorkerT.cc:382
void resolvePutIndicies(BranchType iBranchType, std::unordered_multimap< std::string, std::tuple< TypeID const *, const char *, edm::ProductResolverIndex >> const &iIndicies) override
Definition: WorkerT.cc:510
void callWorkerStreamBegin(D, StreamID id, RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc)
Definition: WorkerT.cc:194
bool implDoBegin(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:186
~WorkerT() override
Definition: WorkerT.cc:127
T ModuleType
Definition: WorkerT.h:32
WorkerT< T > WorkerType
Definition: WorkerT.h:33
std::vector< ProductResolverIndex > const & itemsShouldPutInEvent() const override
Definition: WorkerT.cc:519
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
void implEndStream(StreamID) override
Definition: WorkerT.cc:351
void implBeginJob() override
Definition: WorkerT.cc:315
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.cc:368
void callWorkerBeginStream(D, StreamID)
Definition: WorkerT.cc:328
HLT enums.
void implRegisterThinnedAssociations(ProductRegistry const &, ThinnedAssociationsHelper &) override
Definition: WorkerT.cc:375
bool implDoEnd(RunPrincipal const &rp, EventSetup const &c, ModuleCallingContext const *mcc) override
Definition: WorkerT.cc:237
long double T
std::string workerType() const override
Definition: WorkerT.cc:308
WorkerT(std::shared_ptr< T >, ModuleDescription const &, ExceptionToActionTable const *actions)
Definition: WorkerT.cc:120
void itemsToGet(BranchType branchType, std::vector< ProductResolverIndexAndSkipBit > &indexes) const override
Definition: WorkerT.h:124
def branchType(schema, name)
Definition: revisionDML.py:112