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