source: trunk/src/python_SD.cc @ 95

Last change on this file since 95 was 95, checked in by mar637, 20 years ago

added exception handling

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 KB
Line 
1//#---------------------------------------------------------------------------
2//# python_SD.cc: python module for single dish package
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# Malte Marquarding, ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//#        Internet email: Malte.Marquarding@csiro.au
23//#        Postal address: Malte Marquarding,
24//#                        Australia Telescope National Facility,
25//#                        P.O. Box 76,
26//#                        Epping, NSW, 2121,
27//#                        AUSTRALIA
28//#
29//# $Id: python_SD.cc 95 2004-11-12 02:37:20Z mar637 $
30//#---------------------------------------------------------------------------
31#include <string>
32#include <vector>
33#include <boost/python.hpp>
34#include <boost/python/pyconversions.h>
35#include <boost/python/exception_translator.hpp>
36#include <casa/Exceptions.h>
37
38#include "python_SD.h"
39
40namespace asap {
41  namespace python {
42void translate_ex(AipsError const& e)
43{
44  // Use the Python 'C' API to set up an exception object
45  PyErr_SetString(PyExc_RuntimeError, e.what());
46}
47
48  }
49}
50using namespace boost::python;
51
52BOOST_PYTHON_MODULE(_asap) {
53  asap::python::python_SDMemTable();
54  asap::python::python_SDReader();
55  asap::python::python_SDWriter();
56  asap::python::python_SDMath();
57  asap::python::python_SDFitter();
58
59  register_exception_translator<AipsError>(&asap::python::translate_ex);
60
61  std_vector_to_tuple < int > ();
62  from_python_sequence < std::vector < int >,
63    variable_capacity_policy > ();
64  std_vector_to_tuple < float > ();
65  from_python_sequence < std::vector < float >,
66    variable_capacity_policy > ();
67  std_vector_to_tuple < double > ();
68  from_python_sequence < std::vector < double >,
69    variable_capacity_policy > ();
70  std_vector_to_tuple < std::string > ();
71  from_python_sequence < std::vector < std::string >,
72    variable_capacity_policy > ();
73  std_vector_to_tuple < bool> ();
74  from_python_sequence < std::vector < bool >,
75    variable_capacity_policy > ();
76}
Note: See TracBrowser for help on using the repository browser.