Boost GIL


concepts/channel.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_CHANNEL_HPP
9 #define BOOST_GIL_CONCEPTS_CHANNEL_HPP
10 
11 #include <boost/gil/concepts/basic.hpp>
12 #include <boost/gil/concepts/concept_check.hpp>
13 #include <boost/gil/concepts/fwd.hpp>
14 
15 #include <boost/concept_check.hpp>
16 
17 #include <utility> // std::swap
18 #include <type_traits>
19 
20 #if defined(BOOST_CLANG)
21 #pragma clang diagnostic push
22 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
23 #endif
24 
25 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
26 #pragma GCC diagnostic push
27 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
28 #endif
29 
30 namespace boost { namespace gil {
31 
32 // Forward declarations
33 template <typename T>
34 struct channel_traits;
35 
36 template <typename DstT, typename SrcT>
37 auto channel_convert(SrcT const& val)
38  -> typename channel_traits<DstT>::value_type;
39 
72 template <typename T>
74 {
75  void constraints()
76  {
77  gil_function_requires<boost::EqualityComparableConcept<T>>();
78 
79  using v = typename channel_traits<T>::value_type;
80  using r = typename channel_traits<T>::reference;
81  using p = typename channel_traits<T>::pointer;
82  using cr = typename channel_traits<T>::const_reference;
83  using cp = typename channel_traits<T>::const_pointer;
84 
85  channel_traits<T>::min_value();
86  channel_traits<T>::max_value();
87  }
88 
89  T c;
90 };
91 
92 namespace detail
93 {
94 
96 template <typename T>
98 {
99  void constraints()
100  {
101  c1 = c2;
102  using std::swap;
103  swap(c1, c2);
104  }
105  T c1;
106  T c2;
107 };
108 
109 } // namespace detail
110 
116 template <typename T>
118 {
119  void constraints()
120  {
121  gil_function_requires<ChannelConcept<T>>();
122  gil_function_requires<detail::ChannelIsMutableConcept<T>>();
123  }
124 };
125 
131 template <typename T>
133 {
134  void constraints()
135  {
136  gil_function_requires<ChannelConcept<T>>();
137  gil_function_requires<Regular<T>>();
138  }
139 };
140 
152 template <typename T1, typename T2> // Models GIL Pixel
154  : std::is_same
155  <
156  typename channel_traits<T1>::value_type,
157  typename channel_traits<T2>::value_type
158  >
159 {
160 };
161 
171 template <typename Channel1, typename Channel2>
173 {
174  void constraints()
175  {
177  }
178 };
179 
191 template <typename SrcChannel, typename DstChannel>
193 {
194  void constraints()
195  {
196  gil_function_requires<ChannelConcept<SrcChannel>>();
197  gil_function_requires<MutableChannelConcept<DstChannel>>();
198  dst = channel_convert<DstChannel, SrcChannel>(src);
199  ignore_unused_variable_warning(dst);
200  }
201  SrcChannel src;
202  DstChannel dst;
203 };
204 
205 }} // namespace boost::gil
206 
207 #if defined(BOOST_CLANG)
208 #pragma clang diagnostic pop
209 #endif
210 
211 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
212 #pragma GCC diagnostic pop
213 #endif
214 
215 #endif
Definition: concepts/channel.hpp:97
channel_traits< DstChannel >::value_type channel_convert(const SrcChannel &src)
Converting from one channel type to another.
Definition: channel_algorithm.hpp:451
A channel is convertible to another one if the channel_convert algorithm is defined for the two chann...
Definition: concepts/channel.hpp:192
A channel is the building block of a color. Color is defined as a mixture of primary colors and a cha...
Definition: concepts/channel.hpp:73
A channel that supports default construction.
Definition: concepts/channel.hpp:132
Predicate metafunction returning whether two channels are compatible.
Definition: concepts/channel.hpp:153
void swap(boost::gil::packed_channel_reference< BF, FB, NB, M > const x, R &y)
swap for packed_channel_reference
Definition: channel.hpp:529
Channels are compatible if their associated value types (ignoring constness and references) are the s...
Definition: concepts/channel.hpp:172
A channel that allows for modifying its value.
Definition: concepts/channel.hpp:117