registry.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. namespace boost { namespace python { namespace converter {
  13. struct registration;
  14. // This namespace acts as a sort of singleton
  15. namespace registry
  16. {
  17. // Get the registration corresponding to the type, creating it if necessary
  18. BOOST_PYTHON_DECL registration const& lookup(type_info);
  19. // Get the registration corresponding to the type, creating it if
  20. // necessary. Use this first when the type is a shared_ptr.
  21. BOOST_PYTHON_DECL registration const& lookup_shared_ptr(type_info);
  22. // Return a pointer to the corresponding registration, if one exists
  23. BOOST_PYTHON_DECL registration const* query(type_info);
  24. BOOST_PYTHON_DECL void insert(to_python_function_t, type_info, PyTypeObject const* (*to_python_target_type)() = 0);
  25. // Insert an lvalue from_python converter
  26. BOOST_PYTHON_DECL void insert(convertible_function, type_info, PyTypeObject const* (*expected_pytype)() = 0);
  27. // Insert an rvalue from_python converter
  28. BOOST_PYTHON_DECL void insert(
  29. convertible_function
  30. , constructor_function
  31. , type_info
  32. , PyTypeObject const* (*expected_pytype)() = 0
  33. );
  34. // Insert an rvalue from_python converter at the tail of the
  35. // chain. Used for implicit conversions
  36. BOOST_PYTHON_DECL void push_back(
  37. convertible_function
  38. , constructor_function
  39. , type_info
  40. , PyTypeObject const* (*expected_pytype)() = 0
  41. );
  42. }
  43. }}} // namespace boost::python::converter
  44. #endif // REGISTRY_DWA20011127_HPP