context_error.hpp 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //---------------------------------------------------------------------------//
  2. // Copyright (c) 2013 Kyle Lutz <[email protected]>
  3. //
  4. // Distributed under the Boost Software License, Version 1.0
  5. // See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt
  7. //
  8. // See http://boostorg.github.com/compute for more information.
  9. //---------------------------------------------------------------------------//
  10. #ifndef BOOST_COMPUTE_EXCEPTION_CONTEXT_ERROR_HPP
  11. #define BOOST_COMPUTE_EXCEPTION_CONTEXT_ERROR_HPP
  12. #include <exception>
  13. namespace boost {
  14. namespace compute {
  15. class context;
  16. /// \class context_error
  17. /// \brief A run-time OpenCL context error.
  18. ///
  19. /// The context_error exception is thrown when the OpenCL context encounters
  20. /// an error condition. Boost.Compute is notified of these error conditions by
  21. /// registering an error handler when creating context objects (via the
  22. /// \c pfn_notify argument to the \c clCreateContext() function).
  23. ///
  24. /// This exception is different than the opencl_error exception which is thrown
  25. /// as a result of error caused when calling a single OpenCL API function.
  26. ///
  27. /// \see opencl_error
  28. class context_error : public std::exception
  29. {
  30. public:
  31. /// Creates a new context error exception object.
  32. context_error(const context *context,
  33. const char *errinfo,
  34. const void *private_info,
  35. size_t private_info_size) throw()
  36. : m_context(context),
  37. m_errinfo(errinfo),
  38. m_private_info(private_info),
  39. m_private_info_size(private_info_size)
  40. {
  41. }
  42. /// Destroys the context error object.
  43. ~context_error() throw()
  44. {
  45. }
  46. /// Returns a string with a description of the error.
  47. const char* what() const throw()
  48. {
  49. return m_errinfo;
  50. }
  51. /// Returns a pointer to the context object which generated the error
  52. /// notification.
  53. const context* get_context_ptr() const throw()
  54. {
  55. return m_context;
  56. }
  57. /// Returns a pointer to the private info memory block.
  58. const void* get_private_info_ptr() const throw()
  59. {
  60. return m_private_info;
  61. }
  62. /// Returns the size of the private info memory block.
  63. size_t get_private_info_size() const throw()
  64. {
  65. return m_private_info_size;
  66. }
  67. private:
  68. const context *m_context;
  69. const char *m_errinfo;
  70. const void *m_private_info;
  71. size_t m_private_info_size;
  72. };
  73. } // end compute namespace
  74. } // end boost namespace
  75. #endif // BOOST_COMPUTE_EXCEPTION_CONTEXT_ERROR_HPP