• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

image_fastest.hh

00001 // Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
00002 //
00003 // This file is part of Olena.
00004 //
00005 // Olena is free software: you can redistribute it and/or modify it under
00006 // the terms of the GNU General Public License as published by the Free
00007 // Software Foundation, version 2 of the License.
00008 //
00009 // Olena is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with Olena.  If not, see <http://www.gnu.org/licenses/>.
00016 //
00017 // As a special exception, you may use this file as part of a free
00018 // software project without restriction.  Specifically, if other files
00019 // instantiate templates or use macros or inline functions from this
00020 // file, or you compile this file and link it with other files to produce
00021 // an executable, this file does not by itself cause the resulting
00022 // executable to be covered by the GNU General Public License.  This
00023 // exception does not however invalidate any other reasons why the
00024 // executable file might be covered by the GNU General Public License.
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         // Nothing.
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         // FIXME: how to check that qixter are defined when W is unknown!
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     } // end of namespace mln::internal::check
00147 
00148   } // end of namespace mln::internal
00149 
00150 } // end of namespace mln
00151 
00152 
00153 #endif // ! MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH

Generated on Tue Oct 4 2011 15:23:58 for Milena (Olena) by  doxygen 1.7.1