diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-06-25 22:59:01 +0000 |
---|---|---|
committer | <> | 2013-09-27 11:49:28 +0000 |
commit | 8c4528713d907ee2cfd3bfcbbad272c749867f84 (patch) | |
tree | c09e2ce80f47b90c85cc720f5139089ad9c8cfff /libs/mpi/src/python/utility.hpp | |
download | boost-tarball-baserock/morph.tar.gz |
Imported from /home/lorry/working-area/delta_boost-tarball/boost_1_54_0.tar.bz2.boost_1_54_0baserock/morph
Diffstat (limited to 'libs/mpi/src/python/utility.hpp')
-rw-r--r-- | libs/mpi/src/python/utility.hpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libs/mpi/src/python/utility.hpp b/libs/mpi/src/python/utility.hpp new file mode 100644 index 000000000..ed0016761 --- /dev/null +++ b/libs/mpi/src/python/utility.hpp @@ -0,0 +1,43 @@ +// (C) Copyright 2006 Douglas Gregor <doug.gregor -at- gmail.com> + +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Authors: Douglas Gregor +#ifndef BOOST_MPI_PYTHON_UTILITY_HPP +#define BOOST_MPI_PYTHON_UTILITY_HPP + +/** @file utility.hpp + * + * This file is a utility header for the Boost.MPI Python bindings. + */ +#include <boost/python.hpp> + +namespace boost { namespace mpi { namespace python { + +template<typename E> +class translate_exception +{ + explicit translate_exception(boost::python::object type) : type(type) { } + +public: + static void declare(boost::python::object type) + { + using boost::python::register_exception_translator; + register_exception_translator<E>(translate_exception(type)); + } + + void operator()(const E& e) const + { + using boost::python::object; + PyErr_SetObject(type.ptr(), object(e).ptr()); + } + +private: + boost::python::object type; +}; + +} } } // end namespace boost::mpi::python + +#endif // BOOST_MPI_PYTHON_UTILITY_HPP |