pixel_iterator_traits.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2006 Adobe Systems Incorporated
00003     Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
00004     or a copy at http://opensource.adobe.com/licenses.html)
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 //forward declarations
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 Iterator,typename DFn>  class dereference_iterator_adaptor;
00036 
00054 
00056 template <typename T, typename C>
00057 struct pixel_iterator_traits<pixel<T,C>*> : public std::iterator_traits<pixel<T,C>*> {
00058     typedef const pixel<T,C>&                 const_reference;
00059     typedef T                                 channel_t;
00060     typedef C                                 color_space_t;
00061     typedef pixel_step_iterator<pixel<T,C>*>  dynamic_step_t;
00062     typedef const pixel<T,C>*                 const_t;
00063     typedef pixel<T,C>                        pixel_t;
00064     BOOST_STATIC_CONSTANT(bool,               is_base=true);
00065     BOOST_STATIC_CONSTANT(bool,               is_planar=false);
00066     BOOST_STATIC_CONSTANT(bool,               is_mutable=channel_traits<T>::is_mutable);
00067 };
00068 
00070 template <typename T, typename C>
00071 struct pixel_iterator_traits<const pixel<T,C>*> : public std::iterator_traits<const pixel<T,C>*> {
00072     typedef const pixel<T,C>&                       const_reference;
00073     typedef T                                       channel_t;
00074     typedef C                                       color_space_t;
00075     typedef pixel_step_iterator<const pixel<T,C>*>  dynamic_step_t;
00076     typedef const pixel<T,C>*                       const_t;
00077     typedef pixel<T,C>                              pixel_t;
00078     BOOST_STATIC_CONSTANT(bool,                     is_base=true);
00079     BOOST_STATIC_CONSTANT(bool,                     is_planar=false);
00080     BOOST_STATIC_CONSTANT(bool,                     is_mutable=false);
00081 };
00082 
00083 namespace detail {
00084     template <typename IC> struct channel_iterator_is_mutable { BOOST_STATIC_CONSTANT(bool, value=true); };
00085     template <typename T>  struct channel_iterator_is_mutable<const T*> { BOOST_STATIC_CONSTANT(bool, value=false); };
00086 }
00087 
00089 template <typename IC, typename C>
00090 struct pixel_iterator_traits<planar_ptr<IC,C> > : public std::iterator_traits<planar_ptr<IC,C> > {
00091     typedef typename std::iterator_traits<IC>::value_type                     channel_t;
00092     typedef C                                                                 color_space_t;
00093     typedef planar_ref<typename channel_traits<channel_t>::const_reference,C> const_reference;
00094     typedef pixel_step_iterator<planar_ptr<IC,C> >                            dynamic_step_t;
00095     typedef planar_ptr<typename channel_traits<channel_t>::const_pointer,C>   const_t;
00096     typedef typename std::iterator_traits<planar_ptr<IC,C> >::value_type      pixel_t;
00097     BOOST_STATIC_CONSTANT(bool,                                               is_base=true);
00098     BOOST_STATIC_CONSTANT(bool,                                               is_planar=true);
00099     BOOST_STATIC_CONSTANT(bool,                                               is_mutable=detail::channel_iterator_is_mutable<IC>::value);
00100 };
00101 
00103 template <typename Iterator>
00104 struct pixel_iterator_traits<pixel_step_iterator<Iterator> > : public pixel_iterator_traits<Iterator> {
00105     typedef pixel_step_iterator<typename pixel_iterator_traits<Iterator>::const_t>        const_t; 
00106     typedef pixel_step_iterator<typename pixel_iterator_traits<Iterator>::dynamic_step_t> dynamic_step_base_t;
00107     BOOST_STATIC_CONSTANT(bool,                                                     is_base=false);
00108     typedef Iterator                                                                      base_t;
00109 };
00110 
00112 template <typename Loc> // Models PixelLocatorConcept
00113 struct pixel_iterator_traits<pixel_image_iterator<Loc> > : public pixel_iterator_traits<typename Loc::x_iterator> {
00114     typedef pixel_image_iterator<typename Loc::dynamic_step_t> dynamic_step_t;   
00115     typedef pixel_image_iterator<typename Loc::const_t>        const_t; 
00116 };
00117 
00119 template <typename I, typename DFn>
00120 struct pixel_iterator_traits<dereference_iterator_adaptor<I,DFn> > : public pixel_iterator_traits<I> {
00121     typedef typename DFn::reference                            reference;
00122     typedef typename DFn::value_type                           value_type;
00123     typedef value_type                                          pixel_t;
00124     typedef typename DFn::const_reference                      const_reference;
00125     typedef dereference_iterator_adaptor<I,DFn>                pointer;
00126     typedef dereference_iterator_adaptor<typename pixel_iterator_traits<I>::const_t,typename DFn::const_t> 
00127                                                                 const_t;
00128     typedef typename value_type::channel_t                      channel_t;
00129     typedef typename value_type::color_space_t                  color_space_t;
00130     BOOST_STATIC_CONSTANT(bool,                                 is_base=false);
00131     BOOST_STATIC_CONSTANT(bool,                                 is_mutable=false);
00132     typedef I                                                   base_t;
00133     typedef dereference_iterator_adaptor<typename pixel_iterator_traits<I>::dynamic_step_t,DFn>
00134                                                                 dynamic_step_t;
00135 };
00137 
00138 ADOBE_GIL_NAMESPACE_END
00139 
00140 #endif

Copyright © 2006 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google