00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GIL_PIXEL_ITERATOR_TRAITS_H
00010 #define GIL_PIXEL_ITERATOR_TRAITS_H
00011
00020
00021 #include <cassert>
00022 #include <iterator>
00023 #include "gil_config.hpp"
00024 #include "gil_concept.hpp"
00025 #include "pixel.hpp"
00026 #include "planar_ptr.hpp"
00027
00028 ADOBE_GIL_NAMESPACE_BEGIN
00029
00030
00031 template <typename IC, typename C> struct planar_ptr;
00032 template <typename T, typename C> struct pixel;
00033 template <typename I> class pixel_step_iterator;
00034 template <typename LOC2> class pixel_image_iterator;
00035 template <typename IT,typename D_FN> class dereference_iterator_adaptor;
00036
00055
00057 template <typename T, typename C>
00058 struct pixel_iterator_traits<pixel<T,C>*> : public std::iterator_traits<pixel<T,C>*> {
00059 typedef const pixel<T,C>& const_reference;
00060 typedef T channel_t;
00061 typedef C color_space_t;
00062 typedef pixel_step_iterator<pixel<T,C>*> dynamic_step_t;
00063 typedef const pixel<T,C>* const_t;
00064 typedef pixel<T,C> pixel_t;
00065 BOOST_STATIC_CONSTANT(bool, is_base=true);
00066 BOOST_STATIC_CONSTANT(bool, pixel_data_is_real=true);
00067 BOOST_STATIC_CONSTANT(bool, is_planar=false);
00068 BOOST_STATIC_CONSTANT(bool, is_mutable=channel_traits<T>::is_mutable);
00069 };
00070
00072 template <typename T, typename C>
00073 struct pixel_iterator_traits<const pixel<T,C>*> : public std::iterator_traits<const pixel<T,C>*> {
00074 typedef const pixel<T,C>& const_reference;
00075 typedef T channel_t;
00076 typedef C color_space_t;
00077 typedef pixel_step_iterator<const pixel<T,C>*> dynamic_step_t;
00078 typedef const pixel<T,C>* const_t;
00079 typedef pixel<T,C> pixel_t;
00080 BOOST_STATIC_CONSTANT(bool, is_base=true);
00081 BOOST_STATIC_CONSTANT(bool, pixel_data_is_real=true);
00082 BOOST_STATIC_CONSTANT(bool, is_planar=false);
00083 BOOST_STATIC_CONSTANT(bool, is_mutable=false);
00084 };
00085
00086 namespace detail {
00087 template <typename IC> struct channel_iterator_is_mutable { BOOST_STATIC_CONSTANT(bool, value=true); };
00088 template <typename T> struct channel_iterator_is_mutable<const T*> { BOOST_STATIC_CONSTANT(bool, value=false); };
00089 }
00090
00092 template <typename IC, typename C>
00093 struct pixel_iterator_traits<planar_ptr<IC,C> > : public std::iterator_traits<planar_ptr<IC,C> > {
00094 typedef typename std::iterator_traits<IC>::value_type channel_t;
00095 typedef C color_space_t;
00096 typedef planar_ref<typename channel_traits<channel_t>::const_reference,C> const_reference;
00097 typedef pixel_step_iterator<planar_ptr<IC,C> > dynamic_step_t;
00098 typedef planar_ptr<typename channel_traits<channel_t>::const_pointer,C> const_t;
00099 typedef typename std::iterator_traits<planar_ptr<IC,C> >::value_type pixel_t;
00100 BOOST_STATIC_CONSTANT(bool, is_base=true);
00101 BOOST_STATIC_CONSTANT(bool, pixel_data_is_real=true);
00102 BOOST_STATIC_CONSTANT(bool, is_planar=true);
00103 BOOST_STATIC_CONSTANT(bool, is_mutable=detail::channel_iterator_is_mutable<IC>::value);
00104 };
00105
00107 template <typename IT>
00108 struct pixel_iterator_traits<pixel_step_iterator<IT> > : public pixel_iterator_traits<IT> {
00109 typedef pixel_step_iterator<typename pixel_iterator_traits<IT>::const_t> const_t;
00110 typedef pixel_step_iterator<typename pixel_iterator_traits<IT>::dynamic_step_t> dynamic_step_base_t;
00111 BOOST_STATIC_CONSTANT(bool, is_base=false);
00112 typedef IT base_t;
00113 };
00114
00116 template <typename LOC>
00117 struct pixel_iterator_traits<pixel_image_iterator<LOC> > : public pixel_iterator_traits<typename LOC::x_iterator> {
00118 typedef pixel_image_iterator<typename LOC::dynamic_step_t> dynamic_step_t;
00119 typedef pixel_image_iterator<typename LOC::const_t> const_t;
00120 };
00121
00123 template <typename I, typename D_FN>
00124 struct pixel_iterator_traits<dereference_iterator_adaptor<I,D_FN> > : public pixel_iterator_traits<I> {
00125 typedef typename D_FN::reference reference;
00126 typedef typename D_FN::value_type value_type;
00127 typedef value_type pixel_t;
00128 typedef typename D_FN::const_reference const_reference;
00129 typedef dereference_iterator_adaptor<I,D_FN> pointer;
00130 typedef dereference_iterator_adaptor<typename pixel_iterator_traits<I>::const_t,D_FN>
00131 const_t;
00132 typedef typename value_type::channel_t channel_t;
00133 typedef typename value_type::color_space_t color_space_t;
00134 BOOST_STATIC_CONSTANT(bool, is_base=false);
00135 BOOST_STATIC_CONSTANT(bool, pixel_data_is_real=false);
00136 BOOST_STATIC_CONSTANT(bool, is_mutable=false);
00137 typedef I base_t;
00138 typedef dereference_iterator_adaptor<typename pixel_iterator_traits<I>::dynamic_step_t,D_FN>
00139 dynamic_step_t;
00140 };
00142
00143 ADOBE_GIL_NAMESPACE_END
00144
00145 #endif