ARTS  2.2.66
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 "token.h"
31 #include "messages.h"
32 
33 class MRecord;
34 
35 class Workspace;
36 
38 
44 class Agenda {
45 public:
46 
48  mchecked(false)
49  { /* Nothing to do here */ }
50 
54  Agenda(const Agenda& x) : mname(x.mname),
55  mml(x.mml),
60  { /* Nothing to do here */ }
61 
62 
63  void append(const String& methodname, const TokVal& keywordvalue);
64  void check(Workspace& ws, const Verbosity& verbosity);
65  void push_back(const MRecord& n);
66  void execute(Workspace& ws) const;
67  inline void resize(Index n);
68  inline Index nelem() const;
69  inline Agenda& operator=(const Agenda& x);
70  const Array<MRecord>& Methods() const { return mml; }
71  bool has_method(const String& methodname) const;
72  void set_methods(const Array<MRecord>& ml) { mml = ml; mchecked = false; }
73  void set_outputs_to_push_and_dup(const Verbosity& verbosity);
74  bool is_input(Workspace& ws, Index var) const;
75  bool is_output(Index var) const;
76  void set_name(const String& nname);
77  String name() const;
78  const ArrayOfIndex& get_output2push() const { return moutput_push; }
79  const ArrayOfIndex& get_output2dup() const { return moutput_dup; }
80  void print(ostream& os, const String& indent) const;
81  void set_main_agenda() { main_agenda = true; mchecked = true; }
82  bool is_main_agenda() const { return main_agenda; }
83  void find_unused_variables();
84  bool checked() const { return mchecked; }
85 
86 private:
91 
93 
96 
98  bool mchecked;
99 };
100 
101 // Documentation with implementation.
102 ostream& operator<<(ostream& os, const Agenda& a);
103 
104 
113 class MRecord {
114 public:
115  MRecord() : mid(-1),
116  moutput(),
117  minput(),
118  msetvalue(),
119  mtasks(),
120  minternal(false)
121  { /* Nothing to do here. */ }
122 
123  MRecord(const MRecord& x) : mid(x.mid),
124  moutput(x.moutput),
125  minput(x.minput),
126  msetvalue(x.msetvalue),
127  mtasks(x.mtasks),
129  { /* Nothing to do here */ }
130 
131  MRecord(const Index id,
132  const ArrayOfIndex& output,
133  const ArrayOfIndex& input,
134  const TokVal& setvalue,
135  const Agenda& tasks,
136  bool internal = false) : mid(id),
137  moutput(output),
138  minput(input),
139  msetvalue(setvalue),
140  mtasks(tasks),
141  minternal(internal)
142  { /* Nothing to do here */ }
143 
144  Index Id() const { return mid; }
145  const ArrayOfIndex& Out() const { return moutput; }
146  const ArrayOfIndex& In() const { return minput; }
147  const TokVal& SetValue() const { return msetvalue; }
148  const Agenda& Tasks() const { return mtasks; }
149 
151 
158  bool isInternal() const { return minternal; }
159 
161 
182  {
183  mid = x.mid;
184 
185  msetvalue = x.msetvalue;
186 
187  moutput.resize(x.moutput.nelem());
188  moutput = x.moutput;
189 
190  minput.resize(x.minput.nelem());
191  minput = x.minput;
192 
193  mtasks.resize(x.mtasks.nelem());
194  mtasks = x.mtasks;
195 
196  return *this;
197  }
198 
200 
209  void ginput_only(ArrayOfIndex& ginonly) const
210  {
211  ginonly = minput; // Input
212  for (ArrayOfIndex::const_iterator j = moutput.begin(); j < moutput.end(); ++j)
213  for (ArrayOfIndex::iterator k = ginonly.begin(); k < ginonly.end(); ++k)
214  if (*j == *k)
215  {
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;
242 };
243 
245 
248 inline void Agenda::resize(Index n)
249 {
250  mml.resize(n);
251 }
252 
254 
260 inline Index Agenda::nelem() const
261 {
262  return mml.nelem();
263 }
264 
265 
267 
272 inline void Agenda::push_back(const MRecord& n)
273 {
274  mml.push_back(n);
275  mchecked = false;
276 }
277 
278 
280 
283 inline Agenda& Agenda::operator=(const Agenda& x)
284 {
285  mml = x.mml;
286  mname = x.mname;
289  mchecked = x.mchecked;
290  return *this;
291 }
292 
293 // Documentation is with implementation.
294 ostream& operator<<(ostream& os, const MRecord& a);
295 
296 #endif
297 
MRecord::isInternal
bool isInternal() const
Indicates the origin of this method.
Definition: agenda_class.h:158
MRecord::Out
const ArrayOfIndex & Out() const
Definition: agenda_class.h:145
MRecord::mid
Index mid
Method id.
Definition: agenda_class.h:230
Agenda::push_back
void push_back(const MRecord &n)
Append a new method to end of list.
Definition: agenda_class.h:272
TokVal
This stores arbitrary token values and remembers the type.
Definition: token.h:33
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:289
MRecord::mtasks
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
Definition: agenda_class.h:239
Agenda::execute
void execute(Workspace &ws) const
Execute an agenda.
Definition: agenda_class.cc:162
Agenda::nelem
Index nelem() const
Return the number of agenda elements.
Definition: agenda_class.h:260
Agenda::set_methods
void set_methods(const Array< MRecord > &ml)
Definition: agenda_class.h:72
MRecord::MRecord
MRecord(const MRecord &x)
Definition: agenda_class.h:123
MRecord
Method runtime data.
Definition: agenda_class.h:113
Agenda::get_output2dup
const ArrayOfIndex & get_output2dup() const
Definition: agenda_class.h:79
Agenda::is_output
bool is_output(Index var) const
Check if given variable is agenda output.
Definition: agenda_class.cc:556
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:148
Agenda::has_method
bool has_method(const String &methodname) const
Check if method is in Agenda.
Definition: agenda_class.cc:668
Agenda
The Agenda class.
Definition: agenda_class.h:44
Agenda::mml
Array< MRecord > mml
Definition: agenda_class.h:88
Agenda::checked
bool checked() const
Definition: agenda_class.h:84
Agenda::set_main_agenda
void set_main_agenda()
Definition: agenda_class.h:81
Array< MRecord >
Agenda::moutput_push
ArrayOfIndex moutput_push
Definition: agenda_class.h:90
Agenda::append
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
Definition: agenda_class.cc:59
MRecord::In
const ArrayOfIndex & In() const
Definition: agenda_class.h:146
messages.h
Declarations having to do with the four output streams.
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:64
Agenda::Agenda
Agenda()
Definition: agenda_class.h:47
MRecord::minput
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:234
MRecord::SetValue
const TokVal & SetValue() const
Definition: agenda_class.h:147
Agenda::name
String name() const
Agenda name.
Definition: agenda_class.cc:612
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:131
Agenda::find_unused_variables
void find_unused_variables()
Definition: agenda_class.cc:617
MRecord::print
void print(ostream &os, const String &indent) const
Print an MRecord.
Definition: agenda_class.cc:752
Agenda::is_main_agenda
bool is_main_agenda() const
Definition: agenda_class.h:82
Verbosity
Definition: messages.h:50
MRecord::MRecord
MRecord()
Definition: agenda_class.h:115
Agenda::main_agenda
bool main_agenda
Is set to true if this is the main agenda.
Definition: agenda_class.h:95
Agenda::check
void check(Workspace &ws, const Verbosity &verbosity)
Checks consistency of an agenda.
Definition: agenda_class.cc:84
MRecord::ginput_only
void ginput_only(ArrayOfIndex &ginonly) const
Get list of generic input only WSVs.
Definition: agenda_class.h:209
Agenda::is_input
bool is_input(Workspace &ws, Index var) const
Check if given variable is agenda input.
Definition: agenda_class.cc:480
Agenda::Agenda
Agenda(const Agenda &x)
Definition: agenda_class.h:54
MRecord::msetvalue
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:236
MRecord::Id
Index Id() const
Definition: agenda_class.h:144
Workspace
Workspace class.
Definition: workspace_ng.h:47
Agenda::mname
String mname
Definition: agenda_class.h:87
Agenda::get_output2push
const ArrayOfIndex & get_output2push() const
Definition: agenda_class.h:78
Agenda::set_name
void set_name(const String &nname)
Set agenda name.
Definition: agenda_class.cc:600
operator<<
ostream & operator<<(ostream &os, const Agenda &a)
Output operator for Agenda.
Definition: agenda_class.cc:719
Agenda::resize
void resize(Index n)
Resize the method list.
Definition: agenda_class.h:248
Agenda::moutput_dup
ArrayOfIndex moutput_dup
Definition: agenda_class.h:92
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
Agenda::Methods
const Array< MRecord > & Methods() const
Definition: agenda_class.h:70
Agenda::mchecked
bool mchecked
Flag indicating that the agenda was checked for consistency.
Definition: agenda_class.h:98
MRecord::minternal
bool minternal
Flag if this method is called internally by the engine.
Definition: agenda_class.h:241
token.h
MRecord::moutput
ArrayOfIndex moutput
Output workspace variables.
Definition: agenda_class.h:232
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:176
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:181