/*////////////////////////////////////////////////////////////////////////////// Copyright (c) 2013 Jamboree Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //////////////////////////////////////////////////////////////////////////////*/ #ifndef BOOST_SAW_SUPPORT_FUSION_ADAPTED_PIXEL_HPP_INCLUDED #define BOOST_SAW_SUPPORT_FUSION_ADAPTED_PIXEL_HPP_INCLUDED #include #include #include #include #include #include #include #include #include #include #include namespace boost { namespace fusion { struct gil_pixel_iterator_tag; template struct gil_pixel_iterator : iterator_base > { BOOST_MPL_ASSERT_RELATION(Pos, >=, 0); BOOST_MPL_ASSERT_RELATION(Pos, <=, gil::size::value); struct category : random_access_traversal_tag , associative_tag {}; typedef ColorBase pixel_type; BOOST_STATIC_CONSTANT(int, index = Pos); explicit gil_pixel_iterator(ColorBase& pixel) : pixel(pixel) {} ColorBase& pixel; }; }} namespace boost { namespace fusion { namespace traits { template struct tag_of > { typedef gil_pixel_iterator_tag type; }; }}} namespace boost { namespace fusion { namespace extension { template struct value_of_impl; template struct value_of_data_impl; template struct deref_impl; template struct deref_data_impl; template struct advance_impl; template struct distance_impl; template struct next_impl; template struct prior_impl; template struct equal_to_impl; template struct key_of_impl; template<> struct value_of_impl { template struct apply { typedef typename gil::kth_element_type< typename Iterator::pixel_type, Iterator::index>::type value_type; typedef saw::raw type; }; }; template<> struct value_of_data_impl : value_of_impl {}; template<> struct deref_impl { template struct apply; template struct apply > { typedef typename gil::kth_element_reference_type::type type; static inline type call(gil_pixel_iterator const& it) { return gil::at_c(it.pixel); } }; }; template<> struct deref_data_impl : deref_impl {}; template<> struct advance_impl { template struct apply { typedef gil_pixel_iterator < typename Iterator::pixel_type, Iterator::index + N::value > type; static inline type call(Iterator const& it) { return type(it.pixel); } }; }; template<> struct distance_impl { template struct apply { typedef mpl::int_ type; static inline type call(First const& first, Last const& last) { return type(); } }; }; template<> struct next_impl { template struct apply { typedef gil_pixel_iterator < typename Iterator::pixel_type, Iterator::index + 1 > type; static inline type call(Iterator const& it) { return type(it.pixel); } }; }; template<> struct prior_impl { template struct apply { typedef gil_pixel_iterator < typename Iterator::pixel_type, Iterator::index - 1 > type; static inline type call(Iterator const& it) { return type(it.pixel); } }; }; template<> struct equal_to_impl { template struct apply : mpl::bool_ {}; }; template<> struct key_of_impl { template struct apply { typedef typename Iterator::pixel_type::layout_t::channel_mapping_t channel_mapping; typedef typename mpl::at_c < typename Iterator::pixel_type::layout_t::color_space_t , mpl::distance < typename mpl::begin::type , typename mpl::find < channel_mapping // !!cannot use mpl::int_ here , mpl::integral_c >::type >::value >::type type; }; }; }}} namespace boost { namespace fusion { struct gil_pixel_tag; }} namespace boost { namespace fusion { namespace traits { template struct tag_of >::type> { typedef gil_pixel_tag type; }; }}} namespace boost { namespace fusion { namespace extension { template<> struct category_of_impl { template struct apply { struct type : random_access_traversal_tag, associative_tag {}; }; }; template struct begin_impl; template struct end_impl; template struct at_impl; template struct value_at_impl; template struct size_impl; template struct at_key_impl; template struct value_at_key_impl; template struct has_key_impl; template struct is_sequence_impl; template struct is_view_impl; template<> struct begin_impl { template struct apply { typedef gil_pixel_iterator type; static inline type call(Sequence& seq) { return type(seq); } }; }; template<> struct end_impl { template struct apply { typedef gil_pixel_iterator::value> type; static inline type call(Sequence& seq) { return type(seq); } }; }; template<> struct at_impl { template struct apply { typedef typename gil::kth_element_reference_type::type type; static inline type call(Sequence& seq) { return gil::at_c(seq); } }; }; template<> struct value_at_impl { template struct apply { typedef typename gil::kth_element_type::type value_type; typedef saw::raw type; }; }; template<> struct size_impl { template struct apply : gil::size {}; }; template<> struct value_at_key_impl { template struct apply { typedef typename gil::color_element_type::type type; }; }; template<> struct at_key_impl { template struct apply { typedef gil::color_element_reference_type color_element; typedef typename color_element::type type; static inline type call(Sequence& seq) { return color_element::get(seq); } }; }; template<> struct has_key_impl { template struct apply : gil::contains_color {}; }; template<> struct is_sequence_impl { template struct apply : mpl::true_ {}; }; template<> struct is_view_impl { template struct apply : mpl::false_ {}; }; }}} #endif