unsupported_extension_error.hpp 2.1 KB

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