seqtree.h
1 /***************************************************************************
2  seqtree.h - description
3  -------------------
4  begin : Fri Oct 17 2003
5  copyright : (C) 2000-2015 by Thies H. 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 
19 
20 #ifndef SEQTREE_H
21 #define SEQTREE_H
22 
23 #include <tjutils/tjvallist.h>
24 
25 #include <odinseq/seqclass.h>
26 #include <odinseq/seqoperator.h>
27 
28 
29 
35 
41 
42  public:
43  virtual void display_node(const SeqClass* thisnode, const SeqClass* parentnode, int treelevel, const svector& columntext) = 0;
44 
45 };
46 
48 
49 class ProgressMeter; // forward declaration
50 
57 enum eventAction {seqRun=0, printEvent, countEvents};
58 
62 struct eventContext {
63  eventContext() : action(seqRun), abort(false), noflush(false), seqcheck(false),
64  elapsed(0.0),
65  event_display(0), event_progmeter(0) {}
66 
67  // the action to be performed
68  eventAction action;
69 
70  // signal to abort execution of the sequence
71  bool abort;
72 
73  // do not flush eventblock
74  bool noflush;
75 
76  // just a test run (e.g. fSEQCheck on Idea)
77  bool seqcheck;
78 
79  // counter for time elapsed since start of the sequence
80  double elapsed;
81 
82  // callback pointers to display events in GUI/console
83  SeqTreeCallbackAbstract* event_display;
84 
85  // pointer for progess meter
86  ProgressMeter* event_progmeter;
87 
88  // helper function to update/increase progmeter and store status in 'abort'
89  void increase_progmeter();
90 
91 };
92 
94 
102 enum freqlistAction {calcDeps=0,calcList,calcAcqList,calcDecList};
103 
105 
114 enum programMode {brukerPpg=0, brukerGpg, brukerParx, epicCode, epicPg, epicScan, epicPreScan, epicPreScanDummy, numOfProgModes};
115 
116 
121  programContext() : mode(programMode(0)), formatted(true), nestlevel(0), neststatus(false) {}
122 
123  // the type of program to generate
124  programMode mode;
125 
126  // whether code is nicely formatted (indention, comments), the main
127  // use of this flag is to decide whether to blocks of code are the
128  // same (despite formatting) and whether they can be wrapped in a loop
129  bool formatted;
130 
131  // counter for indention if generating pulse programs
132  int nestlevel;
133 
134  // whether indention is currently enabled
135  bool neststatus;
136 };
137 
138 
140 
141 class SeqTreeObj; //forward declaration
142 
151 enum queryAction {count_acqs, checkoccur, check_acq_iter, tag_toplevel_reploop, display_tree};
152 
156 struct queryContext {
157  queryContext() : action(count_acqs), numof_acqs(0),
158  checkoccur_sto(0), checkoccur_result(false),
159  check_acq_iter_result(false),
160  tree_display(0), parentnode(0), treelevel(0),
161  repetitions_prot(0) {}
162 
163  // the action requested
164  queryAction action;
165 
166  // stuff for action 'count_acqs'
167  unsigned int numof_acqs;
168 
169  // stuff for action 'checkoccur'
170  const SeqTreeObj* checkoccur_sto;
171  bool checkoccur_result;
172 
173  bool check_acq_iter_result;
174 
175  // stuff for action 'display_tree'
176  SeqTreeCallbackAbstract* tree_display;
177  const SeqTreeObj* parentnode;
178  int treelevel;
179 
180  // stuff for action 'tag_toplevel_reploop'
181  int repetitions_prot; // the number of reps in the protocol
182 };
183 
184 
186 
191 struct SeqValList : public ValList<double> {
192  SeqValList(const STD_string& object_label="unnamedSeqValList", unsigned int repetitions=1) : ValList<double>(object_label,repetitions) {}
193 };
194 
196 
197 
198 
202 class SeqTreeObj : public virtual SeqClass {
203 
204  public:
205 
209  virtual double get_duration() const = 0;
210 
216  virtual STD_string get_program(programContext& context) const {return "";}
217 
221  virtual STD_string get_properties() const {return "";}
222 
223 
227  virtual unsigned int event(eventContext& context) const { // make inline to speed up event execution
228  if(context.action==printEvent) display_event(context);
229  context.elapsed+=get_duration();
230  return 0; // no real hardware events played out
231  }
232 
233 
238  virtual RecoValList get_recovallist(unsigned int reptimes, LDRkSpaceCoords& coords) const {return RecoValList();}
239 
243  bool contains(const SeqTreeObj* sto) const;
244 
248  void tree(SeqTreeCallbackAbstract* display) const;
249 
253  virtual SeqValList get_freqvallist(freqlistAction action) const {return SeqValList();}
254 
258  virtual SeqValList get_delayvallist() const {return SeqValList();}
259 
264  virtual double get_rf_energy() const {return 0.0;}
265 
266 
267  protected:
268  friend class SeqObjList;
269  friend class SeqObjVector;
270  friend class SeqParallel;
271 
272 
273 
274  SeqTreeObj();
275 
276  virtual ~SeqTreeObj() {}
277 
278  SeqTreeObj& operator = (const SeqTreeObj& sto) {
279  SeqClass::operator =(sto);
280  return *this;
281  }
282 
286  virtual void query(queryContext& context) const;
287 
288 
289  static int looplevel;
290 
291  private:
292  void display_event(eventContext& context) const;
293 
294 };
295 
296 
297 
301 #endif
eventAction
Definition: seqtree.h:57
void query(queryContext &context) const
virtual unsigned int event(eventContext &context) const
Definition: seqtree.h:227
Container for sequence objects.
Definition: seqlist.h:86
virtual SeqValList get_freqvallist(freqlistAction action) const
Definition: seqtree.h:253
Vector to loop over sequence objects.
Definition: seqobjvec.h:48
virtual SeqValList get_delayvallist() const
Definition: seqtree.h:258
virtual RecoValList get_recovallist(unsigned int reptimes, LDRkSpaceCoords &coords) const
Definition: seqtree.h:238
queryAction
Definition: seqtree.h:151
virtual double get_rf_energy() const
Definition: seqtree.h:264
virtual STD_string get_properties() const
Definition: seqtree.h:221
virtual STD_string get_program(programContext &context) const
Definition: seqtree.h:216
freqlistAction
Definition: seqtree.h:102
SeqParallel & operator=(const SeqParallel &sgp)
programMode
Definition: seqtree.h:114