
https://svn.lrde.epita.fr/svn/oln/trunk/milena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Prepare the 'fetch impl / check impl' image mechanism. * mln/core/internal/image_base.hh (image_checked_): New. (image_impled_): New. (image_base_): Change inheritance to image_impled_. The plug to select_image_concept_---soon obsolete---is now handled by image_checked_. (super_): Remove. * mln/core/internal/check: New directory. * mln/core/internal/check/image_all.hh: New. * mln/core/concept/fastest_image.hh: Move static checks into... * mln/core/internal/check/image_fastest.hh: ...this new file. * mln/core/concept/image.hh: Include extra metal files. concept/fastest_image.hh | 41 -------------------- concept/image.hh | 3 + internal/check/image_all.hh | 68 +++++++++++++++++++++++++++++++++ internal/check/image_fastest.hh | 82 ++++++++++++---------------------------- internal/image_base.hh | 36 +++++++++++++---- 5 files changed, 125 insertions(+), 105 deletions(-) Index: mln/core/internal/image_base.hh --- mln/core/internal/image_base.hh (revision 1254) +++ mln/core/internal/image_base.hh (working copy) @@ -35,8 +35,8 @@ # include <mln/core/concept/image.hh> # include <mln/core/grids.hh> +# include <mln/core/internal/check/image_all.hh> # include <mln/util/tracked_ptr.hh> -# include <mln/metal/equal.hh> @@ -97,6 +97,29 @@ + template <typename E> + struct image_checked_ + : + public check::image_all_<E>, + + // FIXME: first check impl w.r.t. properties, then: + public select_image_concept_< typename mlc_equal(mln_trait_image_speed(E), + trait::speed::fastest)::eval, + E > // FIXME: Change to Image<E> + { + }; + + + template <typename E> + struct image_impled_ + : + // FIXME: first fetch default impl w.r.t. properties, then: + image_checked_<E> + { + }; + + + /*! \brief A base class for images. * * Parameter \p S is a point set type. @@ -105,10 +128,9 @@ */ template <typename S, typename E> struct image_base_ + : + public image_impled_<E> - : public select_image_concept_< typename mlc_equal(mln_trait_image_speed(E), - trait::speed::fastest)::eval, - E > { /// Point_Set associated type. typedef S pset; @@ -171,10 +193,6 @@ // Internal data, sharable by several images. util::tracked_ptr< internal::data_<E> > data_; - - typedef select_image_concept_< typename mlc_equal(mln_trait_image_speed(E), - trait::speed::fastest)::eval, - E > super_; }; @@ -188,7 +206,7 @@ template <typename S, typename E> image_base_<S,E>::image_base_(const image_base_& rhs) - : super_() + : image_impled_<E>() { mln_precondition(exact(rhs).has_data()); // FIXME: Is-it too restrictive? this->data_ = rhs.data_; Index: mln/core/internal/check/image_all.hh --- mln/core/internal/check/image_all.hh (revision 0) +++ mln/core/internal/check/image_all.hh (revision 0) @@ -0,0 +1,68 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef MLN_CORE_INTERNAL_CHECK_IMAGE_ALL_HH +# define MLN_CORE_INTERNAL_CHECK_IMAGE_ALL_HH + +/*! \file mln/core/internal/check/image_all.hh + * + * \brief File that includes all image-related internal checks. + */ + + +# include <mln/core/internal/check/image_fastest.hh> +// ... + + +namespace mln +{ + + namespace internal + { + + /*! Namespace of all image-related internal checks. + */ + namespace check + { + + template <typename E> + struct image_all_ + : + public image_fastest_< E, typename mlc_equal(mln_trait_image_speed(E), + trait::speed::fastest)::eval > + // , ... + { + }; + + } // end of namespace mln::internal::check + + } // end of namespace mln::internal + +} // end of namespace mln + + +#endif // ! MLN_CORE_INTERNAL_CHECK_IMAGE_ALL_HH Index: mln/core/internal/check/image_fastest.hh --- mln/core/internal/check/image_fastest.hh (revision 0) +++ mln/core/internal/check/image_fastest.hh (working copy) @@ -25,83 +25,47 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef MLN_CORE_CONCEPT_FASTEST_IMAGE_HH -# define MLN_CORE_CONCEPT_FASTEST_IMAGE_HH +#ifndef MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH +# define MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH /*! \file mln/core/concept/fastest_image.hh * \brief Definition of the concept of mln::Fastest_Image. */ -# include <mln/core/concept/image.hh> -# include <mln/core/concept/generalized_point.hh> -# include <mln/core/trait/qlf_value.hh> - namespace mln { - /*! \brief Base class for implementation of fastest image classes. + namespace internal + { + + namespace check + { + + /*! \brief FIXME * * \see mln::doc::Fastest_Image for a complete documentation of this * class contents. */ - template <typename E> - struct Fastest_Image : public Image<E> + template < typename E, typename B = metal::true_ > + struct image_fastest_ { - /* - unsigned border(); - - int offset(const dpoint& dp) const; // FIXME: std::ptr_diff_t? - point point_at_offset(unsigned o) const; - - mln_qlf_value(E)* buffer(); - const value* buffer() const; - - rvalue operator[](unsigned o) const; - lvalue operator[](unsigned o); - - std::size_t ncells() const; - */ + protected: + image_fastest_(); + }; - /*! \brief Give the offset of the point \p p. - * - * \param[in] p A generalized point. - * - * \warning This method is final. - * - * \pre The image has to be initialized and to own the point \p p. - * \post p = point_at_offset(result) - */ - template <typename P> - unsigned - offset_at(const Generalized_Point<P>& p) const; - - protected: - Fastest_Image(); + template <typename E> + struct image_fastest_< E, metal::false_ > + { + // Nothing. }; # ifndef MLN_INCLUDE_ONLY - template <typename E> - template <typename P> - unsigned // FIXME: std::size_t? - Fastest_Image<E>::offset_at(const Generalized_Point<P>& p_) const - { - // FIXME: check that P is mln_point(E) - const E* this_ = exact(this); - const P& p = internal::force_exact<P>(p_); - mln_precondition(this_->has_data()); - mln_precondition(this_->owns_(p)); - - unsigned o = & this_->operator()(p) - this_->buffer(); - mln_postcondition(p = this_->point_at_offset(o)); - return o; - } - - template <typename E> - Fastest_Image<E>::Fastest_Image() + template <typename E, typename B> + image_fastest_<E,B>::image_fastest_() { typedef mln_point(E) point; typedef mln_dpoint(E) dpoint; @@ -139,7 +103,11 @@ # endif // ! MLN_INCLUDE_ONLY + } // end of namespace mln::internal::check + + } // end of namespace mln::internal + } // end of namespace mln -#endif // ! MLN_CORE_CONCEPT_FASTEST_IMAGE_HH +#endif // ! MLN_CORE_INTERNAL_CHECK_IMAGE_FASTEST_HH Index: mln/core/concept/image.hh --- mln/core/concept/image.hh (revision 1254) +++ mln/core/concept/image.hh (working copy) @@ -36,10 +36,13 @@ # include <mln/core/concept/mesh.hh> # include <mln/core/trait/all.hh> // FIXME: Move out of core! +# include <mln/core/macros.hh> # include <mln/trait/concrete.hh> // FIXME: Should be in all.hh! # include <mln/trait/images.hh> # include <mln/metal/is_a.hh> +# include <mln/metal/equal.hh> + # include <mln/tag/init.hh> Index: mln/core/concept/fastest_image.hh --- mln/core/concept/fastest_image.hh (revision 1254) +++ mln/core/concept/fastest_image.hh (working copy) @@ -77,13 +77,13 @@ unsigned offset_at(const Generalized_Point<P>& p) const; - protected: - Fastest_Image(); }; # ifndef MLN_INCLUDE_ONLY + // FIXME: Move in internal/image/impl... + template <typename E> template <typename P> unsigned // FIXME: std::size_t? @@ -100,43 +100,6 @@ return o; } - template <typename E> - Fastest_Image<E>::Fastest_Image() - { - typedef mln_point(E) point; - typedef mln_dpoint(E) dpoint; - - typedef mln_fwd_pixter(E) fwd_pixter; - typedef mln_bkd_pixter(E) bkd_pixter; - - int (E::*m1)(const dpoint&) const = & E::offset; - m1 = 0; - point (E::*m2)(unsigned) const = & E::point_at_offset; - m2 = 0; - unsigned (E::*m3)() const = & E::border; - m3 = 0; - - typedef mln_value(E) value; - - mln_qlf_value(E)* (E::*m4)() = & E::buffer; - m4 = 0; - const value* (E::*m5)() const = & E::buffer; - m5 = 0; - - typedef mln_rvalue(E) rvalue; - typedef mln_lvalue(E) lvalue; - - rvalue (E::*m6)(unsigned) const = & E::operator[]; - m6 = 0; - lvalue (E::*m7)(unsigned) = & E::operator[]; - m7 = 0; - - std::size_t (E::*m8)() const = & E::ncells; - m8 = 0; - - // FIXME: how to check that qixter are defined when W is unknown! - } - # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln