ARTS  2.3.1285(git:92a29ea9-dirty)
agenda_class.h
Go to the documentation of this file.
1 /* Copyright (C) 2000-2012 Stefan Buehler <sbuehler@ltu.se>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16  USA. */
17 
26 #ifndef agenda_class_h
27 #define agenda_class_h
28 
29 #include <set>
30 #include "messages.h"
31 #include "token.h"
32 
33 class MRecord;
34 
35 class Workspace;
36 
38 
44 class Agenda {
45  public:
47  : mname(),
48  mml(),
49  moutput_push(),
50  moutput_dup(),
51  main_agenda(false),
52  mchecked(false) { /* Nothing to do here */
53  }
54 
58  Agenda(const Agenda& x)
59  : mname(x.mname),
60  mml(x.mml),
64  mchecked(x.mchecked) { /* Nothing to do here */
65  }
66 
67  void append(const String& methodname, const TokVal& keywordvalue);
68  void check(Workspace& ws, const Verbosity& verbosity);
69  void push_back(const MRecord& n);
70  void execute(Workspace& ws) const;
71  inline void resize(Index n);
72  inline Index nelem() const;
73  inline Agenda& operator=(const Agenda& x);
74  const Array<MRecord>& Methods() const { return mml; }
75  bool has_method(const String& methodname) const;
76  void set_methods(const Array<MRecord>& ml) {
77  mml = ml;
78  mchecked = false;
79  }
80  void set_outputs_to_push_and_dup(const Verbosity& verbosity);
81  bool is_input(Workspace& ws, Index var) const;
82  bool is_output(Index var) const;
83  void set_name(const String& nname);
84  String name() const;
85  const ArrayOfIndex& get_output2push() const { return moutput_push; }
86  const ArrayOfIndex& get_output2dup() const { return moutput_dup; }
87  void print(ostream& os, const String& indent) const;
88  void set_main_agenda() {
89  main_agenda = true;
90  mchecked = true;
91  }
92  bool is_main_agenda() const { return main_agenda; }
93  bool checked() const { return mchecked; }
94 
95  private:
100 
102 
105 
107  bool mchecked;
108 };
109 
110 // Documentation with implementation.
111 ostream& operator<<(ostream& os, const Agenda& a);
112 
121 class MRecord {
122  public:
124  : mid(-1),
125  moutput(),
126  minput(),
127  msetvalue(),
128  mtasks(),
129  minternal(false) { /* Nothing to do here. */
130  }
131 
132  MRecord(const MRecord& x)
133  : mid(x.mid),
134  moutput(x.moutput),
135  minput(x.minput),
136  msetvalue(x.msetvalue),
137  mtasks(x.mtasks),
138  minternal(x.minternal) { /* Nothing to do here */
139  }
140 
141  MRecord(const Index id,
142  const ArrayOfIndex& output,
143  const ArrayOfIndex& input,
144  const TokVal& setvalue,
145  const Agenda& tasks,
146  bool internal = false)
147  : mid(id),
148  moutput(output),
149  minput(input),
150  msetvalue(setvalue),
151  mtasks(tasks),
152  minternal(internal) { /* Nothing to do here */
153  }
154 
155  Index Id() const { return mid; }
156  const ArrayOfIndex& Out() const { return moutput; }
157  const ArrayOfIndex& In() const { return minput; }
158  const TokVal& SetValue() const { return msetvalue; }
159  const Agenda& Tasks() const { return mtasks; }
160 
162 
169  bool isInternal() const { return minternal; }
170 
172 
192  MRecord& operator=(const MRecord& x) {
193  mid = x.mid;
194 
195  msetvalue = x.msetvalue;
196 
197  moutput.resize(x.moutput.nelem());
198  moutput = x.moutput;
199 
200  minput.resize(x.minput.nelem());
201  minput = x.minput;
202 
203  mtasks.resize(x.mtasks.nelem());
204  mtasks = x.mtasks;
205 
206  return *this;
207  }
208 
210 
219  void ginput_only(ArrayOfIndex& ginonly) const {
220  ginonly = minput; // Input
221  for (ArrayOfIndex::const_iterator j = moutput.begin(); j < moutput.end();
222  ++j)
223  for (ArrayOfIndex::iterator k = ginonly.begin(); k < ginonly.end(); ++k)
224  if (*j == *k) {
225  // erase_vector_element(vi,k);
226  k = ginonly.erase(k) - 1;
227  // We need the -1 here, otherwise due to the
228  // following increment we would miss the element
229  // behind the erased one, which is now at the
230  // position of the erased one.
231  }
232  }
233 
234  // Output operator:
235  void print(ostream& os, const String& indent) const;
236 
237  private:
250  bool minternal;
251 };
252 
254 
257 inline void Agenda::resize(Index n) { mml.resize(n); }
258 
260 
266 inline Index Agenda::nelem() const { return mml.nelem(); }
267 
269 
274 inline void Agenda::push_back(const MRecord& n) {
275  mml.push_back(n);
276  mchecked = false;
277 }
278 
280 
283 inline Agenda& Agenda::operator=(const Agenda& x) {
284  mml = x.mml;
285  mname = x.mname;
288  mchecked = x.mchecked;
289  return *this;
290 }
291 
292 // Documentation is with implementation.
293 ostream& operator<<(ostream& os, const MRecord& a);
294 
297 
298 #endif
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
void set_outputs_to_push_and_dup(const Verbosity &verbosity)
Retrieve indexes of all input and output WSVs.
bool main_agenda
Is set to true if this is the main agenda.
Definition: agenda_class.h:104
void var(VectorView var, const Vector &y, const ArrayOfVector &ys, const Index start=0, const Index end=-1)
Compute the variance of the ranged ys.
Definition: raw.cc:49
The Agenda class.
Definition: agenda_class.h:44
String name() const
Agenda name.
Index nelem() const
Number of elements.
Definition: array.h:195
void check(Workspace &ws, const Verbosity &verbosity)
Checks consistency of an agenda.
Definition: agenda_class.cc:80
Declarations having to do with the four output streams.
const ArrayOfIndex & In() const
Definition: agenda_class.h:157
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:243
void ginput_only(ArrayOfIndex &ginonly) const
Get list of generic input only WSVs.
Definition: agenda_class.h:219
Agenda(const Agenda &x)
Definition: agenda_class.h:58
void resize(Index n)
Resize the method list.
Definition: agenda_class.h:257
Index Id() const
Definition: agenda_class.h:155
const ArrayOfIndex & Out() const
Definition: agenda_class.h:156
ArrayOfIndex moutput_dup
Definition: agenda_class.h:101
Array< Agenda > ArrayOfAgenda
An array of Agenda.
Definition: agenda_class.h:296
bool mchecked
Flag indicating that the agenda was checked for consistency.
Definition: agenda_class.h:107
bool has_method(const String &methodname) const
Check if method is in Agenda.
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:245
bool is_main_agenda() const
Definition: agenda_class.h:92
ArrayOfIndex moutput_push
Definition: agenda_class.h:99
Method runtime data.
Definition: agenda_class.h:121
bool is_input(Workspace &ws, Index var) const
Check if given variable is agenda input.
bool minternal
Flag if this method is called internally by the engine.
Definition: agenda_class.h:250
void execute(Workspace &ws) const
Execute an agenda.
MRecord(const Index id, const ArrayOfIndex &output, const ArrayOfIndex &input, const TokVal &setvalue, const Agenda &tasks, bool internal=false)
Definition: agenda_class.h:141
Index nelem() const
Return the number of agenda elements.
Definition: agenda_class.h:266
void set_methods(const Array< MRecord > &ml)
Definition: agenda_class.h:76
String mname
Definition: agenda_class.h:96
const ArrayOfIndex & get_output2push() const
Definition: agenda_class.h:85
const ArrayOfIndex & get_output2dup() const
Definition: agenda_class.h:86
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
Definition: agenda_class.h:192
bool isInternal() const
Indicates the origin of this method.
Definition: agenda_class.h:169
void print(ostream &os, const String &indent) const
Print an agenda.
void set_name(const String &nname)
Set agenda name.
const Array< MRecord > & Methods() const
Definition: agenda_class.h:74
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
Definition: agenda_class.h:248
const TokVal & SetValue() const
Definition: agenda_class.h:158
void set_main_agenda()
Definition: agenda_class.h:88
bool is_output(Index var) const
Check if given variable is agenda output.
Workspace class.
Definition: workspace_ng.h:40
ArrayOfIndex moutput
Output workspace variables.
Definition: agenda_class.h:241
const Agenda & Tasks() const
Definition: agenda_class.h:159
Array< MRecord > mml
Definition: agenda_class.h:97
bool checked() const
Definition: agenda_class.h:93
Agenda & operator=(const Agenda &x)
Assignment operator.
Definition: agenda_class.h:283
MRecord(const MRecord &x)
Definition: agenda_class.h:132
This stores arbitrary token values and remembers the type.
Definition: token.h:40
Index mid
Method id.
Definition: agenda_class.h:239
ostream & operator<<(ostream &os, const Agenda &a)
Output operator for Agenda.
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
Definition: agenda_class.cc:58
void push_back(const MRecord &n)
Append a new method to end of list.
Definition: agenda_class.h:274