Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / io / base.hpp
1 //
2 // Copyright 2007-2008 Christian Henning, Andreas Pokorny, Lubomir Bourdev
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_BASE_HPP
9 #define BOOST_GIL_IO_BASE_HPP
10
11 #include <boost/gil/extension/toolbox/toolbox.hpp>
12
13 #include <boost/gil/bit_aligned_pixel_reference.hpp>
14 #include <boost/gil/bit_aligned_pixel_iterator.hpp>
15 #include <boost/gil/color_convert.hpp>
16 #include <boost/gil/utilities.hpp>
17 #include <boost/gil/io/error.hpp>
18 #include <boost/gil/io/typedefs.hpp>
19
20 #include <istream>
21 #include <ostream>
22 #include <type_traits>
23 #include <vector>
24
25 namespace boost { namespace gil {
26
27 struct format_tag {};
28
29 template< typename Property >
30 struct property_base
31 {
32     using type = Property;
33 };
34
35 template<typename FormatTag>
36 struct is_format_tag : std::is_base_of<format_tag, FormatTag> {};
37
38 struct image_read_settings_base
39 {
40 protected:
41
42     image_read_settings_base()
43     : _top_left( 0, 0 )
44     , _dim     ( 0, 0 )
45     {}
46
47     image_read_settings_base( const point_t& top_left
48                             , const point_t& dim
49                             )
50     : _top_left( top_left )
51     , _dim     ( dim      )
52     {}
53
54
55 public:
56
57     void set( const point_t& top_left
58             , const point_t& dim
59             )
60     {
61         _top_left = top_left;
62         _dim      = dim;
63     }
64
65 public:
66
67     point_t _top_left;
68     point_t _dim;
69 };
70
71 /**
72  * Boolean meta function, std::true_type if the pixel type \a PixelType is supported
73  * by the image format identified with \a FormatTag.
74  * \todo the name is_supported is to generic, pick something more IO realted.
75  */
76 // Depending on image type the parameter Pixel can be a reference type
77 // for bit_aligned images or a pixel for byte images.
78 template< typename Pixel, typename FormatTag > struct is_read_supported {};
79 template< typename Pixel, typename FormatTag > struct is_write_supported {};
80
81
82 namespace detail {
83
84 template< typename Property >
85 struct property_base
86 {
87     using type = Property;
88 };
89
90 } // namespace detail
91
92 struct read_support_true  { static constexpr bool is_supported = true; };
93 struct read_support_false { static constexpr bool is_supported = false; };
94 struct write_support_true { static constexpr bool is_supported = true; };
95 struct write_support_false{ static constexpr bool is_supported = false; };
96
97 class no_log {};
98
99 template< typename Device, typename FormatTag > struct reader_backend;
100 template< typename Device, typename FormatTag > struct writer_backend;
101
102 template< typename FormatTag > struct image_read_info;
103 template< typename FormatTag > struct image_read_settings;
104 template< typename FormatTag, typename Log = no_log > struct image_write_info;
105
106 } // namespace gil
107 } // namespace boost
108
109 #endif