• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List

seqtree.h

00001 /***************************************************************************
00002                           seqtree.h  -  description
00003                              -------------------
00004     begin                : Fri Oct 17 2003
00005     copyright            : (C) 2001 by Thies H. Jochimsen
00006     email                : jochimse@cns.mpg.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 
00019 
00020 #ifndef SEQTREE_H
00021 #define SEQTREE_H
00022 
00023 #include <tjutils/tjvallist.h>
00024 
00025 #include <odinseq/seqclass.h>
00026 #include <odinseq/seqoperator.h>
00027 
00028 
00029 
00035 
00036 
00040 class SeqTreeCallbackAbstract {
00041 
00042  public:
00043   virtual void display_node(const SeqClass* thisnode, const SeqClass* parentnode, int treelevel, const svector& columntext) = 0;
00044 
00045 };
00046 
00048 
00049 class ProgressMeter; // forward declaration
00050 
00057 enum eventAction {seqRun=0, printEvent, countEvents};
00058 
00062 struct eventContext {
00063   eventContext() : action(seqRun), noflush(false), seqcheck(false),
00064                    elapsed(0.0),
00065                    event_display(0), event_progmeter(0) {}
00066 
00067   // the action to be performed
00068   eventAction action;
00069 
00070   // do not flush eventblock
00071   bool noflush;
00072 
00073   // just a test run (e.g. fSEQCheck on Idea)
00074   bool seqcheck;
00075 
00076   // counter for time elapsed since start of the sequence
00077   double elapsed;
00078 
00079   // callback pointers to display events in GUI/console
00080   SeqTreeCallbackAbstract* event_display;
00081 
00082   // pointer for progess meter
00083   ProgressMeter* event_progmeter;
00084 };
00085 
00087 
00095 enum freqlistAction {calcDeps=0,calcList,calcAcqList,calcDecList};
00096 
00098 
00107 enum programMode {brukerPpg=0, brukerGpg, brukerParx, epicCode, epicPg, epicScan, epicPreScan, epicPreScanDummy, numOfProgModes};
00108 
00109 
00113 struct programContext {
00114   programContext() : mode(programMode(0)), formatted(true), nestlevel(0), neststatus(false)  {}
00115 
00116   // the type of program to generate
00117   programMode mode;
00118 
00119   // whether code is nicely formatted (indention, comments), the main
00120   // use of this flag is to decide whether to blocks of code are the
00121   // same (despite formatting) and whether they can be wrapped in a loop
00122   bool formatted;
00123 
00124   // counter for indention if generating pulse programs
00125   int nestlevel;
00126 
00127   // whether indention is currently enabled
00128   bool neststatus;
00129 };
00130 
00131 
00133 
00134 class SeqTreeObj; //forward declaration
00135 
00144 enum queryAction {count_acqs, checkoccur, check_acq_iter, tag_toplevel_reploop, display_tree};
00145 
00149 struct queryContext {
00150   queryContext() : action(count_acqs), numof_acqs(0),
00151   checkoccur_sto(0), checkoccur_result(false),
00152   check_acq_iter_result(false),
00153   tree_display(0), parentnode(0), treelevel(0),
00154   repetitions_prot(0) {}
00155 
00156   // the action requested
00157   queryAction action;
00158 
00159   // stuff for action 'count_acqs'
00160   unsigned int numof_acqs;
00161 
00162   // stuff for action 'checkoccur'
00163   const SeqTreeObj* checkoccur_sto;
00164   bool checkoccur_result;
00165 
00166   bool check_acq_iter_result;
00167   
00168   // stuff for action 'display_tree'
00169   SeqTreeCallbackAbstract* tree_display;
00170   const SeqTreeObj* parentnode;
00171   int treelevel;
00172 
00173   // stuff for action 'tag_toplevel_reploop'
00174   int repetitions_prot; // the number of reps in the protocol
00175 };
00176 
00177 
00179 
00184 struct SeqValList : public ValList<double> {
00185   SeqValList(const STD_string& object_label="unnamedSeqValList", unsigned int repetitions=1) : ValList<double>(object_label,repetitions) {}
00186 };
00187 
00189 
00190 
00191 
00195 class SeqTreeObj : public virtual SeqClass {
00196 
00197  public:
00198 
00202   virtual double get_duration() const = 0;
00203 
00209   virtual STD_string get_program(programContext& context) const {return "";}
00210 
00214   virtual STD_string get_properties() const {return "";}
00215 
00216 
00220   virtual unsigned int event(eventContext& context) const { // make inline to speed up event execution
00221     if(context.action==printEvent) display_event(context);
00222     context.elapsed+=get_duration();
00223     return 0; // no real hardware events played out
00224   }
00225 
00226 
00231   virtual RecoValList get_recovallist(unsigned int reptimes, JDXkSpaceCoords& coords) const {return RecoValList();}
00232 
00236   bool contains(const SeqTreeObj* sto) const;
00237 
00241   void tree(SeqTreeCallbackAbstract* display) const;
00242 
00246   virtual SeqValList get_freqvallist(freqlistAction action) const {return SeqValList();}
00247 
00251   virtual SeqValList get_delayvallist() const {return SeqValList();}
00252 
00257   virtual double get_rf_energy() const {return 0.0;}
00258 
00259 
00260  protected:
00261   friend class SeqObjList;
00262   friend class SeqObjVector;
00263   friend class SeqParallel;
00264 
00265 
00266 
00267   SeqTreeObj();
00268 
00269   virtual ~SeqTreeObj() {}
00270 
00271   SeqTreeObj& operator = (const SeqTreeObj& sto) {
00272     SeqClass::operator =(sto);
00273     return *this;
00274   }
00275 
00279   virtual void query(queryContext& context) const;
00280 
00281 
00282   static int looplevel;
00283 
00284  private:
00285   void display_event(eventContext& context) const;
00286 
00287 };
00288 
00289 
00290 
00294 #endif

Generated on Tue Dec 18 2012 15:11:14 by  doxygen 1.7.1