00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 #ifndef MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH
00027 # define MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH
00028 
00035 
00036 # include <mln/metal/bool.hh>
00037 # include <mln/core/macros.hh>
00038 # include <mln/core/trait/pixter.hh>
00039 # include <mln/core/trait/qlf_value.hh>
00040 # include <mln/core/internal/force_exact.hh>
00041 
00042 
00043 namespace mln
00044 {
00045 
00046   namespace internal
00047   {
00048 
00049     namespace check
00050     {
00051 
00053       template < typename E, typename B = metal::true_ >
00054       struct image_fastest_
00055       {
00056 
00066         template <typename P>
00067         unsigned
00068         index_of_point(const P& p) const;
00069 
00070       protected:
00071         image_fastest_();
00072       };
00073 
00074 
00075       template <typename E>
00076       struct image_fastest_< E, metal::false_ >
00077       {
00078         
00079       };
00080 
00081 
00082 # ifndef MLN_INCLUDE_ONLY
00083 
00084       template <typename E, typename B>
00085       inline
00086       image_fastest_<E,B>::image_fastest_()
00087       {
00088         typedef mln_site(E)        site;
00089         typedef mln_psite(E)      psite;
00090         typedef mln_delta(psite) dpsite;
00091 
00092 
00093         typedef mln_fwd_pixter(E) fwd_pixter;
00094         typedef mln_bkd_pixter(E) bkd_pixter;
00095 
00096         int (E::*m1)(const dpsite&) const = & E::delta_index;
00097         m1 = 0;
00098         site (E::*m2)(unsigned) const = & E::point_at_index;
00099         m2 = 0;
00100         unsigned (E::*m3)() const = & E::border;
00101         m3 = 0;
00102 
00103         typedef mln_value(E) value;
00104 
00105         mln_qlf_value(E)* (E::*m4)() = & E::buffer;
00106         m4 = 0;
00107         const value* (E::*m5)() const = & E::buffer;
00108         m5 = 0;
00109 
00110         typedef mln_rvalue(E) rvalue;
00111         typedef mln_lvalue(E) lvalue;
00112 
00113         rvalue (E::*m6)(unsigned) const = & E::element;
00114         m6 = 0;
00115         lvalue (E::*m7)(unsigned) = & E::element;
00116         m7 = 0;
00117 
00118         unsigned (E::*m8)() const = & E::nelements;
00119         m8 = 0;
00120 
00121 #  if (defined(__GNUC__) && __GNUC__ >= 3) && !defined(__INTEL_COMPILER)
00122         unsigned (E::*m9)(const psite& p) const = & E::index_of_point;
00123         m9 = 0;
00124 #  endif
00125 
00126         
00127       }
00128 
00129       template <typename E, typename B>
00130       template <typename P>
00131       inline
00132       unsigned
00133       image_fastest_<E,B>::index_of_point(const P& p) const
00134       {
00135         const E* this_ = & internal::force_exact<E>(*this);
00136         mln_precondition(this_->is_valid());
00137         mln_precondition(this_->has(p));
00138 
00139         unsigned i = & this_->operator()(p) - this_->buffer();
00140         mln_postcondition(p == this_->point_at_index(i));
00141         return i;
00142       }
00143 
00144 # endif // ! MLN_INCLUDE_ONLY
00145 
00146     } 
00147 
00148   } 
00149 
00150 } 
00151 
00152 
00153 #endif // ! MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH