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