ARTS  2.2.66
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 "array.h"
31 #include "arts.h"
32 #include "exceptions.h"
33 #include "matpackII.h"
34 #include "matpackVII.h"
35 #include "gridded_fields.h"
36 #include "mystring.h"
37 #include "messages.h"
38 #include "workspace_ng.h"
39 #include "agenda_class.h"
40 
41 #ifdef HAVE_SSTREAM
42 #include <sstream>
43 #else
44 #include "sstream.h"
45 #endif
46 
47 /* To avoid redundant code preprocessor macros are used for code generation.
48  *
49  * Author: Oliver Lemke
50  * Date: 2004-09-20
51  */
52 
54 // The following template functions catch all calls to nelemGet,
55 // ncolsGet,etc. for data types (groups) which do not provide the
56 // requested attribute. A runtime error is thrown.
57 
58 #define TMPL_NGET_GENERIC(what) \
59  template <typename T> \
60  void what##Get( Index&, \
61  const T&, \
62  const Verbosity&) \
63  { \
64  ostringstream os; \
65  os << "The variable has no such attribute.\n"; \
66  throw runtime_error(os.str()); \
67  }
68 
69 TMPL_NGET_GENERIC (nelem)
70 TMPL_NGET_GENERIC (ncols)
71 TMPL_NGET_GENERIC (nrows)
72 TMPL_NGET_GENERIC (npages)
73 TMPL_NGET_GENERIC (nbooks)
74 TMPL_NGET_GENERIC (nshelves)
75 TMPL_NGET_GENERIC (nvitrines)
76 TMPL_NGET_GENERIC (nlibraries)
77 
78 // Undefine the macro to make sure that it is never used anywhere else
79 #undef TMPL_NGET_GENERIC
80 
81 #define TMPL_NGET_AGENDA(what) \
82  void what##Get( Workspace& ws _U_, \
83  Index&, \
84  const Agenda&, \
85  const Verbosity&) \
86  { \
87  ostringstream os; \
88  os << "The variable has no such attribute.\n"; \
89  throw runtime_error(os.str()); \
90  }
91 
92 TMPL_NGET_AGENDA (nelem)
93 TMPL_NGET_AGENDA (ncols)
94 TMPL_NGET_AGENDA (nrows)
95 TMPL_NGET_AGENDA (npages)
96 TMPL_NGET_AGENDA (nbooks)
97 TMPL_NGET_AGENDA (nshelves)
98 TMPL_NGET_AGENDA (nvitrines)
99 TMPL_NGET_AGENDA (nlibraries)
100 
101 // Undefine the macro to make sure that it is never used anywhere else
102 #undef TMPL_NGET_AGENDA
103 
104 
106 // The following functions are special implementations of the template
107 // functions above. They set the corresponding workspace variable to the
108 // value of the requested attribute.
109 
110 #define NGET_GENERIC(what, type) \
111  void what##Get(Index& what, \
112  const type& x, \
113  const Verbosity&) \
114  { \
115  what = x.what (); \
116  }
117 
118 NGET_GENERIC (nelem, Vector)
119 NGET_GENERIC (nelem, ArrayOfIndex)
150 
151 NGET_GENERIC (ncols, Matrix)
152 NGET_GENERIC (ncols, Sparse)
153 NGET_GENERIC (ncols, Tensor3)
154 NGET_GENERIC (ncols, Tensor4)
155 NGET_GENERIC (ncols, Tensor5)
156 NGET_GENERIC (ncols, Tensor6)
157 NGET_GENERIC (ncols, Tensor7)
158 
159 NGET_GENERIC (nrows, Matrix)
160 NGET_GENERIC (nrows, Sparse)
161 NGET_GENERIC (nrows, Tensor3)
162 NGET_GENERIC (nrows, Tensor4)
163 NGET_GENERIC (nrows, Tensor5)
164 NGET_GENERIC (nrows, Tensor6)
165 NGET_GENERIC (nrows, Tensor7)
166 
167 NGET_GENERIC (npages, Tensor3)
168 NGET_GENERIC (npages, Tensor4)
169 NGET_GENERIC (npages, Tensor5)
170 NGET_GENERIC (npages, Tensor6)
171 NGET_GENERIC (npages, Tensor7)
172 
173 NGET_GENERIC (nbooks, Tensor4)
174 NGET_GENERIC (nbooks, Tensor5)
175 NGET_GENERIC (nbooks, Tensor6)
176 NGET_GENERIC (nbooks, Tensor7)
177 
178 NGET_GENERIC (nshelves, Tensor5)
179 NGET_GENERIC (nshelves, Tensor6)
180 NGET_GENERIC (nshelves, Tensor7)
181 
182 NGET_GENERIC (nvitrines, Tensor6)
183 NGET_GENERIC (nvitrines, Tensor7)
184 
185 NGET_GENERIC (nlibraries, Tensor7)
186 
187 // Undefine the macro to make sure that it is never used anywhere else
188 #undef NGET_GENERIC
189 
190 
191 
192 #endif /* M_BASIC_TYPES_H */
193 
#define NGET_GENERIC(what, type)
Declarations having to do with the four output streams.
The Vector class.
Definition: matpackI.h:556
#define TMPL_NGET_GENERIC(what)
Definition: m_basic_types.h:58
The Sparse class.
Definition: matpackII.h:55
The Tensor4 class.
Definition: matpackIV.h:383
The Tensor7 class.
Definition: matpackVII.h:1931
This file contains the definition of Array.
This file contains the declaration and partly the implementation of the workspace class...
The Tensor3 class.
Definition: matpackIII.h:348
The global header file for ARTS.
Header file for sparse matrices.
#define TMPL_NGET_AGENDA(what)
Definition: m_basic_types.h:81
Declarations for agendas.
The declarations of all the exception classes.
The Matrix class.
Definition: matpackI.h:788
This can be used to make arrays out of anything.
Definition: array.h:40
The Tensor6 class.
Definition: matpackVI.h:950
Implementation of gridded fields.
The Tensor5 class.
Definition: matpackV.h:451
This file contains the definition of String, the ARTS string class.