casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: aips2-request@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 //# $Id: PycRecord.h,v 1.2 2006/10/17 03:33:50 gvandiep Exp $
27 
28 
29 #ifndef PYRAP_PYCRECORD_H
30 #define PYRAP_PYCRECORD_H
31 
32 //# Includes
33 // include first to avoid _POSIX_C_SOURCE redefined warnings
34 #include <boost/python.hpp>
35 #include <boost/python/dict.hpp>
37 
38 namespace casacore { namespace python {
39 
40  // <summary>
41  // A class to convert a (Table)Record to/from Python objects.
42  // </summary>
43 
44  // <use visibility=export>
45  // <reviewed reviewer="" date="" tests="">
46  // </reviewed>
47 
48  // <synopsis>
49  // </synopsis>
50 
51  // convert casacore::Record to PyDict
53  {
54  static boost::python::dict makeobject (Record const& rec);
55  static PyObject* convert (Record const& rec)
56  {
57  return boost::python::incref(makeobject(rec).ptr());
58  }
59  };
60 
61 
63  {
65  {
66  boost::python::converter::registry::push_back(
67  &convertible,
68  &construct,
69  boost::python::type_id<Record>());
70  }
71 
72  // Check if it is a type we can convert.
73  static void* convertible(PyObject* obj_ptr);
74 
75  // Constructs a Record from a Python object.
76  static void construct(
77  PyObject* obj_ptr,
78  boost::python::converter::rvalue_from_python_stage1_data* data);
79 
80  static Record makeRecord (PyObject* obj_ptr);
81  };
82 
83 
84  // Register the Record conversion.
86  {
87  static void reg();
88  static bool _done;
89  };
92 
93 }}
94 
95 #endif
static PyObject * convert(Record const &rec)
Definition: PycRecord.h:55
static Record makeRecord(PyObject *obj_ptr)
ABSTRACT CLASSES Deliberately vague to be general enough to allow for many different types of data
Definition: PlotData.h:48
A hierarchical collection of named fields of various types.
Definition: Record.h:180
A class to convert a (Table)Record to/from Python objects.
Definition: PycRecord.h:52
static boost::python::dict makeobject(Record const &rec)
static void construct(PyObject *obj_ptr, boost::python::converter::rvalue_from_python_stage1_data *data)
Constructs a Record from a Python object.
void register_convert_casa_record()
Definition: PycRecord.h:90
static void * convertible(PyObject *obj_ptr)
Check if it is a type we can convert.
Register the Record conversion.
Definition: PycRecord.h:85
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42