ARTS  2.3.1285(git:92a29ea9-dirty)
arts_api.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_ARTS_API_H_
30 #define _ARTS_ARTS_API_H_
31 
32 #define DLL_PUBLIC __attribute__((visibility("default")))
33 
34 #include "covariance_matrix.h"
35 #include "interactive_workspace.h"
36 
37 extern "C" {
38 
40 // Structs Definitions
42 
46  const char *name;
48  const char *description;
50  long group;
51 };
52 
64  const void *ptr;
78  long dimensions[7];
84  const int *inner_ptr;
90  const int *outer_ptr;
91 };
92 
97 struct MethodStruct {
99  long id;
105  const char *name;
111  const char *description;
116  unsigned long n_out;
121  const long *out;
126  unsigned long n_g_out;
132  const long *g_out_types;
137  unsigned long n_in;
142  const long *in;
147  unsigned long n_g_in;
153  const long *g_in_types;
154 };
155 
159  long major;
161  long minor;
163  long revision;
164 };
165 
166 
178  long indices[2];
179 
185  long position[2];
186 
191  long dimensions[2];
192 
200  const void *ptr;
201 
207  long nnz;
208 
215  const int *inner_ptr;
222  const int *outer_ptr;
223 };
224 
226 // Setup and Finalization.
228 
237 void include_path_push(const char *path);
238 
245 void include_path_pop();
246 
255 void data_path_push(const char *path);
256 
263 void data_path_pop();
264 
271 void initialize();
272 
278 void finalize();
279 
285 const char *get_error();
286 
293 void set_basename(const char *name);
294 
296 // Parsing and executing agendas.
298 
313 Agenda *parse_agenda(const char *filename);
314 
323 Agenda *create_agenda(const char *name);
324 
336 void agenda_add_method(Agenda *a,
337  const Index id,
338  unsigned long n_args_out,
339  const long *args_out,
340  unsigned long n_args_in,
341  const long *args_in);
342 
348 void agenda_insert_callback(Agenda *a, void (*f)(InteractiveWorkspace *));
349 
363  Agenda *a,
364  long id,
365  long group_id);
366 
376 void agenda_append(Agenda *dst, const Agenda *src);
377 
384 void agenda_clear(Agenda *a);
385 
396 const char *execute_agenda(InteractiveWorkspace *workspace, const Agenda *a);
397 
403 void destroy_agenda(Agenda *a);
404 
406 // Creating Workspaces
408 
414 InteractiveWorkspace *create_workspace(const Index verbosity = 1,
415  const Index agenda_verbosity = 0);
416 
419 void destroy_workspace(InteractiveWorkspace *workspace);
420 
422 // Accessing WSV Group Information
424 
427 unsigned long get_number_of_groups();
428 
431 const char *get_group_name(int i);
432 
434 // Accessing and Executing WSMs
436 
439 unsigned long get_number_of_methods();
440 
444 
453 const char *get_method_g_in(Index i, Index j);
454 
462 const char *get_method_g_in_default(Index i, Index j);
463 
468 const char *get_g_in_nodef() {
469  return NODEF;
470 }
471 
480 const char *get_method_g_out(Index i, Index j);
481 
496 const char *execute_workspace_method(InteractiveWorkspace *workspace,
497  long id,
498  unsigned long n_args_out,
499  const long *args_out,
500  unsigned long n_args_in,
501  const long *args_in);
502 
513 const char *method_print_doc(long id);
514 
516 // Accessing and Manipulating WSVs
518 
525 long lookup_workspace_variable(const char *s);
526 
529 unsigned long get_number_of_variables();
530 
538 
548  Index id,
549  Index group_id);
550 
561  Index id);
562 
577  long block_index,
578  bool inverse);
579 
610 const char *set_variable_value(InteractiveWorkspace *workspace,
611  long id,
612  long group_id,
613  VariableValueStruct value);
627 long add_variable(InteractiveWorkspace *workspace,
628  long group_id,
629  const char *name);
630 
642 void erase_variable(InteractiveWorkspace *workspace, long id, long group_id);
643 
653 }
654 
655 #endif // _ARTS_ARTS_API_
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
DLL_PUBLIC void data_path_pop()
Remove last data path.
Definition: arts_api.cc:58
DLL_PUBLIC MethodStruct get_method(Index i)
Return MethodStruct describing method with index i.
Definition: arts_api.cc:211
DLL_PUBLIC void destroy_workspace(InteractiveWorkspace *workspace)
Destroy given workspace.
Definition: arts_api.cc:196
DLL_PUBLIC VariableStruct get_variable(Index i)
Get WSV by index.
Definition: arts_api.cc:295
DLL_PUBLIC unsigned long get_number_of_variables()
Number of defined WSVs.
Definition: arts_api.cc:293
DLL_PUBLIC Agenda * create_agenda(const char *name)
Create Agenda.
Definition: arts_api.cc:88
The Agenda class.
Definition: agenda_class.h:44
DLL_PUBLIC void agenda_add_method(Agenda *a, const Index id, unsigned long n_args_out, const long *args_out, unsigned long n_args_in, const long *args_in)
Add method to agenda.
This file contains all declarations of the ARTS C API.
const char * name
Pointer to the c_str of the name of the variable.
Definition: arts_api.h:46
DLL_PUBLIC void agenda_insert_set(InteractiveWorkspace *ws, Agenda *a, long id, long group_id)
Insert a set method into an agenda.
Definition: arts_api.cc:94
const long * g_out_types
Generic output types.
Definition: arts_api.h:132
const long * g_in_types
Generic input types.
Definition: arts_api.h:153
DLL_PUBLIC VersionStruct get_version()
Get ARTS Version.
Definition: arts_api.cc:649
const int * inner_ptr
Additional array data for sparse matrices.
Definition: arts_api.h:84
const char * name
Method name.
Definition: arts_api.h:105
const int * inner_ptr
Inner pointer for sparse matrices.
Definition: arts_api.h:215
long id
The WSMs index in md_data.
Definition: arts_api.h:99
unsigned long n_g_out
Number of generic output variables.
Definition: arts_api.h:126
bool initialized
Initialization status.
Definition: arts_api.h:69
Covariance matrix block.
Definition: arts_api.h:172
DLL_PUBLIC const char * set_variable_value(InteractiveWorkspace *workspace, long id, long group_id, VariableValueStruct value)
Sets the value of a WSV in a given workspace.
Definition: arts_api.cc:512
DLL_PUBLIC InteractiveWorkspace * create_workspace(const Index verbosity=1, const Index agenda_verbosity=0)
Create new workspace.
Definition: arts_api.cc:191
DLL_PUBLIC void data_path_push(const char *path)
Add data path.
Definition: arts_api.cc:56
const void * ptr
Data pointer.
Definition: arts_api.h:64
Header files of CovarianceMatrix class.
#define NODEF
Definition: methods.h:35
DLL_PUBLIC const char * execute_agenda(InteractiveWorkspace *workspace, const Agenda *a)
Execute Agenda.
Definition: arts_api.cc:180
const void * ptr
Element pointer.
Definition: arts_api.h:200
#define DLL_PUBLIC
Definition: arts_api.h:32
DLL_PUBLIC VariableValueStruct get_variable_value(InteractiveWorkspace *workspace, Index id, Index group_id)
Get value WSV in given workspace.
Definition: arts_api.cc:300
DLL_PUBLIC unsigned long get_number_of_methods()
Return number of WSMs.
Definition: arts_api.cc:209
DLL_PUBLIC const char * get_method_g_out(Index i, Index j)
Get name value of generic output argument.
Definition: arts_api.cc:258
DLL_PUBLIC void include_path_push(const char *path)
Add include path.
Definition: arts_api.cc:50
DLL_PUBLIC void destroy_agenda(Agenda *a)
Destroy Agenda.
Definition: arts_api.cc:186
unsigned long n_g_in
Number of generic input variables.
Definition: arts_api.h:147
Representation of workspace methods.
Definition: arts_api.h:97
Representation of ARTS WSVs.
Definition: arts_api.h:44
DLL_PUBLIC long lookup_workspace_variable(const char *s)
Lookup workspace variable by name.
Definition: arts_api.cc:285
DLL_PUBLIC CovarianceMatrixBlockStruct get_covariance_matrix_block(CovarianceMatrix *m, long block_index, bool inverse)
Return block of covariance matrix.
Definition: arts_api.cc:467
const int * outer_ptr
Outer pointer for sparse matrices.
Definition: arts_api.h:222
ARTS version.
Definition: arts_api.h:157
const long * out
Output variables.
Definition: arts_api.h:121
Interactive ARTS workspace.
DLL_PUBLIC void finalize()
Finalize ARTS runtime.
Definition: arts_api.cc:62
DLL_PUBLIC void set_basename(const char *name)
Set the ARTS basename.
Definition: arts_api.cc:68
DLL_PUBLIC const char * get_method_g_in_default(Index i, Index j)
Get default value of generic input argument.
Definition: arts_api.cc:250
long minor
Minor version number of this ARTS major version.
Definition: arts_api.h:161
Representation of ARTS values.
Definition: arts_api.h:58
DLL_PUBLIC long add_variable(InteractiveWorkspace *workspace, long group_id, const char *name)
Add variable of given type to workspace.
Definition: arts_api.cc:637
long group
The Index value representing the group this variable belongs to.
Definition: arts_api.h:50
DLL_PUBLIC unsigned long get_number_of_groups()
Return number of WSV groups.
Definition: arts_api.cc:202
DLL_PUBLIC Agenda * parse_agenda(const char *filename)
Parse Controlfile.
Definition: arts_api.cc:73
const char * description
Pointer to the c_str of the description of the variable.
Definition: arts_api.h:48
const int * outer_ptr
Additional array data for sparse matrices.
Definition: arts_api.h:90
unsigned long n_out
Number of non-generic output variables.
Definition: arts_api.h:116
DLL_PUBLIC const char * get_method_g_in(Index i, Index j)
Get name of generic input argument.
Definition: arts_api.cc:246
DLL_PUBLIC const char * get_error()
Get most recent error.
Definition: arts_api.cc:66
DLL_PUBLIC void erase_variable(InteractiveWorkspace *workspace, long id, long group_id)
Erase variable from workspace.
Definition: arts_api.cc:644
unsigned long n_in
Number of non-generic input variables.
Definition: arts_api.h:137
long revision
Revision number.
Definition: arts_api.h:163
const char * description
Method description.
Definition: arts_api.h:111
DLL_PUBLIC const char * method_print_doc(long id)
Print method documentation.
Definition: arts_api.cc:274
DLL_PUBLIC void initialize()
Initalize ARTS runtime.
Definition: arts_api.cc:60
DLL_PUBLIC void agenda_append(Agenda *dst, const Agenda *src)
Append agendas.
Definition: arts_api.cc:171
DLL_PUBLIC void agenda_clear(Agenda *a)
Clear Agenda.
Definition: arts_api.cc:178
long nnz
Number of non-zero elements.
Definition: arts_api.h:207
DLL_PUBLIC void include_path_pop()
Remove last include path.
Definition: arts_api.cc:54
DLL_PUBLIC void * get_variable_data_pointer(InteractiveWorkspace *workspace, Index id)
Get data pointer to the WSV variable.
Definition: arts_api.cc:463
const long * in
Input variables.
Definition: arts_api.h:142
DLL_PUBLIC const char * execute_workspace_method(InteractiveWorkspace *workspace, long id, unsigned long n_args_out, const long *args_out, unsigned long n_args_in, const long *args_in)
Execute workspace method.
Definition: arts_api.cc:262
DLL_PUBLIC void agenda_insert_callback(Agenda *a, void(*f)(InteractiveWorkspace *))
Insert callback into agenda.
Definition: arts_api.cc:149
DLL_PUBLIC const char * get_group_name(int i)
Get pointer to name of given group.
Definition: arts_api.cc:204
DLL_PUBLIC const char * get_g_in_nodef()
Get string defining missing default parameter.
Definition: arts_api.h:468
long major
Major version number of ARTS.
Definition: arts_api.h:159