WorkerT.h
Go to the documentation of this file.
1 #ifndef art_Framework_Core_WorkerT_h
2 #define art_Framework_Core_WorkerT_h
3 
4 /*----------------------------------------------------------------------
5 
6 WorkerT: Code common to all workers.
7 
8 ----------------------------------------------------------------------*/
9 
14 #include "fhiclcpp/ParameterSet.h"
15 
16 #include <iosfwd>
17 #include <memory>
18 
19 namespace art {
20 
21  template <typename T>
22  class WorkerT : public Worker {
23  public:
24  using ModuleType = T;
26 
27  WorkerT(std::unique_ptr<T>&&,
28  ModuleDescription const&,
29  WorkerParams const&);
30 
31  bool
32  modifiesEvent() const override
33  {
34  return module_->modifiesEvent();
35  }
36 
37  protected:
38  T&
40  {
41  return *module_;
42  }
43  T const&
44  module() const
45  {
46  return *module_;
47  }
48 
49  private:
51  CurrentProcessingContext const* cpc,
52  CountingStatistics&) override;
53  bool implDoBegin(RunPrincipal& rp,
54  CurrentProcessingContext const* cpc) override;
55  bool implDoEnd(RunPrincipal& rp,
56  CurrentProcessingContext const* cpc) override;
57  bool implDoBegin(SubRunPrincipal& srp,
58  CurrentProcessingContext const* cpc) override;
59  bool implDoEnd(SubRunPrincipal& srp,
60  CurrentProcessingContext const* cpc) override;
61  void implBeginJob() override;
62  void implEndJob() override;
63  void implRespondToOpenInputFile(FileBlock const& fb) override;
64  void implRespondToCloseInputFile(FileBlock const& fb) override;
65  void implRespondToOpenOutputFiles(FileBlock const& fb) override;
66  void implRespondToCloseOutputFiles(FileBlock const& fb) override;
67  std::string workerType() const override;
68 
69  std::unique_ptr<T> module_;
70  };
71 
72  template <typename T>
73  inline WorkerT<T>::WorkerT(std::unique_ptr<T>&& module,
74  ModuleDescription const& md,
75  WorkerParams const& wp)
76  : Worker{md, wp}, module_{std::move(module)}
77  {
78  module_->setModuleDescription(md);
79  module_->registerProducts(wp.reg_, wp.producedProducts_, md);
80  }
81 
82  template <typename T>
83  bool
85  CurrentProcessingContext const* cpc,
87  {
88  return module_->doEvent(ep, cpc, stats);
89  }
90 
91  template <typename T>
92  bool
94  {
95  return module_->doBeginRun(rp, cpc);
96  }
97 
98  template <typename T>
99  bool
101  {
102  return module_->doEndRun(rp, cpc);
103  }
104 
105  template <typename T>
106  bool
108  CurrentProcessingContext const* cpc)
109  {
110  return module_->doBeginSubRun(srp, cpc);
111  }
112 
113  template <typename T>
114  bool
116  CurrentProcessingContext const* cpc)
117  {
118  return module_->doEndSubRun(srp, cpc);
119  }
120 
121  template <typename T>
124  {
125  return module_->workerType();
126  }
127 
128  template <typename T>
129  void
131  {
132  module_->doBeginJob();
133  }
134 
135  template <typename T>
136  void
138  {
139  module_->doEndJob();
140  }
141 
142  template <typename T>
143  void
145  {
146  module_->doRespondToOpenInputFile(fb);
147  }
148 
149  template <typename T>
150  void
152  {
153  module_->doRespondToCloseInputFile(fb);
154  }
155 
156  template <typename T>
157  void
159  {
160  module_->doRespondToOpenOutputFiles(fb);
161  }
162 
163  template <typename T>
164  void
166  {
167  module_->doRespondToCloseOutputFiles(fb);
168  }
169 }
170 
171 #endif /* art_Framework_Core_WorkerT_h */
172 
173 // Local Variables:
174 // mode: c++
175 // End:
int stats(TString inputFilePath, Int_t firstRun, Int_t lastRun, Float_t thresh, TString myDet)
Definition: stats.C:13
bool modifiesEvent() const override
Definition: WorkerT.h:32
std::string workerType() const override
Definition: WorkerT.h:123
void implRespondToOpenInputFile(FileBlock const &fb) override
Definition: WorkerT.h:144
T const & module() const
Definition: WorkerT.h:44
bool implDoProcess(EventPrincipal &ep, CurrentProcessingContext const *cpc, CountingStatistics &) override
Definition: WorkerT.h:84
bool implDoEnd(RunPrincipal &rp, CurrentProcessingContext const *cpc) override
Definition: WorkerT.h:100
WorkerT(std::unique_ptr< T > &&, ModuleDescription const &, WorkerParams const &)
Definition: WorkerT.h:73
T & module()
Definition: WorkerT.h:39
void implEndJob() override
Definition: WorkerT.h:137
void implRespondToOpenOutputFiles(FileBlock const &fb) override
Definition: WorkerT.h:158
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
void implRespondToCloseOutputFiles(FileBlock const &fb) override
Definition: WorkerT.h:165
std::unique_ptr< T > module_
Definition: WorkerT.h:69
double T
Definition: Xdiff_gwt.C:5
void implRespondToCloseInputFile(FileBlock const &fb) override
Definition: WorkerT.h:151
void implBeginJob() override
Definition: WorkerT.h:130
bool implDoBegin(RunPrincipal &rp, CurrentProcessingContext const *cpc) override
Definition: WorkerT.h:93
enum BeamMode string