planar_ref.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_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 //forward declarations
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 } // namespace detail
00035 template <typename T, typename C> struct pixel;
00036 
00045 template <typename TR, typename C>        // TR is a channel reference (const or mutable)
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;          // must be a value and have no constness
00053     typedef pixel<channel_t,color_space_t>               pixel_value_type;   // type to return when returning by value
00054     typedef const planar_ref<channel_reference,C>&       pixel_reference;
00055     typedef const planar_ref<channel_const_reference,C>& pixel_const_reference;
00056 
00057     template <int K>                                     struct kth_channel_t { 
00058         typedef channel_t         value_type; 
00059         typedef channel_reference reference; 
00060     };
00061 
00062     static const int                                     num_channels = color_space_t::num_channels;
00063 
00064     planar_ref(TR v0, TR v1)                             : parent_t(v0,v1) {}
00065     planar_ref(TR v0, TR v1, TR v2)                      : parent_t(v0,v1,v2) {}
00066     planar_ref(TR v0, TR v1, TR v2, TR v3)               : parent_t(v0,v1,v2,v3) {}
00067     planar_ref(TR v0, TR v1, TR v2, TR v3, TR v4)        : parent_t(v0,v1,v2,v3,v4) {}
00068     planar_ref(TR v0, TR v1, TR v2, TR v3, TR v4, TR v5) : parent_t(v0,v1,v2,v3,v4,v5) {}
00069 
00070     template <typename P> planar_ref(const P& p)         : parent_t(p)             { boost::function_requires<PixelsCompatibleConcept<P,pixel_value_type> >();}
00071     template <typename T1, typename C1> planar_ref(pixel<T1,C1>& p)   : parent_t(p){ boost::function_requires<PixelsCompatibleConcept<pixel<T1,C1>,pixel_value_type> >();}
00072 
00073     planar_ref&                        operator=(const planar_ref& p)  { copy_channels(p,*this); return *this; }
00074     template <typename P> planar_ref&  operator=(const P& p)           { boost::function_requires<PixelsCompatibleConcept<P,pixel_value_type> >(); copy_channels(p,*this); return *this; }
00075 
00076     template <typename P> bool         operator==(const P& p)    const { boost::function_requires<PixelsCompatibleConcept<P,pixel_value_type> >(); return equal_channels(*this,p); }
00077     template <typename P> bool         operator!=(const P& p)    const { return !(*this==p); }
00078 
00079     channel_reference                  operator[](std::size_t i) const { return detail::nth_channel_accessor<color_space_t>()(*this,i); }
00080 
00081     template <int N> channel_reference channel()                 const { return detail::channel_accessor<C,N>()(*this); }
00082     template <int N> channel_reference semantic_channel()        const { return detail::channel_accessor<typename C::base,N>()(*this); }
00083     const planar_ref*                  operator->()              const { return this; }
00084 };
00085 
00086 
00087 ADOBE_GIL_NAMESPACE_END
00088 
00089 #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