ARTS 2.5.4 (git: 31ce4f0e)
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 "debug.h"
32#include "matpack.h"
33#include "mystring.h"
34
35#include "messages.h"
36#include "tokval.h"
37#include "workspace_ng.h"
38
39#include <set>
40#include <utility>
42
51template <typename OutputStream, typename Container>
52void PrintWsvNames(OutputStream &outstream, const Workspace& ws, const Container &container) {
53 for (typename Container::const_iterator it = container.begin();
54 it != container.end();
55 it++) {
56 ws.PrintWsvName(outstream, *it);
57 }
58}
59
60class MRecord;
61
63
69class Agenda final {
70 public:
71 Agenda();
72 explicit Agenda(Workspace& workspace);
73
77 Agenda(const Agenda& x) = default;
78
79 void append(const String& methodname, const TokVal& keywordvalue);
80 void check(Workspace& ws_in, const Verbosity& verbosity);
81 void push_back(const MRecord& n);
82 void execute(Workspace& ws_in) const;
83 void resize(Index n);
84 [[nodiscard]] Index nelem() const;
85 Agenda& operator=(const Agenda& x);
86 [[nodiscard]] const Array<MRecord>& Methods() const { return mml; }
87 [[nodiscard]] bool has_method(const String& methodname) const;
88 void set_methods(const Array<MRecord>& ml);
89 void set_outputs_to_push_and_dup(const Verbosity& verbosity);
90 [[nodiscard]] bool is_input(Workspace& ws_in, Index var) const;
91 [[nodiscard]] bool is_output(Index var) const;
92 void set_name(const String& nname);
93 [[nodiscard]] String name() const;
94 [[nodiscard]] const ArrayOfIndex& get_output2push() const { return moutput_push; }
95 [[nodiscard]] const ArrayOfIndex& get_output2dup() const { return moutput_dup; }
96 void print(ostream& os, const String& indent) const;
98 main_agenda = true;
99 mchecked = true;
100 }
101 [[nodiscard]] bool is_main_agenda() const { return main_agenda; }
102 [[nodiscard]] bool checked() const { return mchecked; }
103
104 friend ostream& operator<<(ostream& os, const Agenda& a);
105
106 [[nodiscard]] bool has_same_origin(const Workspace& ws2) const {return ws->original_workspace == ws2.original_workspace;}
107
108 [[nodiscard]] Workspace& workspace() {return *ws;}
109 [[nodiscard]] const Workspace& workspace() const {return *ws;}
110
111 private:
112 std::shared_ptr<Workspace> ws;
117
119
121 bool main_agenda{false};
122
124 bool mchecked{false};
125};
126
135class MRecord {
136 public:
137 MRecord();
138
139 explicit MRecord(Workspace& ws);
140
141 MRecord(const MRecord& x) = default;
142
143 MRecord(const Index id,
144 ArrayOfIndex output,
145 ArrayOfIndex input,
146 const TokVal& setvalue,
147 const Agenda& tasks,
148 bool internal = false);
149
150 [[nodiscard]] Index Id() const { return mid; }
151 [[nodiscard]] const ArrayOfIndex& Out() const { return moutput; }
152 [[nodiscard]] const ArrayOfIndex& In() const { return minput; }
153 [[nodiscard]] const TokVal& SetValue() const { return msetvalue; }
154 [[nodiscard]] const Agenda& Tasks() const { return mtasks; }
155
157
164 [[nodiscard]] bool isInternal() const { return minternal; }
165
167
187 MRecord& operator=(const MRecord& x);
188
190
199 void ginput_only(ArrayOfIndex& ginonly) const;
200 // Output operator:
201 void print(ostream& os, const String& indent) const;
202
203 friend ostream& operator<<(ostream& os, const MRecord& a);
204
205 private:
218 bool minternal{false};
219};
220
221
224
225#endif
void PrintWsvNames(OutputStream &outstream, const Workspace &ws, const Container &container)
Print list of WSV names to output stream.
Definition: agenda_class.h:52
This file contains the definition of Array.
The Agenda class.
Definition: agenda_class.h:69
Workspace & workspace()
Definition: agenda_class.h:108
bool mchecked
Flag indicating that the agenda was checked for consistency.
Definition: agenda_class.h:124
bool has_same_origin(const Workspace &ws2) const
Definition: agenda_class.h:106
void print(ostream &os, const String &indent) const
Print an agenda.
const ArrayOfIndex & get_output2push() const
Definition: agenda_class.h:94
const Workspace & workspace() const
Definition: agenda_class.h:109
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
Definition: agenda_class.cc:87
String name() const
Agenda name.
Array< MRecord > mml
Definition: agenda_class.h:114
void execute(Workspace &ws_in) const
Execute an agenda.
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:121
void set_methods(const Array< MRecord > &ml)
void check(Workspace &ws_in, const Verbosity &verbosity)
Checks consistency of an agenda.
bool is_input(Workspace &ws_in, Index var) const
Check if given variable is agenda input.
const ArrayOfIndex & get_output2dup() const
Definition: agenda_class.h:95
Agenda & operator=(const Agenda &x)
std::shared_ptr< Workspace > ws
Definition: agenda_class.h:112
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.
void set_main_agenda()
Definition: agenda_class.h:97
friend ostream & operator<<(ostream &os, const Agenda &a)
Output operator for Agenda.
bool checked() const
Definition: agenda_class.h:102
String mname
Definition: agenda_class.h:113
void resize(Index n)
Resize the method list.
ArrayOfIndex moutput_push
Definition: agenda_class.h:116
Agenda(const Agenda &x)=default
void set_name(const String &nname)
Set agenda name.
const Array< MRecord > & Methods() const
Definition: agenda_class.h:86
ArrayOfIndex moutput_dup
Definition: agenda_class.h:118
bool is_main_agenda() const
Definition: agenda_class.h:101
Index nelem() const
Return the number of agenda elements.
Method runtime data.
Definition: agenda_class.h:135
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
Definition: agenda_class.h:216
const ArrayOfIndex & In() const
Definition: agenda_class.h:152
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:211
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
const TokVal & SetValue() const
Definition: agenda_class.h:153
friend ostream & operator<<(ostream &os, const MRecord &a)
Output operator for MRecord.
const Agenda & Tasks() const
Definition: agenda_class.h:154
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:218
ArrayOfIndex moutput
Output workspace variables.
Definition: agenda_class.h:209
Index Id() const
Definition: agenda_class.h:150
Index mid
Method id.
Definition: agenda_class.h:207
void ginput_only(ArrayOfIndex &ginonly) const
Get list of generic input only WSVs.
bool isInternal() const
Indicates the origin of this method.
Definition: agenda_class.h:164
const ArrayOfIndex & Out() const
Definition: agenda_class.h:151
MRecord(const MRecord &x)=default
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:213
Definition: tokval.h:145
Workspace class.
Definition: workspace_ng.h:53
void PrintWsvName(OutputStream &outstream, Index i) const
Print WSV name to output stream.
Definition: workspace_ng.h:197
Workspace * original_workspace
Definition: workspace_ng.h:62
Helper macros for debugging.
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
#define a
This file contains the Workspace class.