casacore
Loading...
Searching...
No Matches
PycRecord.h
Go to the documentation of this file.
1// # PycRecord.h: Class to convert a Record to/from Python
2// # Copyright (C) 2006
3// # Associated Universities, Inc. Washington DC, USA.
4// #
5// # This library is free software; you can redistribute it and/or modify it
6// # under the terms of the GNU Library General Public License as published by
7// # the Free Software Foundation; either version 2 of the License, or (at your
8// # option) any later version.
9// #
10// # This library is distributed in the hope that it will be useful, but WITHOUT
11// # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12// # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13// # License for more details.
14// #
15// # You should have received a copy of the GNU Library General Public License
16// # along with this library; if not, write to the Free Software Foundation,
17// # Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18// #
19// # Correspondence concerning AIPS++ should be addressed as follows:
20// # Internet email: casa-feedback@nrao.edu.
21// # Postal address: AIPS++ Project Office
22// # National Radio Astronomy Observatory
23// # 520 Edgemont Road
24// # Charlottesville, VA 22903-2475 USA
25
26#ifndef PYRAP_PYCRECORD_H
27#define PYRAP_PYCRECORD_H
28
29// # Includes
30// include first to avoid _POSIX_C_SOURCE redefined warnings
31#include <boost/python.hpp>
32#include <boost/python/dict.hpp>
33#include <casacore/casa/Containers/Record.h>
34
35namespace casacore {
36namespace python {
37
38// <summary>
39// A class to convert a (Table)Record to/from Python objects.
40// </summary>
41
42// <use visibility=export>
43// <reviewed reviewer="" date="" tests="">
44// </reviewed>
45
46// <synopsis>
47// </synopsis>
48
49// convert casacore::Record to PyDict
51 static boost::python::dict makeobject(Record const& rec);
52 static PyObject* convert(Record const& rec) {
53 return boost::python::incref(makeobject(rec).ptr());
54 }
55};
56
59 boost::python::converter::registry::push_back(&convertible, &construct,
60 boost::python::type_id<Record>());
61 }
62
63 // Check if it is a type we can convert.
64 static void* convertible(PyObject* obj_ptr);
65
66 // Constructs a Record from a Python object.
67 static void construct(PyObject* obj_ptr,
68 boost::python::converter::rvalue_from_python_stage1_data* data);
69
70 static Record makeRecord(PyObject* obj_ptr);
71};
72
73// Register the Record conversion.
75 static void reg();
76 static bool _done;
77};
79
80} // namespace python
81} // namespace casacore
82
83#endif
void register_convert_casa_record()
Definition PycRecord.h:78
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
static void * convertible(PyObject *obj_ptr)
Check if it is a type we can convert.
static Record makeRecord(PyObject *obj_ptr)
static void construct(PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
Constructs a Record from a Python object.
static boost::python::dict makeobject(Record const &rec)
static PyObject * convert(Record const &rec)
Definition PycRecord.h:52
Register the Record conversion.
Definition PycRecord.h:74