get_reader.hpp 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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_READER_HPP
  9. #define BOOST_GIL_IO_GET_READER_HPP
  10. ////////////////////////////////////////////////////////////////////////////////////////
  11. /// \file
  12. /// \brief
  13. /// \author Christian Henning \n
  14. ///
  15. /// \date 2012 \n
  16. ///
  17. ////////////////////////////////////////////////////////////////////////////////////////
  18. #include "get_read_device.hpp"
  19. namespace boost { namespace gil {
  20. /// \brief Helper metafunction to generate image reader type.
  21. template< typename T
  22. , typename FormatTag
  23. , typename ConversionPolicy
  24. , class Enable = void
  25. >
  26. struct get_reader
  27. {};
  28. template< typename String
  29. , typename FormatTag
  30. , typename ConversionPolicy
  31. >
  32. struct get_reader< String
  33. , FormatTag
  34. , ConversionPolicy
  35. , typename enable_if< mpl::and_< detail::is_supported_path_spec< String >
  36. , is_format_tag< FormatTag >
  37. >
  38. >::type
  39. >
  40. {
  41. typedef typename get_read_device< String
  42. , FormatTag
  43. >::type device_t;
  44. typedef reader< device_t
  45. , FormatTag
  46. , ConversionPolicy
  47. > type;
  48. };
  49. template< typename Device
  50. , typename FormatTag
  51. , typename ConversionPolicy
  52. >
  53. struct get_reader< Device
  54. , FormatTag
  55. , ConversionPolicy
  56. , typename enable_if< mpl::and_< detail::is_adaptable_input_device< FormatTag
  57. , Device
  58. >
  59. , is_format_tag< FormatTag >
  60. >
  61. >::type
  62. >
  63. {
  64. typedef typename get_read_device< Device
  65. , FormatTag
  66. >::type device_t;
  67. typedef reader< device_t
  68. , FormatTag
  69. , ConversionPolicy
  70. > type;
  71. };
  72. /// \brief Helper metafunction to generate dynamic image reader type.
  73. template< typename T
  74. , typename FormatTag
  75. , class Enable = void
  76. >
  77. struct get_dynamic_image_reader
  78. {};
  79. template< typename String
  80. , typename FormatTag
  81. >
  82. struct get_dynamic_image_reader< String
  83. , FormatTag
  84. , typename enable_if< mpl::and_< detail::is_supported_path_spec< String >
  85. , is_format_tag< FormatTag >
  86. >
  87. >::type
  88. >
  89. {
  90. typedef typename get_read_device< String
  91. , FormatTag
  92. >::type device_t;
  93. typedef dynamic_image_reader< device_t
  94. , FormatTag
  95. > type;
  96. };
  97. template< typename Device
  98. , typename FormatTag
  99. >
  100. struct get_dynamic_image_reader< Device
  101. , FormatTag
  102. , typename enable_if< mpl::and_< detail::is_adaptable_input_device< FormatTag
  103. , Device
  104. >
  105. , is_format_tag< FormatTag >
  106. >
  107. >::type
  108. >
  109. {
  110. typedef typename get_read_device< Device
  111. , FormatTag
  112. >::type device_t;
  113. typedef dynamic_image_reader< device_t
  114. , FormatTag
  115. > type;
  116. };
  117. /////////////////////////////////////////////////////////////
  118. /// \brief Helper metafunction to generate image backend type.
  119. template< typename T
  120. , typename FormatTag
  121. , class Enable = void
  122. >
  123. struct get_reader_backend
  124. {};
  125. template< typename String
  126. , typename FormatTag
  127. >
  128. struct get_reader_backend< String
  129. , FormatTag
  130. , typename enable_if< mpl::and_< detail::is_supported_path_spec< String >
  131. , is_format_tag< FormatTag >
  132. >
  133. >::type
  134. >
  135. {
  136. typedef typename get_read_device< String
  137. , FormatTag
  138. >::type device_t;
  139. typedef reader_backend< device_t
  140. , FormatTag
  141. > type;
  142. };
  143. template< typename Device
  144. , typename FormatTag
  145. >
  146. struct get_reader_backend< Device
  147. , FormatTag
  148. , typename enable_if< mpl::and_< detail::is_adaptable_input_device< FormatTag
  149. , Device
  150. >
  151. , is_format_tag< FormatTag >
  152. >
  153. >::type
  154. >
  155. {
  156. typedef typename get_read_device< Device
  157. , FormatTag
  158. >::type device_t;
  159. typedef reader_backend< device_t
  160. , FormatTag
  161. > type;
  162. };
  163. /// \brief Helper metafunction to generate image scanline_reader type.
  164. template< typename T
  165. , typename FormatTag
  166. >
  167. struct get_scanline_reader
  168. {
  169. typedef typename get_read_device< T
  170. , FormatTag
  171. >::type device_t;
  172. typedef scanline_reader< device_t
  173. , FormatTag
  174. > type;
  175. };
  176. } // namespace gil
  177. } // namespace boost
  178. #endif