00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GIL_PLANAR_REF_H
00010 #define GIL_PLANAR_REF_H
00011
00020
00021 #include "gil_config.hpp"
00022 #include "gil_concept.hpp"
00023 #include "channel.hpp"
00024
00025 ADOBE_GIL_NAMESPACE_BEGIN
00026
00027
00028 namespace detail {
00029 template <typename T, typename C> struct color_base;
00030 template <typename CS,int N> struct channel_accessor;
00031 template <typename CS> struct nth_channel_accessor;
00032 template <int N> struct channel_recursion;
00033
00034 }
00035 template <typename T, typename C> struct pixel;
00036
00045 template <typename TR, typename C>
00046 struct planar_ref : public detail::color_base<TR,C> {
00047 typedef detail::color_base<TR,C> parent_t;
00048 public:
00049 typedef C color_space_t;
00050 typedef TR channel_reference;
00051 typedef typename channel_traits<TR>::const_reference channel_const_reference;
00052 typedef typename channel_traits<TR>::value_type channel_t;
00053 typedef pixel<channel_t,color_space_t> pixel_value_type;
00054 template <int N> struct kth_channel_t { typedef channel_t type; };
00055
00056 static const int num_channels=color_space_t::num_channels;
00057
00058 planar_ref(TR v0, TR v1) : parent_t(v0,v1) {}
00059 planar_ref(TR v0, TR v1, TR v2) : parent_t(v0,v1,v2) {}
00060 planar_ref(TR v0, TR v1, TR v2, TR v3) : parent_t(v0,v1,v2,v3) {}
00061 planar_ref(TR v0, TR v1, TR v2, TR v3, TR v4) : parent_t(v0,v1,v2,v3,v4) {}
00062
00063 template <typename P> planar_ref(const P& p) : parent_t(p) { boost::function_requires<PixelsCompatibleConcept<P,pixel_value_type> >();}
00064 template <typename T1, typename C1> planar_ref(pixel<T1,C1>& p) : parent_t(p){ boost::function_requires<PixelsCompatibleConcept<pixel<T1,C1>,pixel_value_type> >();}
00065
00066 planar_ref& operator=(const planar_ref& p) { detail::channel_recursion<num_channels>::copy_channels(*this,p); return *this; }
00067 template <typename P> planar_ref& operator=(const P& p) { boost::function_requires<PixelsCompatibleConcept<P,pixel_value_type> >(); detail::channel_recursion<num_channels>::copy_channels(*this,p); return *this; }
00068
00069 template <typename P> bool operator==(const P& p) const { boost::function_requires<PixelsCompatibleConcept<P,pixel_value_type> >(); return detail::channel_recursion<num_channels>::equal_to(*this,p); }
00070 template <typename P> bool operator!=(const P& p) const { return !(*this==p); }
00071
00072 channel_reference operator[](std::size_t i) const { return detail::nth_channel_accessor<color_space_t>()(*this,i); }
00073
00074 template <int N> channel_reference channel() const { return detail::channel_accessor<C,N>()(*this); }
00075 template <int N> channel_reference semantic_channel() const { return detail::channel_accessor<typename C::base,N>()(*this); }
00076 const planar_ref* operator->() const { return this; }
00077 };
00078
00079
00080 ADOBE_GIL_NAMESPACE_END
00081
00082 #endif