00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00026 #ifndef agenda_class_h
00027 #define agenda_class_h
00028
00029 #include <set>
00030 #include "token.h"
00031
00032 class MRecord;
00033
00034 class Workspace;
00035
00037
00043 class Agenda {
00044 public:
00045
00046 Agenda() : mname(), mml(), moutput_push(), moutput_dup(), main_agenda(false),
00047 mchecked(false)
00048 { }
00049
00053 Agenda(const Agenda& x) : mname(x.mname),
00054 mml(x.mml),
00055 moutput_push(x.moutput_push),
00056 moutput_dup(x.moutput_dup),
00057 main_agenda(x.main_agenda),
00058 mchecked(x.mchecked)
00059 { }
00060
00061
00062 void append(Workspace& ws,
00063 const String& methodname, const TokVal& keywordvalue);
00064 void check(Workspace& ws);
00065 void push_back(MRecord n);
00066 void execute(Workspace& ws) const;
00067 inline void resize(Index n);
00068 inline Index nelem() const;
00069 inline Agenda& operator=(const Agenda& x);
00070 const Array<MRecord>& Methods () const { return mml; }
00071 void set_methods (const Array<MRecord>& ml) { mml = ml; mchecked = false; };
00072 void set_outputs_to_push_and_dup ();
00073 bool is_input(Workspace& ws, Index var) const;
00074 bool is_output(Index var) const;
00075 void set_name(const String& nname);
00076 String name() const;
00077 const ArrayOfIndex& get_output2push() const { return moutput_push; }
00078 const ArrayOfIndex& get_output2dup() const { return moutput_dup; }
00079 void print( ostream& os,
00080 const String& indent ) const;
00081 void set_main_agenda() {main_agenda = true; mchecked = true;};
00082 bool is_main_agenda() const {return main_agenda;};
00083 private:
00084 String mname;
00085 Array<MRecord> mml;
00087 ArrayOfIndex moutput_push;
00088
00089 ArrayOfIndex moutput_dup;
00090
00092 bool main_agenda;
00093
00095 bool mchecked;
00096 };
00097
00098
00099 ostream& operator<<(ostream& os, const Agenda& a);
00100
00101
00110 class MRecord {
00111 public:
00112 MRecord() : mid(-1),
00113 moutput(),
00114 minput(),
00115 msetvalue(),
00116 mtasks() { }
00117
00118 MRecord(const MRecord& x) : mid(x.mid),
00119 moutput(x.moutput),
00120 minput(x.minput),
00121 msetvalue(x.msetvalue),
00122 mtasks(x.mtasks)
00123 { }
00124
00125 MRecord(const Index id,
00126 const ArrayOfIndex& output,
00127 const ArrayOfIndex& input,
00128 const TokVal& setvalue,
00129 const Agenda& tasks) : mid(id),
00130 moutput(output),
00131 minput(input),
00132 msetvalue(setvalue),
00133 mtasks(tasks)
00134 { }
00135
00136 Index Id() const { return mid; }
00137 const ArrayOfIndex& Out() const { return moutput; }
00138 const ArrayOfIndex& In() const { return minput; }
00139 const TokVal& SetValue() const { return msetvalue; }
00140 const Agenda& Tasks() const { return mtasks; }
00141
00143
00163 MRecord& operator=(const MRecord& x)
00164 {
00165 mid = x.mid;
00166
00167 msetvalue = x.msetvalue;
00168
00169 moutput.resize(x.moutput.nelem());
00170 moutput = x.moutput;
00171
00172 minput.resize(x.minput.nelem());
00173 minput = x.minput;
00174
00175 mtasks.resize(x.mtasks.nelem());
00176 mtasks = x.mtasks;
00177
00178 return *this;
00179 }
00180
00182
00191 void ginput_only (ArrayOfIndex& ginonly) const
00192 {
00193 ginonly = minput;
00194 for (ArrayOfIndex::const_iterator j=moutput.begin(); j<moutput.end(); ++j)
00195 for (ArrayOfIndex::iterator k=ginonly.begin(); k<ginonly.end(); ++k)
00196 if ( *j == *k )
00197 {
00198
00199 k = ginonly.erase(k) - 1;
00200
00201
00202
00203
00204 }
00205 }
00206
00207
00208 void print( ostream& os,
00209 const String& indent ) const;
00210
00211 private:
00213 Index mid;
00215 ArrayOfIndex moutput;
00217 ArrayOfIndex minput;
00219 TokVal msetvalue;
00222 Agenda mtasks;
00223 };
00224
00226
00229 inline void Agenda::resize(Index n)
00230 {
00231 mml.resize(n);
00232 }
00233
00235
00241 inline Index Agenda::nelem() const
00242 {
00243 return mml.nelem();
00244 }
00245
00246
00248
00253 inline void Agenda::push_back(MRecord n)
00254 {
00255 mml.push_back(n);
00256 mchecked = false;
00257 }
00258
00259
00261
00264 inline Agenda& Agenda::operator=(const Agenda& x)
00265 {
00266 mml = x.mml;
00267 mname = x.mname;
00268 moutput_push = x.moutput_push;
00269 moutput_dup = x.moutput_dup;
00270 mchecked = x.mchecked;
00271 return *this;
00272 }
00273
00274
00275 ostream& operator<<(ostream& os, const MRecord& a);
00276
00277 #endif
00278