exception_handler.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright David Abrahams 2002.
  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 EXCEPTION_HANDLER_DWA2002810_HPP
  6. # define EXCEPTION_HANDLER_DWA2002810_HPP
  7. # include <boost/python/detail/config.hpp>
  8. # include <boost/function/function0.hpp>
  9. # include <boost/function/function2.hpp>
  10. namespace boost { namespace python { namespace detail {
  11. struct exception_handler;
  12. typedef function2<bool, exception_handler const&, function0<void> const&> handler_function;
  13. struct BOOST_PYTHON_DECL exception_handler
  14. {
  15. private: // types
  16. public:
  17. explicit exception_handler(handler_function const& impl);
  18. inline bool handle(function0<void> const& f) const;
  19. bool operator()(function0<void> const& f) const;
  20. static exception_handler* chain;
  21. private:
  22. static exception_handler* tail;
  23. handler_function m_impl;
  24. exception_handler* m_next;
  25. };
  26. inline bool exception_handler::handle(function0<void> const& f) const
  27. {
  28. return this->m_impl(*this, f);
  29. }
  30. BOOST_PYTHON_DECL void register_exception_handler(handler_function const& f);
  31. }}} // namespace boost::python::detail
  32. #endif // EXCEPTION_HANDLER_DWA2002810_HPP