ARTS 2.5.11 (git: 725533f0)
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.
This file contains the definition of Array.
The Agenda class.
bool mchecked
Flag indicating that the agenda was checked for consistency.
bool has_same_origin(const Workspace &ws2) const
void print(ostream &os, const String &indent) const
Print an agenda.
std::weak_ptr< Workspace > ws
const ArrayOfIndex & get_output2push() const
void append(const String &methodname, const TokVal &keywordvalue)
Appends methods to an agenda.
String name() const
Agenda name.
Array< MRecord > mml
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.
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
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()
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
String mname
void resize(Index n)
Resize the method list.
ArrayOfIndex moutput_push
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
ArrayOfIndex moutput_dup
bool is_main_agenda() const
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.
Agenda mtasks
An agenda, which can be given in the controlfile instead of keywords.
const ArrayOfIndex & In() const
ArrayOfIndex minput
Input workspace variables.
void set_workspace(Workspace &x)
MRecord & operator=(const MRecord &x)
Assignment operator for MRecord.
const TokVal & SetValue() const
friend ostream & operator<<(ostream &os, const MRecord &a)
Output operator for MRecord.
const Agenda & Tasks() const
void print(ostream &os, const String &indent) const
Print an MRecord.
bool minternal
Flag if this method is called internally by the engine.
MRecord deepcopy_if(Workspace &) const
Creates a deep copy of the method if necessary (i.e., different workspace)!
ArrayOfIndex moutput
Output workspace variables.
Index Id() const
Index mid
Method id.
void ginput_only(ArrayOfIndex &ginonly) const
Get list of generic input only WSVs.
bool isInternal() const
Indicates the origin of this method.
const ArrayOfIndex & Out() const
MRecord(const MRecord &x)=default
TokVal msetvalue
Keyword value for Set methods.
Workspace class.
void PrintWsvName(OutputStream &outstream, Index i) const
Print WSV name to output stream.
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.