RAVE
pyraveio.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2Copyright (C) 2009 Swedish Meteorological and Hydrological Institute, SMHI,
3
4This file is part of RAVE.
5
6RAVE is free software: you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11RAVE is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License
17along with RAVE. If not, see <http://www.gnu.org/licenses/>.
18------------------------------------------------------------------------*/
25#ifndef PYRAVEIO_H
26#define PYRAVEIO_H
27#include "rave_io.h"
28
32typedef struct {
33 PyObject_HEAD /* Always has to be on top */
35} PyRaveIO;
36
37#define PyRaveIO_Type_NUM 0
39#define PyRaveIO_GetNative_NUM 1
40#define PyRaveIO_GetNative_RETURN RaveIO_t*
41#define PyRaveIO_GetNative_PROTO (PyRaveIO*)
43#define PyRaveIO_New_NUM 2
44#define PyRaveIO_New_RETURN PyRaveIO*
45#define PyRaveIO_New_PROTO (RaveIO_t*)
47#define PyRaveIO_Open_NUM 3
48#define PyRaveIO_Open_RETURN PyRaveIO*
49#define PyRaveIO_Open_PROTO (const char* filename, int lazyLoading, const char* preloadQuantities)
52#define PyRaveIO_API_pointers 4
54#define PyRaveIO_CAPSULE_NAME "_raveio._C_API"
55
56#ifdef PYRAVEIO_MODULE
58extern PyTypeObject PyRaveIO_Type;
59
61#define PyRaveIO_Check(op) ((op)->ob_type == &PyRaveIO_Type)
62
65
68
71
72#else
74static void **PyRaveIO_API;
75
80#define PyRaveIO_GetNative \
81 (*(PyRaveIO_GetNative_RETURN (*)PyRaveIO_GetNative_PROTO) PyRaveIO_API[PyRaveIO_GetNative_NUM])
82
90#define PyRaveIO_New \
91 (*(PyRaveIO_New_RETURN (*)PyRaveIO_New_PROTO) PyRaveIO_API[PyRaveIO_New_NUM])
92
98#define PyRaveIO_Open \
99 (*(PyRaveIO_Open_RETURN (*)PyRaveIO_Open_PROTO) PyRaveIO_API[PyRaveIO_Open_NUM])
100
104#define PyRaveIO_Check(op) \
105 (Py_TYPE(op) == &PyRaveIO_Type)
106
107#define PyRaveIO_Type (*(PyTypeObject*)PyRaveIO_API[PyRaveIO_Type_NUM])
108
112#define import_pyraveio() \
113 PyRaveIO_API = (void **)PyCapsule_Import(PyRaveIO_CAPSULE_NAME, 1);
114
115
116#ifdef KALLE
120#define PyRaveIO_Check(op) \
121 ((op)->ob_type == (PyTypeObject *)PyRaveIO_API[PyRaveIO_Type_NUM])
122
126static int
127import_pyraveio(void)
128{
129 PyObject *module;
130 PyObject *c_api_object;
131
132 module = PyImport_ImportModule("_raveio");
133 if (module == NULL) {
134 return -1;
135 }
136
137 c_api_object = PyObject_GetAttrString(module, "_C_API");
138 if (c_api_object == NULL) {
139 Py_DECREF(module);
140 return -1;
141 }
142 if (PyCObject_Check(c_api_object)) {
143 PyRaveIO_API = (void **)PyCObject_AsVoidPtr(c_api_object);
144 }
145 Py_DECREF(c_api_object);
146 Py_DECREF(module);
147 return 0;
148}
149#endif
150
151#endif
152
153#endif /* PYRAVEIO_H */
#define PyRaveIO_New
Creates a new rave io instance.
Definition pyraveio.h:90
#define PyRaveIO_New_PROTO
argument prototype for New
Definition pyraveio.h:45
#define PyRaveIO_Open_RETURN
return type for Open
Definition pyraveio.h:48
#define PyRaveIO_GetNative_PROTO
argument prototype for GetNative
Definition pyraveio.h:41
#define import_pyraveio()
Imports the PyRaveIO module (like import _raveio in python).
Definition pyraveio.h:112
#define PyRaveIO_GetNative
Returns a pointer to the internal rave io, remember to release the reference when done with the objec...
Definition pyraveio.h:80
#define PyRaveIO_Open_PROTO
argument prototype for Open
Definition pyraveio.h:49
#define PyRaveIO_Open
Opens a rave io instance.
Definition pyraveio.h:98
#define PyRaveIO_New_RETURN
return type for New
Definition pyraveio.h:44
#define PyRaveIO_GetNative_RETURN
return type for GetNative
Definition pyraveio.h:40
Functions for performing rave related IO operations, mostly ODIM-formatted HDF5 files.
The RaveIO.
Definition pyraveio.h:32
PyObject_HEAD RaveIO_t * raveio
the raveio instance
Definition pyraveio.h:34
Defines the structure for the RaveIO in a volume.
Definition rave_io.c:58