ARTS  2.4.0(git:4fb77825)
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  }
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),
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 
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;
286  moutput_push = x.moutput_push;
287  moutput_dup = x.moutput_dup;
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
MRecord::isInternal
bool isInternal() const
Indicates the origin of this method.
Definition: agenda_class.h:169
MRecord::Out
const ArrayOfIndex & Out() const
Definition: agenda_class.h:156
MRecord::mid
Index mid
Method id.
Definition: agenda_class.h:239
Agenda::push_back
void push_back(const MRecord &n)
Append a new method to end of list.
Definition: agenda_class.h:274
TokVal
This stores arbitrary token values and remembers the type.
Definition: token.h:40
Agenda::set_outputs_to_push_and_dup
void set_outputs_to_push_and_dup(const Verbosity &verbosity)
Retrieve indexes of all input and output WSVs.
Definition: agenda_class.cc:269
MRecord::mtasks
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
Definition: agenda_class.h:248
Agenda::execute
void execute(Workspace &ws) const
Execute an agenda.
Definition: agenda_class.cc:148
Agenda::nelem
Index nelem() const
Return the number of agenda elements.
Definition: agenda_class.h:266
ARTS::Var::verbosity
Verbosity verbosity(Workspace &ws) noexcept
Definition: autoarts.h:7112
Agenda::set_methods
void set_methods(const Array< MRecord > &ml)
Definition: agenda_class.h:76
MRecord::MRecord
MRecord(const MRecord &x)
Definition: agenda_class.h:132
MRecord
Method runtime data.
Definition: agenda_class.h:121
Agenda::get_output2dup
const ArrayOfIndex & get_output2dup() const
Definition: agenda_class.h:86
Agenda::is_output
bool is_output(Index var) const
Check if given variable is agenda output.
Definition: agenda_class.cc:580
Agenda::print
void print(ostream &os, const String &indent) const
Print an agenda.
Definition: agenda_class.cc:696
MRecord::Tasks
const Agenda & Tasks() const
Definition: agenda_class.h:159
Agenda::has_method
bool has_method(const String &methodname) const
Check if method is in Agenda.
Definition: agenda_class.cc:672
Agenda
The Agenda class.
Definition: agenda_class.h:44
Agenda::mml
Array< MRecord > mml
Definition: agenda_class.h:97
Agenda::checked
bool checked() const
Definition: agenda_class.h:93
Agenda::set_main_agenda
void set_main_agenda()
Definition: agenda_class.h:88
Array< MRecord >
Agenda::moutput_push
ArrayOfIndex moutput_push
Definition: agenda_class.h:99
Agenda::append
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
Definition: agenda_class.cc:58
MRecord::In
const ArrayOfIndex & In() const
Definition: agenda_class.h:157
messages.h
Declarations having to do with the four output streams.
my_basic_string< char >
Agenda::Agenda
Agenda()
Definition: agenda_class.h:46
MRecord::minput
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:243
MRecord::SetValue
const TokVal & SetValue() const
Definition: agenda_class.h:158
Agenda::name
String name() const
Agenda name.
Definition: agenda_class.cc:658
MRecord::MRecord
MRecord(const Index id, const ArrayOfIndex &output, const ArrayOfIndex &input, const TokVal &setvalue, const Agenda &tasks, bool internal=false)
Definition: agenda_class.h:141
ArrayOfAgenda
Array< Agenda > ArrayOfAgenda
An array of Agenda.
Definition: agenda_class.h:296
MRecord::print
void print(ostream &os, const String &indent) const
Print an MRecord.
Definition: agenda_class.cc:746
Agenda::is_main_agenda
bool is_main_agenda() const
Definition: agenda_class.h:92
Verbosity
Definition: messages.h:49
MRecord::MRecord
MRecord()
Definition: agenda_class.h:123
linalg::var
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
Agenda::main_agenda
bool main_agenda
Is set to true if this is the main agenda.
Definition: agenda_class.h:104
Agenda::check
void check(Workspace &ws, const Verbosity &verbosity)
Checks consistency of an agenda.
Definition: agenda_class.cc:80
MRecord::ginput_only
void ginput_only(ArrayOfIndex &ginonly) const
Get list of generic input only WSVs.
Definition: agenda_class.h:219
Agenda::is_input
bool is_input(Workspace &ws, Index var) const
Check if given variable is agenda input.
Definition: agenda_class.cc:498
Agenda::Agenda
Agenda(const Agenda &x)
Definition: agenda_class.h:58
MRecord::msetvalue
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:245
MRecord::Id
Index Id() const
Definition: agenda_class.h:155
Workspace
Workspace class.
Definition: workspace_ng.h:40
Agenda::mname
String mname
Definition: agenda_class.h:96
Agenda::get_output2push
const ArrayOfIndex & get_output2push() const
Definition: agenda_class.h:85
Agenda::set_name
void set_name(const String &nname)
Set agenda name.
Definition: agenda_class.cc:647
operator<<
ostream & operator<<(ostream &os, const Agenda &a)
Output operator for Agenda.
Definition: agenda_class.cc:715
Agenda::resize
void resize(Index n)
Resize the method list.
Definition: agenda_class.h:257
Agenda::moutput_dup
ArrayOfIndex moutput_dup
Definition: agenda_class.h:101
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Agenda::Methods
const Array< MRecord > & Methods() const
Definition: agenda_class.h:74
Agenda::mchecked
bool mchecked
Flag indicating that the agenda was checked for consistency.
Definition: agenda_class.h:107
MRecord::minternal
bool minternal
Flag if this method is called internally by the engine.
Definition: agenda_class.h:250
token.h
MRecord::moutput
ArrayOfIndex moutput
Output workspace variables.
Definition: agenda_class.h:241
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:195
Agenda::operator=
Agenda & operator=(const Agenda &x)
Assignment operator.
Definition: agenda_class.h:283
MRecord::operator=
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
Definition: agenda_class.h:192