ARTS 2.5.4 (git: 4c0d3b4d)
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
30#include "array.h"
31#include "species_tags.h"
32#include "matpackI.h"
33#include "mystring.h"
34
35#include "messages.h"
36#include "tokval.h"
37#include <set>
38#include <utility>
39
40class MRecord;
41
42class Workspace;
43
45
51class Agenda {
52 public:
54 : mname(),
55 mml(),
57 moutput_dup() { /* Nothing to do here */
58 }
59
63 Agenda(const Agenda& x) = default;
64
65 Agenda(Agenda&&) noexcept = default;
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 [[nodiscard]] inline Index nelem() const;
73 inline Agenda& operator=(const Agenda& x);
74 [[nodiscard]] const Array<MRecord>& Methods() const { return mml; }
75 [[nodiscard]] 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 [[nodiscard]] bool is_output(Index var) const;
83 void set_name(const String& nname);
84 [[nodiscard]] String name() const;
85 [[nodiscard]] const ArrayOfIndex& get_output2push() const { return moutput_push; }
86 [[nodiscard]] 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 [[nodiscard]] bool is_main_agenda() const { return main_agenda; }
93 [[nodiscard]] bool checked() const { return mchecked; }
94
95 private:
100
102
104 bool main_agenda{false};
105
107 bool mchecked{false};
108};
109
110// Documentation with implementation.
111ostream& operator<<(ostream& os, const Agenda& a);
112
121class MRecord {
122 public:
124 : moutput(),
125 minput(),
126 msetvalue(),
127 mtasks() { /* Nothing to do here. */
128 }
129
130 MRecord(const MRecord& x) = default;
131
132 MRecord(const Index id,
133 ArrayOfIndex output,
134 ArrayOfIndex input,
135 TokVal setvalue,
136 Agenda tasks,
137 bool internal = false)
138 : mid(id),
139 moutput(std::move(output)),
140 minput(std::move(input)),
141 msetvalue(std::move(setvalue)),
142 mtasks(std::move(tasks)),
143 minternal(internal) { /* Nothing to do here */
144 }
145
146 [[nodiscard]] Index Id() const { return mid; }
147 [[nodiscard]] const ArrayOfIndex& Out() const { return moutput; }
148 [[nodiscard]] const ArrayOfIndex& In() const { return minput; }
149 [[nodiscard]] const TokVal& SetValue() const { return msetvalue; }
150 [[nodiscard]] const Agenda& Tasks() const { return mtasks; }
151
153
160 [[nodiscard]] bool isInternal() const { return minternal; }
161
163
184 mid = x.mid;
185
187
188 moutput.resize(x.moutput.nelem());
189 moutput = x.moutput;
190
191 minput.resize(x.minput.nelem());
192 minput = x.minput;
193
195 mtasks = x.mtasks;
196
197 return *this;
198 }
199
201
210 void ginput_only(ArrayOfIndex& ginonly) const {
211 ginonly = minput; // Input
212 for (auto j = moutput.begin(); j < moutput.end();
213 ++j)
214 for (auto k = ginonly.begin(); k < ginonly.end(); ++k)
215 if (*j == *k) {
216 // erase_vector_element(vi,k);
217 k = ginonly.erase(k) - 1;
218 // We need the -1 here, otherwise due to the
219 // following increment we would miss the element
220 // behind the erased one, which is now at the
221 // position of the erased one.
222 }
223 }
224
225 // Output operator:
226 void print(ostream& os, const String& indent) const;
227
228 private:
241 bool minternal{false};
242};
243
245
248inline void Agenda::resize(Index n) { mml.resize(n); }
249
251
257inline Index Agenda::nelem() const { return mml.nelem(); }
258
260
265inline void Agenda::push_back(const MRecord& n) {
266 mml.push_back(n);
267 mchecked = false;
268}
269
271
274inline Agenda& Agenda::operator=(const Agenda& x) {
275 mml = x.mml;
276 mname = x.mname;
279 mchecked = x.mchecked;
280 return *this;
281}
282
283// Documentation is with implementation.
284ostream& operator<<(ostream& os, const MRecord& a);
285
288
289#endif
ostream & operator<<(ostream &os, const Agenda &a)
Output operator for Agenda.
This file contains the definition of Array.
The Agenda class.
Definition: agenda_class.h:51
Agenda(Agenda &&) noexcept=default
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.
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:274
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:265
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:248
ArrayOfIndex moutput_push
Definition: agenda_class.h:99
Agenda(const Agenda &x)=default
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:257
This can be used to make arrays out of anything.
Definition: array.h:108
Index nelem() const ARTS_NOEXCEPT
Number of elements.
Definition: array.h:197
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:239
const ArrayOfIndex & In() const
Definition: agenda_class.h:148
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:234
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
Definition: agenda_class.h:183
const TokVal & SetValue() const
Definition: agenda_class.h:149
const Agenda & Tasks() const
Definition: agenda_class.h:150
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:241
ArrayOfIndex moutput
Output workspace variables.
Definition: agenda_class.h:232
Index Id() const
Definition: agenda_class.h:146
Index mid
Method id.
Definition: agenda_class.h:230
void ginput_only(ArrayOfIndex &ginonly) const
Get list of generic input only WSVs.
Definition: agenda_class.h:210
bool isInternal() const
Indicates the origin of this method.
Definition: agenda_class.h:160
const ArrayOfIndex & Out() const
Definition: agenda_class.h:147
MRecord(const MRecord &x)=default
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:236
MRecord(const Index id, ArrayOfIndex output, ArrayOfIndex input, TokVal setvalue, Agenda tasks, bool internal=false)
Definition: agenda_class.h:132
Definition: tokval.h:27
Workspace class.
Definition: workspace_ng.h:40
Implementation of Matrix, Vector, and such stuff.
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.
This file contains the definition of String, the ARTS string class.
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
VectorView std(VectorView std, const Vector &y, const ArrayOfVector &ys, const Index start, const Index end_tmp)
Compute the standard deviation of the ranged ys.
Definition: raw.cc:205
#define a