Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / concepts / pixel_based.hpp
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
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_CONCEPTS_PIXEL_BASED_HPP
9 #define BOOST_GIL_CONCEPTS_PIXEL_BASED_HPP
10
11 #include <boost/gil/concepts/basic.hpp>
12 #include <boost/gil/concepts/channel.hpp>
13 #include <boost/gil/concepts/color.hpp>
14 #include <boost/gil/concepts/concept_check.hpp>
15 #include <boost/gil/concepts/fwd.hpp>
16
17 #include <cstddef>
18
19 #if defined(BOOST_CLANG)
20 #pragma clang diagnostic push
21 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
22 #endif
23
24 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
27 #endif
28
29 namespace boost { namespace gil {
30
31 /// \ingroup PixelBasedConcept
32 /// \brief Concept for all pixel-based GIL constructs.
33 ///
34 /// Pixel-based constructs include pixels, iterators, locators, views and
35 /// images whose value type is a pixel.
36 ///
37 /// \code
38 /// concept PixelBasedConcept<typename T>
39 /// {
40 ///     typename color_space_type<T>;
41 ///         where Metafunction<color_space_type<T> >;
42 ///         where ColorSpaceConcept<color_space_type<T>::type>;
43 ///     typename channel_mapping_type<T>;
44 ///         where Metafunction<channel_mapping_type<T> >;
45 ///         where ChannelMappingConcept<channel_mapping_type<T>::type>;
46 ///     typename is_planar<T>;
47 ///         where Metafunction<is_planar<T> >;
48 ///         where SameType<is_planar<T>::type, bool>;
49 /// };
50 /// \endcode
51 template <typename P>
52 struct PixelBasedConcept
53 {
54     void constraints()
55     {
56         using color_space_t = typename color_space_type<P>::type;
57         gil_function_requires<ColorSpaceConcept<color_space_t>>();
58
59         using channel_mapping_t = typename channel_mapping_type<P>::type ;
60         gil_function_requires<ChannelMappingConcept<channel_mapping_t>>();
61
62         static const bool planar = is_planar<P>::value;
63         ignore_unused_variable_warning(planar);
64
65         // This is not part of the concept, but should still work
66         static const std::size_t nc = num_channels<P>::value;
67         ignore_unused_variable_warning(nc);
68     }
69 };
70
71 /// \brief Concept for homogeneous pixel-based GIL constructs
72 /// \ingroup PixelBasedConcept
73 /// \code
74 /// concept HomogeneousPixelBasedConcept<PixelBasedConcept T>
75 /// {
76 ///     typename channel_type<T>;
77 ///         where Metafunction<channel_type<T>>;
78 ///         where ChannelConcept<channel_type<T>::type>;
79 /// };
80 /// \endcode
81 template <typename P>
82 struct HomogeneousPixelBasedConcept
83 {
84     void constraints()
85     {
86         gil_function_requires<PixelBasedConcept<P>>();
87
88         using channel_t = typename channel_type<P>::type;
89         gil_function_requires<ChannelConcept<channel_t>>();
90     }
91 };
92
93 }} // namespace boost::gil
94
95 #if defined(BOOST_CLANG)
96 #pragma clang diagnostic pop
97 #endif
98
99 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
100 #pragma GCC diagnostic pop
101 #endif
102
103 #endif