Boost GIL


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