Boost GIL


get_writer.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_WRITER_HPP
9 #define BOOST_GIL_IO_GET_WRITER_HPP
10 
11 #include <boost/gil/detail/mp11.hpp>
12 #include <boost/gil/io/get_write_device.hpp>
13 
14 #include <type_traits>
15 
16 namespace boost { namespace gil {
17 
19 template <typename T, typename FormatTag, class Enable = void>
20 struct get_writer {};
21 
22 
23 template <typename String, typename FormatTag>
24 struct get_writer
25 <
26  String,
27  FormatTag,
28  typename std::enable_if
29  <
30  mp11::mp_and
31  <
32  detail::is_supported_path_spec<String>,
33  is_format_tag<FormatTag>
34  >::value
35  >::type
36 >
37 {
38  using device_t = typename get_write_device<String, FormatTag>::type;
39  using type = writer<device_t, FormatTag>;
40 };
41 
42 template <typename Device, typename FormatTag>
43 struct get_writer
44 <
45  Device,
46  FormatTag,
47  typename std::enable_if
48  <
49  mp11::mp_and
50  <
51  detail::is_adaptable_output_device<FormatTag, Device>,
52  is_format_tag<FormatTag>
53  >::value
54  >::type
55 >
56 {
57  using device_t = typename get_write_device<Device, FormatTag>::type;
58  using type = writer<device_t, FormatTag>;
59 };
60 
62 template <typename T, typename FormatTag, class Enable = void>
64 
65 template <typename String, typename FormatTag>
67 <
68  String,
69  FormatTag,
70  typename std::enable_if
71  <
72  mp11::mp_and
73  <
74  detail::is_supported_path_spec<String>,
75  is_format_tag<FormatTag>
76  >::value
77  >::type
78 >
79 {
80  using device_t = typename get_write_device<String, FormatTag>::type;
81  using type = dynamic_image_writer<device_t, FormatTag>;
82 };
83 
84 template <typename Device, typename FormatTag>
85 struct get_dynamic_image_writer
86 <
87  Device,
88  FormatTag,
89  typename std::enable_if
90  <
91  mp11::mp_and
92  <
93  detail::is_write_device<FormatTag, Device>,
94  is_format_tag<FormatTag>
95  >::value
96  >::type
97 >
98 {
99  using device_t = typename get_write_device<Device, FormatTag>::type;
100  using type = dynamic_image_writer<device_t, FormatTag>;
101 };
102 
103 }} // namespace boost::gil
104 
105 #endif
Helper metafunction to generate writer type.
Definition: get_writer.hpp:20
Helper metafunction to generate dynamic image writer type.
Definition: get_writer.hpp:63