ARTS  2.0.49
agenda_class.h
Go to the documentation of this file.
1 /* Copyright (C) 2000-2008 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(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  void set_methods (const Array<MRecord>& ml) { mml = ml; mchecked = false; }
72  void set_outputs_to_push_and_dup (const Verbosity& verbosity);
73  bool is_input(Workspace& ws, Index var) const;
74  bool is_output(Index var) const;
75  void set_name(const String& nname);
76  String name() const;
77  const ArrayOfIndex& get_output2push() const { return moutput_push; }
78  const ArrayOfIndex& get_output2dup() const { return moutput_dup; }
79  void print( ostream& os,
80  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 
85 private:
90 
92 
95 
97  bool mchecked;
98 };
99 
100 // Documentation with implementation.
101 ostream& operator<<(ostream& os, const Agenda& a);
102 
103 
112 class MRecord {
113 public:
114  MRecord() : mid(-1),
115  moutput(),
116  minput(),
117  msetvalue(),
118  mtasks() { /* Nothing to do here. */ }
119 
120  MRecord(const MRecord& x) : mid(x.mid),
121  moutput(x.moutput),
122  minput(x.minput),
123  msetvalue(x.msetvalue),
124  mtasks(x.mtasks)
125  { /* Nothing to do here */ }
126 
127  MRecord(const Index id,
128  const ArrayOfIndex& output,
129  const ArrayOfIndex& input,
130  const TokVal& setvalue,
131  const Agenda& tasks) : mid(id),
132  moutput(output),
133  minput(input),
134  msetvalue(setvalue),
135  mtasks(tasks)
136  { /* Nothing to do here */ }
137 
138  Index Id() const { return mid; }
139  const ArrayOfIndex& Out() const { return moutput; }
140  const ArrayOfIndex& In() const { return minput; }
141  const TokVal& SetValue() const { return msetvalue; }
142  const Agenda& Tasks() const { return mtasks; }
143 
145 
166  {
167  mid = x.mid;
168 
169  msetvalue = x.msetvalue;
170 
171  moutput.resize(x.moutput.nelem());
172  moutput = x.moutput;
173 
174  minput.resize(x.minput.nelem());
175  minput = x.minput;
176 
177  mtasks.resize(x.mtasks.nelem());
178  mtasks = x.mtasks;
179 
180  return *this;
181  }
182 
184 
193  void ginput_only (ArrayOfIndex& ginonly) const
194  {
195  ginonly = minput; // Input
196  for (ArrayOfIndex::const_iterator j=moutput.begin(); j<moutput.end(); ++j)
197  for (ArrayOfIndex::iterator k=ginonly.begin(); k<ginonly.end(); ++k)
198  if ( *j == *k )
199  {
200  // erase_vector_element(vi,k);
201  k = ginonly.erase(k) - 1;
202  // We need the -1 here, otherwise due to the
203  // following increment we would miss the element
204  // behind the erased one, which is now at the
205  // position of the erased one.
206  }
207  }
208 
209  // Output operator:
210  void print( ostream& os,
211  const String& indent ) const;
212 
213 private:
225 };
226 
228 
231 inline void Agenda::resize(Index n)
232 {
233  mml.resize(n);
234 }
235 
237 
243 inline Index Agenda::nelem() const
244 {
245  return mml.nelem();
246 }
247 
248 
250 
256 {
257  mml.push_back(n);
258  mchecked = false;
259 }
260 
261 
263 
266 inline Agenda& Agenda::operator=(const Agenda& x)
267 {
268  mml = x.mml;
269  mname = x.mname;
272  mchecked = x.mchecked;
273  return *this;
274 }
275 
276 // Documentation is with implementation.
277 ostream& operator<<(ostream& os, const MRecord& a);
278 
279 #endif
280 
MRecord::Out
const ArrayOfIndex & Out() const
Definition: agenda_class.h:139
MRecord::mid
Index mid
Method id.
Definition: agenda_class.h:215
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:291
MRecord::mtasks
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
Definition: agenda_class.h:224
Agenda::execute
void execute(Workspace &ws) const
Execute an agenda.
Definition: agenda_class.cc:166
Agenda::nelem
Index nelem() const
Return the number of agenda elements.
Definition: agenda_class.h:243
Agenda::set_methods
void set_methods(const Array< MRecord > &ml)
Definition: agenda_class.h:71
MRecord::MRecord
MRecord(const MRecord &x)
Definition: agenda_class.h:120
MRecord
Method runtime data.
Definition: agenda_class.h:112
Agenda::get_output2dup
const ArrayOfIndex & get_output2dup() const
Definition: agenda_class.h:78
Agenda::is_output
bool is_output(Index var) const
Check if given variable is agenda output.
Definition: agenda_class.cc:558
Agenda::print
void print(ostream &os, const String &indent) const
Print an agenda.
Definition: agenda_class.cc:669
MRecord::Tasks
const Agenda & Tasks() const
Definition: agenda_class.h:142
Agenda
The Agenda class.
Definition: agenda_class.h:44
Agenda::mml
Array< MRecord > mml
Definition: agenda_class.h:87
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:89
Agenda::append
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
Definition: agenda_class.cc:67
MRecord::In
const ArrayOfIndex & In() const
Definition: agenda_class.h:140
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:62
Agenda::Agenda
Agenda()
Definition: agenda_class.h:47
MRecord::minput
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:219
MRecord::SetValue
const TokVal & SetValue() const
Definition: agenda_class.h:141
Agenda::name
String name() const
Agenda name.
Definition: agenda_class.cc:614
Agenda::find_unused_variables
void find_unused_variables()
Definition: agenda_class.cc:619
MRecord::print
void print(ostream &os, const String &indent) const
Print an MRecord.
Definition: agenda_class.cc:723
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:114
Agenda::main_agenda
bool main_agenda
Is set to true if this is the main agenda.
Definition: agenda_class.h:94
Agenda::check
void check(Workspace &ws, const Verbosity &verbosity)
Checks consistency of an agenda.
Definition: agenda_class.cc:92
MRecord::ginput_only
void ginput_only(ArrayOfIndex &ginonly) const
Get list of generic input only WSVs.
Definition: agenda_class.h:193
Agenda::is_input
bool is_input(Workspace &ws, Index var) const
Check if given variable is agenda input.
Definition: agenda_class.cc:482
Agenda::Agenda
Agenda(const Agenda &x)
Definition: agenda_class.h:54
MRecord::msetvalue
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:221
MRecord::Id
Index Id() const
Definition: agenda_class.h:138
Workspace
Workspace class.
Definition: workspace_ng.h:47
Agenda::mname
String mname
Definition: agenda_class.h:86
Agenda::get_output2push
const ArrayOfIndex & get_output2push() const
Definition: agenda_class.h:77
Agenda::set_name
void set_name(const String &nname)
Set agenda name.
Definition: agenda_class.cc:602
operator<<
ostream & operator<<(ostream &os, const Agenda &a)
Output operator for Agenda.
Definition: agenda_class.cc:691
Agenda::resize
void resize(Index n)
Resize the method list.
Definition: agenda_class.h:231
Agenda::moutput_dup
ArrayOfIndex moutput_dup
Definition: agenda_class.h:91
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:70
MRecord::MRecord
MRecord(const Index id, const ArrayOfIndex &output, const ArrayOfIndex &input, const TokVal &setvalue, const Agenda &tasks)
Definition: agenda_class.h:127
Agenda::mchecked
bool mchecked
Flag indicating that the agenda was checked for consistency.
Definition: agenda_class.h:97
token.h
MRecord::moutput
ArrayOfIndex moutput
Output workspace variables.
Definition: agenda_class.h:217
Agenda::push_back
void push_back(MRecord n)
Append a new method to end of list.
Definition: agenda_class.h:255
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:172
Agenda::operator=
Agenda & operator=(const Agenda &x)
Assignment operator.
Definition: agenda_class.h:266
MRecord::operator=
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
Definition: agenda_class.h:165