123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- #ifndef OBJECT_MANAGER_DWA2002614_HPP
- # define OBJECT_MANAGER_DWA2002614_HPP
- # include <boost/python/handle.hpp>
- # include <boost/python/cast.hpp>
- # include <boost/python/converter/pyobject_traits.hpp>
- # include <boost/python/detail/type_traits.hpp>
- # include <boost/mpl/if.hpp>
- # include <boost/python/detail/indirect_traits.hpp>
- # include <boost/mpl/bool.hpp>
- namespace boost { namespace python
- {
- namespace api
- {
- class object;
- }
- }}
- namespace boost { namespace python { namespace converter {
- template <class T>
- struct handle_object_manager_traits
- : pyobject_traits<typename T::element_type>
- {
- private:
- typedef pyobject_traits<typename T::element_type> base;
-
- public:
- BOOST_STATIC_CONSTANT(bool, is_specialized = true);
-
-
- static null_ok<typename T::element_type>* adopt(PyObject* p)
- {
- return python::allow_null(base::checked_downcast(p));
- }
- };
- template <class T>
- struct default_object_manager_traits
- {
- BOOST_STATIC_CONSTANT(
- bool, is_specialized = python::detail::is_borrowed_ptr<T>::value
- );
- };
- template <class T>
- struct object_manager_traits
- : mpl::if_c<
- is_handle<T>::value
- , handle_object_manager_traits<T>
- , default_object_manager_traits<T>
- >::type
- {
- };
- template <class T>
- struct is_object_manager
- : mpl::bool_<object_manager_traits<T>::is_specialized>
- {
- };
- template <class T>
- struct is_reference_to_object_manager
- : mpl::false_
- {
- };
- template <class T>
- struct is_reference_to_object_manager<T&>
- : is_object_manager<T>
- {
- };
- template <class T>
- struct is_reference_to_object_manager<T const&>
- : is_object_manager<T>
- {
- };
- template <class T>
- struct is_reference_to_object_manager<T volatile&>
- : is_object_manager<T>
- {
- };
- template <class T>
- struct is_reference_to_object_manager<T const volatile&>
- : is_object_manager<T>
- {
- };
- }}}
- #endif
|