get_read_device.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Copyright 2012 Christian Henning
  3. Use, modification and distribution are subject to the Boost Software License,
  4. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. */
  7. /*************************************************************************************************/
  8. #ifndef BOOST_GIL_IO_GET_READ_DEVICE_HPP
  9. #define BOOST_GIL_IO_GET_READ_DEVICE_HPP
  10. ////////////////////////////////////////////////////////////////////////////////////////
  11. /// \file
  12. /// \brief
  13. /// \author Christian Henning \n
  14. ///
  15. /// \date 2012 \n
  16. ///
  17. ////////////////////////////////////////////////////////////////////////////////////////
  18. #include <boost/mpl/and.hpp>
  19. #include <boost/utility/enable_if.hpp>
  20. #include <boost/gil/io/device.hpp>
  21. #include <boost/gil/io/path_spec.hpp>
  22. namespace boost { namespace gil {
  23. template< typename T
  24. , typename FormatTag
  25. , class Enable = void
  26. >
  27. struct get_read_device
  28. {};
  29. template< typename Device
  30. , typename FormatTag
  31. >
  32. struct get_read_device< Device
  33. , FormatTag
  34. , typename enable_if< mpl::and_< detail::is_adaptable_input_device< FormatTag
  35. , Device
  36. >
  37. , is_format_tag< FormatTag >
  38. >
  39. >::type
  40. >
  41. {
  42. typedef typename detail::is_adaptable_input_device< FormatTag
  43. , Device
  44. >::device_type type;
  45. };
  46. template< typename String
  47. , typename FormatTag
  48. >
  49. struct get_read_device< String
  50. , FormatTag
  51. , typename enable_if< mpl::and_< detail::is_supported_path_spec< String >
  52. , is_format_tag< FormatTag >
  53. >
  54. >::type
  55. >
  56. {
  57. typedef detail::file_stream_device< FormatTag > type;
  58. };
  59. } // namespace gil
  60. } // namespace boost
  61. #endif