ARTS  2.0.49
m_basic_types.h
Go to the documentation of this file.
1 /* Copyright (C) 2004-2008 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)
132 
133 NGET_GENERIC (ncols, Matrix)
134 NGET_GENERIC (ncols, Sparse)
135 NGET_GENERIC (ncols, Tensor3)
136 NGET_GENERIC (ncols, Tensor4)
137 NGET_GENERIC (ncols, Tensor5)
138 NGET_GENERIC (ncols, Tensor6)
139 NGET_GENERIC (ncols, Tensor7)
140 
141 NGET_GENERIC (nrows, Matrix)
142 NGET_GENERIC (nrows, Sparse)
143 NGET_GENERIC (nrows, Tensor3)
144 NGET_GENERIC (nrows, Tensor4)
145 NGET_GENERIC (nrows, Tensor5)
146 NGET_GENERIC (nrows, Tensor6)
147 NGET_GENERIC (nrows, Tensor7)
148 
149 NGET_GENERIC (npages, Tensor3)
150 NGET_GENERIC (npages, Tensor4)
151 NGET_GENERIC (npages, Tensor5)
152 NGET_GENERIC (npages, Tensor6)
153 NGET_GENERIC (npages, Tensor7)
154 
155 NGET_GENERIC (nbooks, Tensor4)
156 NGET_GENERIC (nbooks, Tensor5)
157 NGET_GENERIC (nbooks, Tensor6)
158 NGET_GENERIC (nbooks, Tensor7)
159 
160 NGET_GENERIC (nshelves, Tensor5)
161 NGET_GENERIC (nshelves, Tensor6)
162 NGET_GENERIC (nshelves, Tensor7)
163 
164 NGET_GENERIC (nvitrines, Tensor6)
165 NGET_GENERIC (nvitrines, Tensor7)
166 
167 NGET_GENERIC (nlibraries, Tensor7)
168 
169 // Undefine the macro to make sure that it is never used anywhere else
170 #undef NGET_GENERIC
171 
172 
173 
174 #endif /* M_BASIC_TYPES_H */
175 
Matrix
The Matrix class.
Definition: matpackI.h:767
gridded_fields.h
Implementation of gridded fields.
exceptions.h
The declarations of all the exception classes.
Tensor3
The Tensor3 class.
Definition: matpackIII.h:340
Sparse
The Sparse class.
Definition: matpackII.h:55
NGET_GENERIC
#define NGET_GENERIC(what, type)
Definition: m_basic_types.h:110
Tensor4
The Tensor4 class.
Definition: matpackIV.h:375
array.h
This file contains the definition of Array.
Array
This can be used to make arrays out of anything.
Definition: array.h:103
agenda_class.h
Declarations for agendas.
messages.h
Declarations having to do with the four output streams.
TMPL_NGET_AGENDA
#define TMPL_NGET_AGENDA(what)
Definition: m_basic_types.h:81
Tensor5
The Tensor5 class.
Definition: matpackV.h:443
workspace_ng.h
This file contains the declaration and partly the implementation of the workspace class.
matpackII.h
Header file for sparse matrices.
Tensor6
The Tensor6 class.
Definition: matpackVI.h:937
Vector
The Vector class.
Definition: matpackI.h:555
TMPL_NGET_GENERIC
#define TMPL_NGET_GENERIC(what)
Definition: m_basic_types.h:58
mystring.h
This file contains the definition of String, the ARTS string class.
Tensor7
The Tensor7 class.
Definition: matpackVII.h:1912
matpackVII.h
arts.h
The global header file for ARTS.