odinreco/step.h
1 /***************************************************************************
2  step.h - description
3  -------------------
4  begin : Sat Dec 30 2006
5  copyright : (C) 2000-2015 by Thies Jochimsen
6  email : thies@jochimsen.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef RECOSTEP_H
19 #define RECOSTEP_H
20 
21 #include <odindata/step.h>
22 
23 #include <odinreco/odinreco.h>
24 #include <odinreco/index.h>
25 
32 class RecoData; // forward declaration
33 class RecoController; // forward declaration
34 
36 
41 
42 
49  enum queryMode {prep=0, finalize, print};
50  queryMode mode;
51 
56 
60  STD_string printprefix;
61 
65  STD_string printpostfix;
66 
71 
72  RecoQueryContext(queryMode m, RecoController& contr, unsigned short numof[n_recoDims]) : mode(m), controller(contr) {
73  for(int idim=0; idim<n_recoDims; idim++) coord.index[idim].set_numof(numof[idim]); // initializing numof in this branch
74  }
75 
76 };
77 
79 
80 
84 class RecoStep : public Step<RecoStep> {
85 
86  public:
87 
88  virtual ~RecoStep() {}
89 
98  virtual bool process(RecoData& rd, RecoController& controller) = 0;
99 
100 
104  virtual RecoCoord input_coord() const = 0;
105 
109  virtual void modify_coord(RecoCoord& coord) const = 0;
110 
111 
117  virtual bool pipeline_init(const RecoController& controller, const RecoCoord& input_coord) {return true;}
118 
119 
125  virtual bool query(RecoQueryContext& context);
126 
127 
131  void set_next_step(RecoStep* step) {next_step=step;}
132 
133 
134 
135  // To be used by factory via duck typing
136  static void create_templates(STD_list<RecoStep*>& result);
137  static STD_string manual_group() {return "odinreco_steps";}
138  static void interface_description(const RecoStep* step, STD_string& in, STD_string& out);
139 
140 
141 
142  protected:
143  friend class RecoController;
144 
148  RecoStep() : next_step(0) {}
149 
150 
151 
157  bool execute_next_step(RecoData& rd, RecoController& controller);
158 
159 
160  private:
161 
162  void interface_dims(int& in, int& out) const;
163 
164 
165  RecoStep* next_step;
166 
167 };
168 
169 
171 
172 
173 
174 typedef StepFactory<RecoStep> RecoStepFactory; // The factory for reco steps
175 
176 
177 
180 #endif
181 
RecoIndex & set_numof(unsigned short n)
Definition: index.h:114
void set_next_step(RecoStep *step)
virtual bool pipeline_init(const RecoController &controller, const RecoCoord &input_coord)
STD_string printprefix
Definition: odinreco/step.h:60
STD_string printpostfix
Definition: odinreco/step.h:65
RecoIndex index[n_recoDims]
Definition: index.h:269
RecoController & controller
Definition: odinreco/step.h:55