1 //---------------------------------------------------------------------------// 2 // Copyright (c) 2013 Kyle Lutz <kyle.r.lutz@gmail.com> 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 11 #ifndef BOOST_COMPUTE_EXCEPTION_CONTEXT_ERROR_HPP 12 #define BOOST_COMPUTE_EXCEPTION_CONTEXT_ERROR_HPP 13 14 #include <exception> 15 16 namespace boost { 17 namespace compute { 18 19 class context; 20 21 /// \class context_error 22 /// \brief A run-time OpenCL context error. 23 /// 24 /// The context_error exception is thrown when the OpenCL context encounters 25 /// an error condition. Boost.Compute is notified of these error conditions by 26 /// registering an error handler when creating context objects (via the 27 /// \c pfn_notify argument to the \c clCreateContext() function). 28 /// 29 /// This exception is different than the opencl_error exception which is thrown 30 /// as a result of error caused when calling a single OpenCL API function. 31 /// 32 /// \see opencl_error 33 class context_error : public std::exception 34 { 35 public: 36 /// Creates a new context error exception object. context_error(const context * context,const char * errinfo,const void * private_info,size_t private_info_size)37 context_error(const context *context, 38 const char *errinfo, 39 const void *private_info, 40 size_t private_info_size) throw() 41 : m_context(context), 42 m_errinfo(errinfo), 43 m_private_info(private_info), 44 m_private_info_size(private_info_size) 45 { 46 } 47 48 /// Destroys the context error object. ~context_error()49 ~context_error() throw() 50 { 51 } 52 53 /// Returns a string with a description of the error. what() const54 const char* what() const throw() 55 { 56 return m_errinfo; 57 } 58 59 /// Returns a pointer to the context object which generated the error 60 /// notification. get_context_ptr() const61 const context* get_context_ptr() const throw() 62 { 63 return m_context; 64 } 65 66 /// Returns a pointer to the private info memory block. get_private_info_ptr() const67 const void* get_private_info_ptr() const throw() 68 { 69 return m_private_info; 70 } 71 72 /// Returns the size of the private info memory block. get_private_info_size() const73 size_t get_private_info_size() const throw() 74 { 75 return m_private_info_size; 76 } 77 78 private: 79 const context *m_context; 80 const char *m_errinfo; 81 const void *m_private_info; 82 size_t m_private_info_size; 83 }; 84 85 } // end compute namespace 86 } // end boost namespace 87 88 #endif // BOOST_COMPUTE_EXCEPTION_CONTEXT_ERROR_HPP 89