1 //---------------------------------------------------------------------------// 2 // Copyright (c) 2013-2014 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_UNSUPPORTED_EXTENSION_ERROR_HPP 12 #define BOOST_COMPUTE_EXCEPTION_UNSUPPORTED_EXTENSION_ERROR_HPP 13 14 #include <exception> 15 #include <sstream> 16 #include <string> 17 18 namespace boost { 19 namespace compute { 20 21 /// \class unsupported_extension_error 22 /// \brief Exception thrown when attempting to use an unsupported 23 /// OpenCL extension. 24 /// 25 /// This exception is thrown when the user attempts to use an OpenCL 26 /// extension which is not supported on the platform and/or device. 27 /// 28 /// An example of this is attempting to use CL-GL sharing on a non-GPU 29 /// device. 30 /// 31 /// \see opencl_error 32 class unsupported_extension_error : public std::exception 33 { 34 public: 35 /// Creates a new unsupported extension error exception object indicating 36 /// that \p extension is not supported by the OpenCL platform or device. unsupported_extension_error(const char * extension)37 explicit unsupported_extension_error(const char *extension) throw() 38 : m_extension(extension) 39 { 40 std::stringstream msg; 41 msg << "OpenCL extension " << extension << " not supported"; 42 m_error_string = msg.str(); 43 } 44 45 /// Destroys the unsupported extension error object. ~unsupported_extension_error()46 ~unsupported_extension_error() throw() 47 { 48 } 49 50 /// Returns the name of the unsupported extension. extension_name() const51 std::string extension_name() const throw() 52 { 53 return m_extension; 54 } 55 56 /// Returns a string containing a human-readable error message containing 57 /// the name of the unsupported exception. what() const58 const char* what() const throw() 59 { 60 return m_error_string.c_str(); 61 } 62 63 private: 64 std::string m_extension; 65 std::string m_error_string; 66 }; 67 68 } // end compute namespace 69 } // end boost namespace 70 71 #endif // BOOST_COMPUTE_EXCEPTION_UNSUPPORTED_EXTENSION_ERROR_HPP 72