ARTS 2.5.11 (git: 6827797f)
agenda_class.h
Go to the documentation of this file.
1
9#ifndef agenda_class_h
10#define agenda_class_h
11
12
13#include "array.h"
14#include "debug.h"
15#include "matpack_concepts.h"
16#include "mystring.h"
17
18#include "messages.h"
19#include "tokval.h"
20#include "workspace_ng.h"
21
22#include <set>
23#include <utility>
25
34template <typename OutputStream, typename Container>
35void PrintWsvNames(OutputStream &outstream, const Workspace& ws, const Container &container) {
36 for (typename Container::const_iterator it = container.begin();
37 it != container.end();
38 it++) {
39 ws.PrintWsvName(outstream, *it);
40 }
41}
42
43class MRecord;
44
46
52class Agenda final {
53 public:
54 Agenda() = default;
55 explicit Agenda(Workspace& workspace);
56
60 Agenda(const Agenda& x) = default;
61
62 void append(const String& methodname, const TokVal& keywordvalue);
63 void check(Workspace& ws_in, const Verbosity& verbosity);
64 void push_back(const MRecord& n);
65 void execute(Workspace& ws_in) const;
66 void resize(Index n);
67 [[nodiscard]] Index nelem() const;
68 Agenda& operator=(const Agenda& x);
69 [[nodiscard]] const Array<MRecord>& Methods() const { return mml; }
70 [[nodiscard]] bool has_method(const String& methodname) const;
71 void set_methods(const Array<MRecord>& ml);
72 void set_outputs_to_push_and_dup(const Verbosity& verbosity);
73 [[nodiscard]] bool is_input(Workspace& ws_in, Index var) const;
74 [[nodiscard]] bool is_output(Index var) const;
75 void set_name(const String& nname);
76 [[nodiscard]] String name() const;
77 [[nodiscard]] const ArrayOfIndex& get_output2push() const { return moutput_push; }
78 [[nodiscard]] const ArrayOfIndex& get_output2dup() const { return moutput_dup; }
79 void print(ostream& os, const String& indent) const;
81 main_agenda = true;
82 mchecked = true;
83 }
84 [[nodiscard]] bool is_main_agenda() const { return main_agenda; }
85 [[nodiscard]] bool checked() const { return mchecked; }
86
87 friend ostream& operator<<(ostream& os, const Agenda& a);
88
89 [[nodiscard]] bool has_same_origin(const Workspace& ws2) const;
90
91 [[nodiscard]] std::shared_ptr<Workspace> workspace() const;
92
93 void set_workspace(Workspace& x);
94
97
99 [[nodiscard]] std::pair<ArrayOfIndex, ArrayOfIndex> get_global_inout() const;
100
101 private:
102 std::weak_ptr<Workspace> ws;
107
109
111 bool main_agenda{false};
112
114 bool mchecked{false};
115};
116
125class MRecord {
126 public:
127 MRecord();
128
129 explicit MRecord(Workspace& ws);
130
131 MRecord(const MRecord& x) = default;
132
133 MRecord(const Index id,
134 ArrayOfIndex output,
135 ArrayOfIndex input,
136 const TokVal& setvalue,
137 const Agenda& tasks,
138 bool internal = false);
139
140 [[nodiscard]] Index Id() const { return mid; }
141 [[nodiscard]] const ArrayOfIndex& Out() const { return moutput; }
142 [[nodiscard]] const ArrayOfIndex& In() const { return minput; }
143 [[nodiscard]] const TokVal& SetValue() const { return msetvalue; }
144 [[nodiscard]] const Agenda& Tasks() const { return mtasks; }
145
148
150
157 [[nodiscard]] bool isInternal() const { return minternal; }
158
160
180 MRecord& operator=(const MRecord& x);
181
183
192 void ginput_only(ArrayOfIndex& ginonly) const;
193 // Output operator:
194 void print(ostream& os, const String& indent) const;
195
196 friend ostream& operator<<(ostream& os, const MRecord& a);
197
198 void set_workspace(Workspace& x);
199
200 private:
202 Index mid{-1};
213 bool minternal{false};
214};
215
216
219
222
223#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:35
This file contains the definition of Array.
The Agenda class.
Definition: agenda_class.h:52
bool mchecked
Flag indicating that the agenda was checked for consistency.
Definition: agenda_class.h:114
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:102
const ArrayOfIndex & get_output2push() const
Definition: agenda_class.h:77
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
Definition: agenda_class.cc:68
String name() const
Agenda name.
Array< MRecord > mml
Definition: agenda_class.h:104
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:111
void set_methods(const Array< MRecord > &ml)
void check(Workspace &ws_in, const Verbosity &verbosity)
Checks consistency of an agenda.
Definition: agenda_class.cc:90
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:78
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:80
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:85
String mname
Definition: agenda_class.h:103
void resize(Index n)
Resize the method list.
ArrayOfIndex moutput_push
Definition: agenda_class.h:106
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:69
ArrayOfIndex moutput_dup
Definition: agenda_class.h:108
bool is_main_agenda() const
Definition: agenda_class.h:84
Index nelem() const
Return the number of agenda elements.
This can be used to make arrays out of anything.
Definition: array.h:31
Method runtime data.
Definition: agenda_class.h:125
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
Definition: agenda_class.h:211
const ArrayOfIndex & In() const
Definition: agenda_class.h:142
ArrayOfIndex minput
Input workspace variables.
Definition: agenda_class.h:206
void set_workspace(Workspace &x)
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
const TokVal & SetValue() const
Definition: agenda_class.h:143
friend ostream & operator<<(ostream &os, const MRecord &a)
Output operator for MRecord.
const Agenda & Tasks() const
Definition: agenda_class.h:144
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:213
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:204
Index Id() const
Definition: agenda_class.h:140
Index mid
Method id.
Definition: agenda_class.h:202
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:157
const ArrayOfIndex & Out() const
Definition: agenda_class.h:141
MRecord(const MRecord &x)=default
TokVal msetvalue
Keyword value for Set methods.
Definition: agenda_class.h:208
Definition: tokval.h:244
Workspace class.
Definition: workspace_ng.h:36
void PrintWsvName(OutputStream &outstream, Index i) const
Print WSV name to output stream.
Definition: workspace_ng.h:193
Helper macros for debugging.
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.