Chris@16: // Copyright (C) 2006 Douglas Gregor Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // Authors: Douglas Gregor Chris@16: #ifndef BOOST_MPI_PYTHON_HPP Chris@16: #define BOOST_MPI_PYTHON_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: /** @file python.hpp Chris@16: * Chris@16: * This header interacts with the Python bindings for Boost.MPI. The Chris@16: * routines in this header can be used to register user-defined and Chris@16: * library-defined data types with Boost.MPI for efficient Chris@16: * (de-)serialization and separate transmission of skeletons and Chris@16: * content. Chris@16: * Chris@16: */ Chris@16: Chris@16: namespace boost { namespace mpi { namespace python { Chris@16: Chris@16: /** Chris@16: * @brief Register the type T for direct serialization within Boost.MPI Chris@16: * Chris@16: * The @c register_serialized function registers a C++ type for direct Chris@16: * serialization within Boost.MPI. Direct serialization elides the use Chris@16: * of the Python @c pickle package when serializing Python objects Chris@16: * that represent C++ values. Direct serialization can be beneficial Chris@16: * both to improve serialization performance (Python pickling can be Chris@16: * very inefficient) and to permit serialization for Python-wrapped Chris@16: * C++ objects that do not support pickling. Chris@16: * Chris@16: * @param value A sample value of the type @c T. This may be used Chris@16: * to compute the Python type associated with the C++ type @c T. Chris@16: * Chris@16: * @param type The Python type associated with the C++ type @c Chris@16: * T. If not provided, it will be computed from the same value @p Chris@16: * value. Chris@16: */ Chris@16: template Chris@16: void Chris@16: register_serialized(const T& value = T(), PyTypeObject* type = 0); Chris@16: Chris@16: /** Chris@16: * @brief Registers a type for use with the skeleton/content mechanism Chris@16: * in Python. Chris@16: * Chris@16: * The skeleton/content mechanism can only be used from Python with Chris@16: * C++ types that have previously been registered via a call to this Chris@16: * function. Both the sender and the transmitter must register the Chris@16: * type. It is permitted to call this function multiple times for the Chris@16: * same type @c T, but only one call per process per type is Chris@16: * required. The type @c T must be Serializable. Chris@16: * Chris@16: * @param value A sample object of type T that will be used to Chris@16: * determine the Python type associated with T, if @p type is not Chris@16: * specified. Chris@16: * Chris@16: * @param type The Python type associated with the C++ type @c Chris@16: * T. If not provided, it will be computed from the same value @p Chris@16: * value. Chris@16: */ Chris@16: template Chris@16: void Chris@16: register_skeleton_and_content(const T& value = T(), PyTypeObject* type = 0); Chris@16: Chris@16: } } } // end namespace boost::mpi::python Chris@16: Chris@16: #ifndef BOOST_MPI_PYTHON_FORWARD_ONLY Chris@16: # include Chris@16: # include Chris@16: #else Chris@16: # undef BOOST_MPI_PYTHON_FORWARD_ONLY Chris@16: #endif Chris@16: Chris@16: #endif // BOOST_MPI_PYTHON_HPP