ARTS  2.4.0(git:4fb77825)
m_basic_types.h
Go to the documentation of this file.
1 /* Copyright (C) 2004-2012 Oliver Lemke <olemke@core-dump.info>
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 
27 #ifndef M_BASIC_TYPES_H
28 #define M_BASIC_TYPES_H
29 
30 #include <sstream>
31 
32 #include "agenda_class.h"
33 #include "array.h"
34 #include "arts.h"
35 #include "exceptions.h"
36 #include "gridded_fields.h"
37 #include "matpackII.h"
38 #include "matpackVII.h"
39 #include "messages.h"
40 #include "mystring.h"
41 #include "workspace_ng.h"
42 
43 /* To avoid redundant code preprocessor macros are used for code generation.
44  *
45  * Author: Oliver Lemke
46  * Date: 2004-09-20
47  */
48 
50 // The following template functions catch all calls to nelemGet,
51 // ncolsGet,etc. for data types (groups) which do not provide the
52 // requested attribute. A runtime error is thrown.
53 
54 #define TMPL_NGET_GENERIC(what) \
55  template <typename T> \
56  void what##Get(Index&, const T&, const Verbosity&) { \
57  ostringstream os; \
58  os << "The variable has no such attribute.\n"; \
59  throw runtime_error(os.str()); \
60  }
61 
70 
71 // Undefine the macro to make sure that it is never used anywhere else
72 #undef TMPL_NGET_GENERIC
73 
74 #define TMPL_NGET_AGENDA(what) \
75 inline void what##Get(Workspace& ws _U_, Index&, const Agenda&, const Verbosity&) { \
76  ostringstream os; \
77  os << "The variable has no such attribute.\n"; \
78  throw runtime_error(os.str()); \
79  }
80 
89 
90 // Undefine the macro to make sure that it is never used anywhere else
91 #undef TMPL_NGET_AGENDA
92 
93 template <typename T>
94 void IndexSetToLast(Index&, const T&, const Verbosity&) {
95  ostringstream os;
96  os << "The variable has no such attribute.\n";
97  throw runtime_error(os.str());
98 }
99 
101 // The following functions are special implementations of the template
102 // functions above. They set the corresponding workspace variable to the
103 // value of the requested attribute.
104 
105 #define NGET_GENERIC(what, type) \
106 inline void what##Get(Index& what, const type& x, const Verbosity&) { \
107  what = x.what(); \
108  }
109 
110 #define SET_TO_LAST_GENERIC(type) \
111 inline void IndexSetToLast(Index& i, const type& x, const Verbosity&) { \
112  i = x.nelem() - 1; \
113  }
114 
115 // If you add a group here, add it is also to SET_TO_LAST
151 
187 
195 
203 
209 
214 
218 
221 
223 
224 // Undefine the macros to make sure that it is never used anywhere else
225 #undef NGET_GENERIC
226 #undef SET_TO_LAST_GENERIC
227 
228 inline void nelemGet(Workspace& /* ws */,
229  Index& nelem,
230  const ArrayOfAgenda& x,
231  const Verbosity&) {
232  nelem = x.nelem();
233 }
234 
235 inline void IndexSetToLast(Workspace& /* ws */,
236  Index& nelem,
237  const ArrayOfAgenda& x,
238  const Verbosity&) {
239  nelem = x.nelem() - 1;
240 }
241 
242 #endif /* M_BASIC_TYPES_H */
Matrix
The Matrix class.
Definition: matpackI.h:1193
gridded_fields.h
Implementation of gridded fields.
ARTS::Var::nlibraries
Index nlibraries(Workspace &ws) noexcept
Definition: autoarts.h:4560
exceptions.h
The declarations of all the exception classes.
Tensor3
The Tensor3 class.
Definition: matpackIII.h:339
SET_TO_LAST_GENERIC
#define SET_TO_LAST_GENERIC(type)
Definition: m_basic_types.h:110
ARTS::Var::nvitrines
Index nvitrines(Workspace &ws) noexcept
Definition: autoarts.h:4696
Sparse
The Sparse class.
Definition: matpackII.h:60
NGET_GENERIC
#define NGET_GENERIC(what, type)
Definition: m_basic_types.h:105
ARTS::Var::nshelves
Index nshelves(Workspace &ws) noexcept
Definition: autoarts.h:4689
IndexSetToLast
void IndexSetToLast(Index &, const T &, const Verbosity &)
WORKSPACE METHOD: IndexSetToLast.
Definition: m_basic_types.h:94
Tensor4
The Tensor4 class.
Definition: matpackIV.h:421
array.h
This file contains the definition of Array.
Array
This can be used to make arrays out of anything.
Definition: array.h:108
Absorption::nelem
Index nelem(const Lines &l)
Number of lines.
Definition: absorptionlines.h:1820
agenda_class.h
Declarations for agendas.
messages.h
Declarations having to do with the four output streams.
nelemGet
void nelemGet(Workspace &, Index &nelem, const ArrayOfAgenda &x, const Verbosity &)
Definition: m_basic_types.h:228
Verbosity
Definition: messages.h:49
ARTS::Var::npages
Index npages(Workspace &ws) noexcept
Definition: autoarts.h:4675
TMPL_NGET_AGENDA
#define TMPL_NGET_AGENDA(what)
Definition: m_basic_types.h:74
Tensor5
The Tensor5 class.
Definition: matpackV.h:506
ARTS::Var::nrows
Index nrows(Workspace &ws) noexcept
Definition: autoarts.h:4682
workspace_ng.h
This file contains the Workspace class.
Workspace
Workspace class.
Definition: workspace_ng.h:40
matpackII.h
Header file for sparse matrices.
ARTS::Var::x
Vector x(Workspace &ws) noexcept
Definition: autoarts.h:7346
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Tensor6
The Tensor6 class.
Definition: matpackVI.h:1088
ARTS::Var::ncols
Index ncols(Workspace &ws) noexcept
Definition: autoarts.h:4546
Vector
The Vector class.
Definition: matpackI.h:860
TMPL_NGET_GENERIC
#define TMPL_NGET_GENERIC(what)
Definition: m_basic_types.h:54
ARTS::Var::nbooks
Index nbooks(Workspace &ws) noexcept
Definition: autoarts.h:4539
mystring.h
This file contains the definition of String, the ARTS string class.
Tensor7
The Tensor7 class.
Definition: matpackVII.h:2382
matpackVII.h
arts.h
The global header file for ARTS.