• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //  Copyright David Abrahams 2001.
2 // Distributed under the Boost Software License, Version 1.0. (See
3 // accompanying file LICENSE_1_0.txt or copy at
4 // http://www.boost.org/LICENSE_1_0.txt)
5 #ifndef REGISTRY_DWA20011127_HPP
6 # define REGISTRY_DWA20011127_HPP
7 # include <boost/python/type_id.hpp>
8 # include <boost/python/converter/to_python_function_type.hpp>
9 # include <boost/python/converter/rvalue_from_python_data.hpp>
10 # include <boost/python/converter/constructor_function.hpp>
11 # include <boost/python/converter/convertible_function.hpp>
12 
13 namespace boost { namespace python { namespace converter {
14 
15 struct registration;
16 
17 // This namespace acts as a sort of singleton
18 namespace registry
19 {
20   // Get the registration corresponding to the type, creating it if necessary
21   BOOST_PYTHON_DECL registration const& lookup(type_info);
22 
23   // Get the registration corresponding to the type, creating it if
24   // necessary.  Use this first when the type is a shared_ptr.
25   BOOST_PYTHON_DECL registration const& lookup_shared_ptr(type_info);
26 
27   // Return a pointer to the corresponding registration, if one exists
28   BOOST_PYTHON_DECL registration const* query(type_info);
29 
30   BOOST_PYTHON_DECL void insert(to_python_function_t, type_info, PyTypeObject const* (*to_python_target_type)() = 0);
31 
32   // Insert an lvalue from_python converter
33   BOOST_PYTHON_DECL void insert(convertible_function, type_info, PyTypeObject const* (*expected_pytype)() = 0);
34 
35   // Insert an rvalue from_python converter
36   BOOST_PYTHON_DECL void insert(
37       convertible_function
38       , constructor_function
39       , type_info
40       , PyTypeObject const* (*expected_pytype)()  = 0
41       );
42 
43   // Insert an rvalue from_python converter at the tail of the
44   // chain. Used for implicit conversions
45   BOOST_PYTHON_DECL void push_back(
46       convertible_function
47       , constructor_function
48       , type_info
49       , PyTypeObject const* (*expected_pytype)()  = 0
50       );
51 }
52 
53 }}} // namespace boost::python::converter
54 
55 #endif // REGISTRY_DWA20011127_HPP
56