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