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 "-Wunknown-pragmas"
23 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
24 #endif
25 
26 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
29 #endif
30 
31 namespace boost { namespace gil {
32 
33 // Forward declarations
34 template <typename T>
35 struct channel_traits;
36 
37 template <typename DstT, typename SrcT>
38 auto channel_convert(SrcT const& val)
39  -> typename channel_traits<DstT>::value_type;
40 
73 template <typename T>
75 {
76  void constraints()
77  {
78  gil_function_requires<boost::EqualityComparableConcept<T>>();
79 
80  using v = typename channel_traits<T>::value_type;
81  using r = typename channel_traits<T>::reference;
82  using p = typename channel_traits<T>::pointer;
83  using cr = typename channel_traits<T>::const_reference;
84  using cp = typename channel_traits<T>::const_pointer;
85 
86  channel_traits<T>::min_value();
87  channel_traits<T>::max_value();
88  }
89 
90  T c;
91 };
92 
93 namespace detail
94 {
95 
97 template <typename T>
99 {
100  void constraints()
101  {
102  c1 = c2;
103  using std::swap;
104  swap(c1, c2);
105  }
106  T c1;
107  T c2;
108 };
109 
110 } // namespace detail
111 
117 template <typename T>
119 {
120  void constraints()
121  {
122  gil_function_requires<ChannelConcept<T>>();
123  gil_function_requires<detail::ChannelIsMutableConcept<T>>();
124  }
125 };
126 
132 template <typename T>
134 {
135  void constraints()
136  {
137  gil_function_requires<ChannelConcept<T>>();
138  gil_function_requires<Regular<T>>();
139  }
140 };
141 
153 template <typename T1, typename T2> // Models GIL Pixel
155  : std::is_same
156  <
157  typename channel_traits<T1>::value_type,
158  typename channel_traits<T2>::value_type
159  >
160 {
161 };
162 
172 template <typename Channel1, typename Channel2>
174 {
175  void constraints()
176  {
178  }
179 };
180 
192 template <typename SrcChannel, typename DstChannel>
194 {
195  void constraints()
196  {
197  gil_function_requires<ChannelConcept<SrcChannel>>();
198  gil_function_requires<MutableChannelConcept<DstChannel>>();
199  dst = channel_convert<DstChannel, SrcChannel>(src);
200  ignore_unused_variable_warning(dst);
201  }
202  SrcChannel src;
203  DstChannel dst;
204 };
205 
206 }} // namespace boost::gil
207 
208 #if defined(BOOST_CLANG)
209 #pragma clang diagnostic pop
210 #endif
211 
212 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
213 #pragma GCC diagnostic pop
214 #endif
215 
216 #endif
Definition: concepts/channel.hpp:98
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:193
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:74
A channel that supports default construction.
Definition: concepts/channel.hpp:133
Predicate metafunction returning whether two channels are compatible.
Definition: concepts/channel.hpp:154
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:173
A channel that allows for modifying its value.
Definition: concepts/channel.hpp:118