ARTS  2.4.0(git:4fb77825)
interactive_workspace.h
Go to the documentation of this file.
1 /* Copyright (C) 2017 Simon Pfreundschuh <simon.pfreundschuh@chalmers.se>
2 
3  This program is free software; you can redistribute it and/or
4  modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation; either version 2 of the
6  License, or (at your option) any 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 
19 // File description
21 
29 #ifndef _ARTS_INTERACTIVE_WORKSPACE_H_
30 #define _ARTS_INTERACTIVE_WORKSPACE_H_
31 
32 #include "agenda_class.h"
33 #include "workspace_ng.h"
34 
35 extern void (*getaways[])(Workspace &, const MRecord &);
36 
38 
50 class Callback {
51  public:
58  : callback_(f){
59  // Nothing to do here.
60  };
61 
62  Callback(const Callback &) = default;
63  Callback(Callback &&) = default;
64  Callback &operator=(const Callback &) = default;
65  Callback &operator=(Callback &&) = default;
66  ~Callback() = default;
67 
73  virtual void execute(InteractiveWorkspace &ws) {(*callback_)(&ws);};
74 
75  private:
77 };
78 
85  public:
87  const Index agenda_verbosity = 0);
88 
90  using Workspace::operator[];
91 
98  static void initialize();
99 
108  const char *execute_agenda(const Agenda *a);
109 
122  const char *execute_workspace_method(long id,
123  const ArrayOfIndex &output,
124  const ArrayOfIndex &input);
125 
137  void set_agenda_variable(Index id, const Agenda &src);
143  void set_index_variable(Index id, const Index &src);
149  void set_array_of_index_variable(Index id, size_t n, const Index *src);
155  void set_numeric_variable(Index id, const Numeric &src);
162  void set_string_variable(Index id, const char *src);
169  void set_array_of_string_variable(Index id, size_t n, const char *const *src);
176  void set_vector_variable(Index id, size_t n, const Numeric *src);
183  void set_matrix_variable(Index id, size_t m, size_t n, const Numeric *src);
191  Index id, size_t l, size_t m, size_t n, const Numeric *src);
199  Index id, size_t k, size_t l, size_t m, size_t n, const Numeric *src);
206  void set_tensor5_variable(Index id,
207  size_t k,
208  size_t l,
209  size_t m,
210  size_t n,
211  size_t o,
212  const Numeric *src);
219  void set_tensor6_variable(Index id,
220  size_t k,
221  size_t l,
222  size_t m,
223  size_t n,
224  size_t o,
225  size_t p,
226  const Numeric *src);
233  void set_tensor7_variable(Index id,
234  size_t k,
235  size_t l,
236  size_t m,
237  size_t n,
238  size_t o,
239  size_t p,
240  size_t q,
241  const Numeric *src);
257  void set_sparse_variable(Index id,
258  Index m,
259  Index n,
260  Index nnz,
261  const Numeric *src,
262  const int *row_indices,
263  const int *column_indices);
264 
265  void execute_callback(Index callback_id) {
266  callbacks_[callback_id]->execute(*this);
267  }
268 
281  Index id = callbacks_.size();
282  callbacks_.push_back(cb);
283  return id;
284  }
285 
287 
293  void initialize_variable(Index id);
294 
296 
304  Index add_variable(Index group_id, const char *name);
305 
307 
314  void erase_variable(Index i, Index group_id);
315 
317 
323  void swap(Index i, Index j);
324 
325  private:
326 
332  void resize();
333 
334  static size_t n_anonymous_variables_;
335  static std::vector<Callback *> callbacks_;
336 };
337 
338 #endif // _ARTS_INTERACTIVE_WORKSPACE_H_
InteractiveWorkspace::set_string_variable
void set_string_variable(Index id, const char *src)
Deep-copy of String variable into workspace.
Definition: interactive_workspace.cc:182
InteractiveWorkspace::execute_agenda
const char * execute_agenda(const Agenda *a)
Execute agenda.
Definition: interactive_workspace.cc:100
Callback::callback_
void(* callback_)(InteractiveWorkspace *)
Definition: interactive_workspace.h:76
Callback::operator=
Callback & operator=(Callback &&)=default
ARTS::Var::verbosity
Verbosity verbosity(Workspace &ws) noexcept
Definition: autoarts.h:7112
InteractiveWorkspace::initialize_variable
void initialize_variable(Index id)
Initialize workspace variable.
Definition: interactive_workspace.cc:317
MRecord
Method runtime data.
Definition: agenda_class.h:121
Callback::execute
virtual void execute(InteractiveWorkspace &ws)
Execute callback.
Definition: interactive_workspace.h:73
InteractiveWorkspace::set_tensor7_variable
void set_tensor7_variable(Index id, size_t k, size_t l, size_t m, size_t n, size_t o, size_t p, size_t q, const Numeric *src)
Deep-copy of Tensor5 variable into workspace.
Definition: interactive_workspace.cc:273
InteractiveWorkspace::set_agenda_variable
void set_agenda_variable(Index id, const Agenda &src)
Set agenda variable into workspace.
Definition: interactive_workspace.cc:163
Agenda
The Agenda class.
Definition: agenda_class.h:44
InteractiveWorkspace::set_matrix_variable
void set_matrix_variable(Index id, size_t m, size_t n, const Numeric *src)
Deep-copy of Matrix variable into workspace.
Definition: interactive_workspace.cc:215
InteractiveWorkspace::resize
void resize()
Resize workspace stack.
Definition: interactive_workspace.cc:311
InteractiveWorkspace::n_anonymous_variables_
static size_t n_anonymous_variables_
Definition: interactive_workspace.h:334
InteractiveWorkspace::set_index_variable
void set_index_variable(Index id, const Index &src)
Deep-copy of Index variable into workspace.
Definition: interactive_workspace.cc:174
Array< Index >
InteractiveWorkspace::set_vector_variable
void set_vector_variable(Index id, size_t n, const Numeric *src)
Deep-copy of Vector variable into workspace.
Definition: interactive_workspace.cc:205
agenda_class.h
Declarations for agendas.
Callback::Callback
Callback(Callback &&)=default
InteractiveWorkspace::InteractiveWorkspace
InteractiveWorkspace(const Index verbosity=1, const Index agenda_verbosity=0)
Definition: interactive_workspace.cc:56
InteractiveWorkspace::initialize
static void initialize()
Workspace intialization.
Definition: interactive_workspace.cc:79
InteractiveWorkspace::set_array_of_index_variable
void set_array_of_index_variable(Index id, size_t n, const Index *src)
Deep-copy of ArrayOfIndex variable into workspace.
Definition: interactive_workspace.cc:195
Callback::operator=
Callback & operator=(const Callback &)=default
InteractiveWorkspace::set_tensor5_variable
void set_tensor5_variable(Index id, size_t k, size_t l, size_t m, size_t n, size_t o, const Numeric *src)
Deep-copy of Tensor5 variable into workspace.
Definition: interactive_workspace.cc:244
InteractiveWorkspace::set_numeric_variable
void set_numeric_variable(Index id, const Numeric &src)
Deep-copy of Numeric variable into workspace.
Definition: interactive_workspace.cc:178
Numeric
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
InteractiveWorkspace::set_tensor3_variable
void set_tensor3_variable(Index id, size_t l, size_t m, size_t n, const Numeric *src)
Deep-copy of Tensor3 variable into workspace.
Definition: interactive_workspace.cc:226
InteractiveWorkspace::set_sparse_variable
void set_sparse_variable(Index id, Index m, Index n, Index nnz, const Numeric *src, const int *row_indices, const int *column_indices)
Deep-copy of Sparse matrix into workspace.
Definition: interactive_workspace.cc:289
Callback
External callbacks.
Definition: interactive_workspace.h:50
InteractiveWorkspace::set_tensor6_variable
void set_tensor6_variable(Index id, size_t k, size_t l, size_t m, size_t n, size_t o, size_t p, const Numeric *src)
Deep-copy of Tensor6 variable into workspace.
Definition: interactive_workspace.cc:258
InteractiveWorkspace::callbacks_
static std::vector< Callback * > callbacks_
Definition: interactive_workspace.h:335
InteractiveWorkspace::execute_workspace_method
const char * execute_workspace_method(long id, const ArrayOfIndex &output, const ArrayOfIndex &input)
Execute workspace method.
Definition: interactive_workspace.cc:115
q
#define q
Definition: legacy_continua.cc:21712
InteractiveWorkspace::set_tensor4_variable
void set_tensor4_variable(Index id, size_t k, size_t l, size_t m, size_t n, const Numeric *src)
Deep-copy of Tensor4 variable into workspace.
Definition: interactive_workspace.cc:235
InteractiveWorkspace::add_callback
static Index add_callback(Callback *cb)
Add callback to workspace.
Definition: interactive_workspace.h:280
InteractiveWorkspace::set_array_of_string_variable
void set_array_of_string_variable(Index id, size_t n, const char *const *src)
Deep-copy of ArrayOfString variable into workspace.
Definition: interactive_workspace.cc:186
workspace_ng.h
This file contains the Workspace class.
InteractiveWorkspace::erase_variable
void erase_variable(Index i, Index group_id)
Remove a variable stack from the workspace.
Definition: interactive_workspace.cc:353
Workspace
Workspace class.
Definition: workspace_ng.h:40
getaways
void(* getaways[])(Workspace &, const MRecord &)
Definition: auto_md.cc:21496
Workspace::is_initialized
bool is_initialized(Index i)
Checks existence of the given WSV.
Definition: workspace_ng.h:118
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Callback::Callback
Callback(void(*f)(InteractiveWorkspace *))
Create callback.
Definition: interactive_workspace.h:57
Callback::Callback
Callback(const Callback &)=default
InteractiveWorkspace::swap
void swap(Index i, Index j)
Remove a variable stack from the workspace.
Definition: interactive_workspace.cc:370
InteractiveWorkspace::add_variable
Index add_variable(Index group_id, const char *name)
Push a stack for a new variable to the workspace.
Definition: interactive_workspace.cc:323
InteractiveWorkspace
Interactive ARTS workspace.
Definition: interactive_workspace.h:84
InteractiveWorkspace::execute_callback
void execute_callback(Index callback_id)
Definition: interactive_workspace.h:265
Callback::~Callback
~Callback()=default