ARTS 2.5.10 (git: 2f1c442c)
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() = default;
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;
107
108 [[nodiscard]] std::shared_ptr<Workspace> workspace() const;
109
110 void set_workspace(Workspace& x);
111
114
116 [[nodiscard]] std::pair<ArrayOfIndex, ArrayOfIndex> get_global_inout() const;
117
118 private:
119 std::weak_ptr<Workspace> ws;
124
126
128 bool main_agenda{false};
129
131 bool mchecked{false};
132};
133
142class MRecord {
143 public:
144 MRecord();
145
146 explicit MRecord(Workspace& ws);
147
148 MRecord(const MRecord& x) = default;
149
150 MRecord(const Index id,
151 ArrayOfIndex output,
152 ArrayOfIndex input,
153 const TokVal& setvalue,
154 const Agenda& tasks,
155 bool internal = false);
156
157 [[nodiscard]] Index Id() const { return mid; }
158 [[nodiscard]] const ArrayOfIndex& Out() const { return moutput; }
159 [[nodiscard]] const ArrayOfIndex& In() const { return minput; }
160 [[nodiscard]] const TokVal& SetValue() const { return msetvalue; }
161 [[nodiscard]] const Agenda& Tasks() const { return mtasks; }
162
165
167
174 [[nodiscard]] bool isInternal() const { return minternal; }
175
177
197 MRecord& operator=(const MRecord& x);
198
200
209 void ginput_only(ArrayOfIndex& ginonly) const;
210 // Output operator:
211 void print(ostream& os, const String& indent) const;
212
213 friend ostream& operator<<(ostream& os, const MRecord& a);
214
215 void set_workspace(Workspace& x);
216
217 private:
230 bool minternal{false};
231};
232
233
236
239
240#endif
ArrayOfAgenda deepcopy_if(Workspace &ws, const ArrayOfAgenda &agendas)
Same as Agenda member method but for an entire array.
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
bool mchecked
Flag indicating that the agenda was checked for consistency.
Definition: agenda_class.h:131
bool has_same_origin(const Workspace &ws2) const
void print(ostream &os, const String &indent) const
Print an agenda.
std::weak_ptr< Workspace > ws
Definition: agenda_class.h:119
const ArrayOfIndex & get_output2push() const
Definition: agenda_class.h:94
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:121
void execute(Workspace &ws_in) const
Execute an agenda.
bool has_method(const String &methodname) const
Check if method is in Agenda.
void set_workspace(Workspace &x)
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:128
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::pair< ArrayOfIndex, ArrayOfIndex > get_global_inout() const
Get index lists of global input and output variables from agenda_data of this agenda.
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
Agenda deepcopy_if(Workspace &) const
Creates a deep copy of the agenda if necessary (i.e., different workspace)!
Agenda()=default
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:120
void resize(Index n)
Resize the method list.
ArrayOfIndex moutput_push
Definition: agenda_class.h:123
std::shared_ptr< Workspace > workspace() const
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:125
bool is_main_agenda() const
Definition: agenda_class.h:101
Index nelem() const
Return the number of agenda elements.
This can be used to make arrays out of anything.
Definition: array.h:48
Method runtime data.
Definition: agenda_class.h:142
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
Definition: agenda_class.h:228
const ArrayOfIndex & In() const
Definition: agenda_class.h:159
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:223
void set_workspace(Workspace &x)
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
const TokVal & SetValue() const
Definition: agenda_class.h:160
friend ostream & operator<<(ostream &os, const MRecord &a)
Output operator for MRecord.
const Agenda & Tasks() const
Definition: agenda_class.h:161
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:230
MRecord deepcopy_if(Workspace &) const
Creates a deep copy of the method if necessary (i.e., different workspace)!
ArrayOfIndex moutput
Output workspace variables.
Definition: agenda_class.h:221
Index Id() const
Definition: agenda_class.h:157
Index mid
Method id.
Definition: agenda_class.h:219
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:174
const ArrayOfIndex & Out() const
Definition: agenda_class.h:158
MRecord(const MRecord &x)=default
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:225
Definition: tokval.h:245
Workspace class.
Definition: workspace_ng.h:53
void PrintWsvName(OutputStream &outstream, Index i) const
Print WSV name to output stream.
Definition: workspace_ng.h:210
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.
#define a
This file contains the Workspace class.