casacore
Loading...
Searching...
No Matches
PycValueHolder.h
Go to the documentation of this file.
1//# PycValueHolder.h: Class to convert a ValueHolder 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
27#ifndef PYRAP_PYCVALUEHOLDER_H
28#define PYRAP_PYCVALUEHOLDER_H
29
30//# Includes
31
32// include first to avoid _POSIX_C_SOURCE redefined warnings
33#include <boost/python.hpp>
34#include <casacore/casa/Containers/ValueHolder.h>
35#include <casacore/casa/Utilities/DataType.h>
36
37namespace casacore { namespace python {
38
39
40 // <summary>
41 // A class to convert a ValueHolder to/from Python objects.
42 // </summary>
43
44 // <use visibility=export>
45 // <reviewed reviewer="" date="" tests="">
46 // </reviewed>
47
48 // <synopsis>
49 // </synopsis>
50
52 {
53 static boost::python::object makeobject (ValueHolder const&);
54 static PyObject* convert (ValueHolder const& c)
55 {
56 return boost::python::incref(makeobject(c).ptr());
57 }
58 };
59
61 {
63 {
64 boost::python::converter::registry::push_back(
66 &construct,
67 boost::python::type_id<ValueHolder>());
68 }
69
70 // Check if it is a type we can convert.
71 static void* convertible(PyObject* obj_ptr);
72
73 // Constructs a ValueHolder from a Python object.
74 static void construct(
75 PyObject* obj_ptr,
76 boost::python::converter::rvalue_from_python_stage1_data* data);
77
78 // Make a ValueHolder from all possible python data types.
79 static ValueHolder makeValueHolder (PyObject* obj_ptr);
80
81 // Make a vector from a python sequence.
82 static ValueHolder toVector (PyObject* obj_ptr);
83 // Get (and check) the data type in a python sequence.
84 static DataType checkDataType (PyObject* obj_ptr);
85 };
86
87
88 // Register the ValueHolder conversion.
90 {
91 static void reg();
92 static bool _done;
93 };
96
97}}
98
99#endif
void register_convert_casa_valueholder()
this file contains all the compiler specific defines
Definition mainpage.dox:28
static ValueHolder toVector(PyObject *obj_ptr)
Make a vector from a python sequence.
static ValueHolder makeValueHolder(PyObject *obj_ptr)
Make a ValueHolder from all possible python data types.
static void * convertible(PyObject *obj_ptr)
Check if it is a type we can convert.
static DataType checkDataType(PyObject *obj_ptr)
Get (and check) the data type in a python sequence.
static void construct(PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
Constructs a ValueHolder from a Python object.
static PyObject * convert(ValueHolder const &c)
static boost::python::object makeobject(ValueHolder const &)
Register the ValueHolder conversion.