ARTS 2.5.0 (git: 9ee3ac6c)
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
33class MRecord;
34
35class Workspace;
36
38
44class Agenda {
45 public:
47 : mname(),
48 mml(),
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;
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
108};
109
110// Documentation with implementation.
111ostream& operator<<(ostream& os, const Agenda& a);
112
121class 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),
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
193 mid = x.mid;
194
196
197 moutput.resize(x.moutput.nelem());
198 moutput = x.moutput;
199
200 minput.resize(x.minput.nelem());
201 minput = x.minput;
202
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:
251};
252
254
257inline void Agenda::resize(Index n) { mml.resize(n); }
258
260
266inline Index Agenda::nelem() const { return mml.nelem(); }
267
269
274inline void Agenda::push_back(const MRecord& n) {
275 mml.push_back(n);
276 mchecked = false;
277}
278
280
283inline 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.
293ostream& operator<<(ostream& os, const MRecord& a);
294
297
298#endif
ostream & operator<<(ostream &os, const Agenda &a)
Output operator for Agenda.
Array< Agenda > ArrayOfAgenda
An array of Agenda.
Definition: agenda_class.h:296
The Agenda class.
Definition: agenda_class.h:44
bool mchecked
Flag indicating that the agenda was checked for consistency.
Definition: agenda_class.h:107
void print(ostream &os, const String &indent) const
Print an agenda.
Agenda(const Agenda &x)
Definition: agenda_class.h:58
const ArrayOfIndex & get_output2push() const
Definition: agenda_class.h:85
void execute(Workspace &ws) const
Execute an agenda.
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
Definition: agenda_class.cc:58
String name() const
Agenda name.
Array< MRecord > mml
Definition: agenda_class.h:97
bool is_input(Workspace &ws, Index var) const
Check if given variable is agenda input.
bool has_method(const String &methodname) const
Check if method is in Agenda.
bool is_output(Index var) const
Check if given variable is agenda output.
bool main_agenda
Is set to true if this is the main agenda.
Definition: agenda_class.h:104
void set_methods(const Array< MRecord > &ml)
Definition: agenda_class.h:76
const ArrayOfIndex & get_output2dup() const
Definition: agenda_class.h:86
Agenda & operator=(const Agenda &x)
Assignment operator.
Definition: agenda_class.h:283
void check(Workspace &ws, const Verbosity &verbosity)
Checks consistency of an agenda.
Definition: agenda_class.cc:80
void set_outputs_to_push_and_dup(const Verbosity &verbosity)
Retrieve indexes of all input and output WSVs.
void push_back(const MRecord &n)
Append a new method to end of list.
Definition: agenda_class.h:274
void set_main_agenda()
Definition: agenda_class.h:88
bool checked() const
Definition: agenda_class.h:93
String mname
Definition: agenda_class.h:96
void resize(Index n)
Resize the method list.
Definition: agenda_class.h:257
ArrayOfIndex moutput_push
Definition: agenda_class.h:99
void set_name(const String &nname)
Set agenda name.
const Array< MRecord > & Methods() const
Definition: agenda_class.h:74
ArrayOfIndex moutput_dup
Definition: agenda_class.h:101
bool is_main_agenda() const
Definition: agenda_class.h:92
Index nelem() const
Return the number of agenda elements.
Definition: agenda_class.h:266
This can be used to make arrays out of anything.
Definition: array.h:107
Index nelem() const ARTS_NOEXCEPT
Number of elements.
Definition: array.h:195
Method runtime data.
Definition: agenda_class.h:121
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
Definition: agenda_class.h:248
MRecord(const Index id, const ArrayOfIndex &output, const ArrayOfIndex &input, const TokVal &setvalue, const Agenda &tasks, bool internal=false)
Definition: agenda_class.h:141
const ArrayOfIndex & In() const
Definition: agenda_class.h:157
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:243
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
Definition: agenda_class.h:192
const TokVal & SetValue() const
Definition: agenda_class.h:158
const Agenda & Tasks() const
Definition: agenda_class.h:159
void print(ostream &os, const String &indent) const
Print an MRecord.
bool minternal
Flag if this method is called internally by the engine.
Definition: agenda_class.h:250
MRecord(const MRecord &x)
Definition: agenda_class.h:132
ArrayOfIndex moutput
Output workspace variables.
Definition: agenda_class.h:241
Index Id() const
Definition: agenda_class.h:155
Index mid
Method id.
Definition: agenda_class.h:239
void ginput_only(ArrayOfIndex &ginonly) const
Get list of generic input only WSVs.
Definition: agenda_class.h:219
bool isInternal() const
Indicates the origin of this method.
Definition: agenda_class.h:169
const ArrayOfIndex & Out() const
Definition: agenda_class.h:156
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:245
This stores arbitrary token values and remembers the type.
Definition: token.h:42
Workspace class.
Definition: workspace_ng.h:40
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Declarations having to do with the four output streams.
VectorView var(VectorView var, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the variance of the ranged ys.
Definition: raw.cc:159
#define a