
Index: olena/ChangeLog from Damien Thivolle <damien@lrde.epita.fr> * olena/oln/core/abstract/image.hh: Add macros. * olena/oln/morpher/generic_morpher.hh: generic_morpher implementation. Index: olena/oln/core/abstract/image.hh --- olena/oln/core/abstract/image.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/t/25_image.hh 1.27 640) +++ olena/oln/core/abstract/image.hh Thu, 25 Mar 2004 20:08:16 +0100 thivol_d (oln/t/25_image.hh 1.27 640) @@ -125,7 +125,7 @@ ** at \a p in the current image. */ - const value_type& + const value_type operator[](const abstract::point<point_type>& p) const { return this->exact().at(p.exact()); @@ -343,11 +343,36 @@ # define oln_concrete_type(ImgType) \ typename mute<ImgType>::ret +# define oln_exact_type(ImgType) \ +mlc_exact_type(ImgType)::exact_type +# define oln_exact_type_(ImgType) \ +mlc_exact_type_(ImgType)::exact_type + # define oln_iter_type(Iterable) \ mlc_exact_type(Iterable)::iter_type # define oln_iter_type_(Iterable) \ mlc_exact_type_(Iterable)::iter_type +# define oln_fwd_iter_type(Fwd_Iterable) \ +mlc_exact_type(Fwd_Iterable)::fwd_iter_type +# define oln_fwd_iter_type_(Fwd_Iterable) \ +mlc_exact_type_(Fwd_Iterable) + +# define oln_bkd_iter_type(Bkd_Iterable) \ +mlc_exact_type(Bkd_Iterable)::bkd_iter_type +# define oln_bkd_iter_type_(Bkd_Iterable) \ +mlc_exact_type_(Bkd_Iterable)::bkd_iter_type + +# define oln_size_type(ImgType) \ +mlc_exact_type(ImgType)::size_type +# define oln_size_type_(ImgType) \ +mlc_exact_type_(ImgType)::size_type + +# define oln_impl_type(ImgType) \ +mlc_exact_type(ImgType)::impl_type +# define oln_impl_type_(ImgType) \ +mlc_exact_type_(ImgType)::impl_type + # define oln_point_type(Pointable) \ mlc_exact_type(Pointable)::point_type # define oln_point_type_(Pointable) \ Index: olena/oln/morpher/generic_morpher.hh --- olena/oln/morpher/generic_morpher.hh Thu, 25 Mar 2004 20:12:11 +0100 thivol_d () +++ olena/oln/morpher/generic_morpher.hh Thu, 25 Mar 2004 20:09:08 +0100 thivol_d (oln/m/18_generic_mo 644) @@ -0,0 +1,226 @@ +// Copyright (C) 2001, 2003, 2004 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, 59 Temple Place - Suite 330, 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 GENERIC_MORPHER_HH +# define GENERIC_MORPHER_HH + +# include <string> + + +# include <oln/basics1d.hh> +# include <oln/basics2d.hh> +# include <oln/basics3d.hh> +# include <ntg/all.hh> + +namespace oln { + + /*! \namespace morpher + ** + ** Contain all the morpher relative declarations and functions. + */ + + namespace morpher { + + /*! \namespace abstract + ** + ** generic_morpher implementation. + */ + + namespace abstract { + + /*! \class gm_inherit + ** + ** Perform a conditionnal inheritance for the \a generic_morpher + ** class regarding its template parameters. + */ + template <class T, class Exact> + struct gm_inherit; + + /*! \class gm_inherit<oln::image1d<T>, Exact > + ** + ** Return \a image1d with an \a exact_type of \a Exact. + */ + template <class T, class Exact> + struct gm_inherit<oln::image1d<T>, Exact > + { + typedef oln::image1d<T, Exact> ret; + }; + + /*! \class gm_inherit<oln::image1d<T>, Exact > + ** + ** Return \a image2d with an \a exact_type of \a Exact. + */ + template <class T, class Exact> + struct gm_inherit<oln::image2d<T>, Exact > + { + typedef oln::image2d<T, Exact> ret; + }; + + /*! \class gm_inherit<oln::image1d<T>, Exact > + ** + ** Return \a image3d with an \a exact_type of \a Exact. + */ + template <class T, class Exact> + struct gm_inherit<oln::image3d<T>, Exact > + { + typedef oln::image3d<T, Exact> ret; + }; + + /*! \class generic_morpher + ** + ** An abstract class from whom derive all other + ** concrete morphers. Define a default implementation + ** for all the dispatched methods of the image hierarchy. + */ + + template <class Inherit, class Deco, class Exact> + class generic_morpher : public gm_inherit< + Inherit, + Exact>::ret + { + protected: + + /*! \brief Construct an instance of generic_morpher by assigning + ** \a Ima to Ima_. + */ + generic_morpher(const Deco &Ima) : super_type(), Ima_(Ima) {} + + /// Default Constructor. + generic_morpher(): Ima(Deco()) {} + + /// The decorated image. + const Deco &Ima_; + + public: + + /// Type of the decorated image. + typedef Deco deco_type; + typedef oln_point_type(Deco) point_type; + typedef oln_dpoint_type(Deco) dpoint_type; + typedef oln_iter_type(Deco) iter_type; + typedef oln_fwd_iter_type(Deco) fwd_iter_type; + typedef oln_bkd_iter_type(Deco) bkd_iter_type; + typedef oln_value_type(Deco) value_type; + typedef oln_size_type(Deco) size_type; + + /// Underlying implementation of the decorated image. + typedef oln_impl_type(Deco) impl_type; + + /// Exact type of the decorated image. + typedef oln_exact_type(Deco) image_type; + + typedef typename gm_inherit<Inherit, Exact>::ret super_type; + + /// Return the decorated image. + const Deco& + get_ima() const + { + return this->Ima_; + } + + /// Return the value stored at \a p in the decorated image. + const value_type + at(const point_type& p) const + { + return this->Ima_.exact().at(p); + } + + /// Return a reference to the value stored at \a p in the decorated image. + value_type& + at(const point_type& p) + { + return this->Ima_.exact().at(p); + } + + /// Return a pointer to the value container of the decorated image. + const impl_type* + impl() const + { + return this->Ima_.exact().impl(); + } + + /// Return a pointer to the value container of the decorated image. + impl_type* + impl() + { + return this->Ima_.exact().impl(); + } + + /// Return a copy of the decorated image. + image_type + clone_() const + { + return this->Ima_.exact().clone_(); + } + + /// Return the size of the decorated image. + size_t + npoints_() + { + return this->Ima_.exact().npoints_(); + } + + /// Assign \a rhs to the decorated image. + image_type& + assign(deco_type& rhs) + { + return this->Ima_.exact().assign(rhs); + } + + /// Assign the decorated image to \a r + deco_type& + operator=(const oln::io::internal::anything& r) + { + return r.assign(this->Ima_); + } + + /*! \brief Set the border width of the decorated image to + ** \a min_border. + */ + void + border_set_width(oln::coord min_border, + bool copy_border = false) const + { + return this->Ima_.exact().border_set_width(min_border, copy_border); + } + + static std::string name() + { return "generic_morpher<" + super_type::name() + ">"; } + + + }; + + } // end of namespace abstract + + } // end of namespace morpher + +} // end of namespace oln + + +#endif // !GENERIC_MORPHER_HH -- Damien Thivolle damien.thivolle@lrde.epita.fr

Damien Thivolle <damien@lrde.epita.fr> writes:
Index: olena/ChangeLog from Damien Thivolle <damien@lrde.epita.fr>
* olena/oln/core/abstract/image.hh: Add macros. * olena/oln/morpher/generic_morpher.hh: generic_morpher implementation.
Index: olena/oln/core/abstract/image.hh --- olena/oln/core/abstract/image.hh Mon, 15 Mar 2004 19:40:09 +0100 odou_s (oln/t/25_image.hh 1.27 640) +++ olena/oln/core/abstract/image.hh Thu, 25 Mar 2004 20:08:16 +0100 thivol_d (oln/t/25_image.hh 1.27 640) @@ -125,7 +125,7 @@ ** at \a p in the current image. */
- const value_type& + const value_type operator[](const abstract::point<point_type>& p) const { return this->exact().at(p.exact()); @@ -343,11 +343,36 @@ # define oln_concrete_type(ImgType) \ typename mute<ImgType>::ret
+# define oln_exact_type(ImgType) \ +mlc_exact_type(ImgType)::exact_type +# define oln_exact_type_(ImgType) \ +mlc_exact_type_(ImgType)::exact_type
Si on etend les macros et les templates, on obtient quelque chose du genre ImgType::exact_type::exact_type, d'ou l'inutilite selon moi du '::exact_type'. De plus c'est une macro generale a toute hierarchie statique, je ne vois donc pas pourquoi en faire une version oln.
+ /// Return the value stored at \a p in the decorated image. + const value_type + at(const point_type& p) const + { + return this->Ima_.exact().at(p); + } toto.exact() doit s'ecrire to_exact(toto) + + /// Return a reference to the value stored at \a p in the decorated image. + value_type& + at(const point_type& p) + { + return this->Ima_.exact().at(p); + } idem
+ + /// Return a pointer to the value container of the decorated image. + const impl_type* + impl() const + { + return this->Ima_.exact().impl(); + } idem
+ + /// Return a pointer to the value container of the decorated image. + impl_type* + impl() + { + return this->Ima_.exact().impl(); + } idem
+ + /// Return a copy of the decorated image. + image_type + clone_() const + { + return this->Ima_.exact().clone_(); + } idem
+ + /// Return the size of the decorated image. + size_t + npoints_() + { + return this->Ima_.exact().npoints_(); + } + idem
+ /// Assign \a rhs to the decorated image. + image_type& + assign(deco_type& rhs) + { + return this->Ima_.exact().assign(rhs); + } + idem
+ /// Assign the decorated image to \a r + deco_type& + operator=(const oln::io::internal::anything& r) + { + return r.assign(this->Ima_); + } + + /*! \brief Set the border width of the decorated image to + ** \a min_border. + */ + void + border_set_width(oln::coord min_border, + bool copy_border = false) const + { + return this->Ima_.exact().border_set_width(min_border, copy_border); + }
Y'a-t-il une raison a tout ces this ? -- Giovanni Palma EPITA - promo 2005 - membre d'EpX - LRDE Mob. : +33 (0)6 60 97 31 74

* olena/oln/core/abstract/image.hh: Add macros. Tu n'as pas changer le type de retour de at?
* olena/oln/morpher/generic_morpher.hh: generic_morpher implementation. Youpi!
# define oln_concrete_type(ImgType) \ typename mute<ImgType>::ret
+# define oln_exact_type(ImgType) \ +mlc_exact_type(ImgType)::exact_type Pas beau.
+// Copyright (C) 2001, 2003, 2004 EPITA Research and Development Laboratory
OK pour 2003 si tu as repris les fichiers de david, mais 2001 ???
+# include <ntg/all.hh> ???? Pas glop ici.
+ /*! \namespace morpher + ** + ** Contain all the morpher relative declarations and functions. + */ Pas top comme définition.
De plus il est préférable d'écrire: /// [...] que /* \namespace toto ** ** [...] */
+ /*! \namespace abstract + ** + ** generic_morpher implementation. + */ On ne peux pas cliquer dans la doc. A changer par:
///Implementation of oln::abstract::generic_morpher.
+ + namespace abstract { + + /*! \class gm_inherit + ** + ** Perform a conditionnal inheritance for the + ** class regarding its template parameters. + */
Il faut éviter \class .... Regarde le resultat dans la doc mais je doute que le "Perform..." soit dans le brief. Remplace donc ce genre de remarque par: /*! Traits for conditionnal inheritance used by the \a generic_morpher ** ** It changes the exact type of the image in the input (the exact ** type becomes the concrete morpher). ** \see oln::morpher::generic_morpher */
+ /*! \class gm_inherit<oln::image1d<T>, Exact > Idem.
+ ** Return \a image1d with an \a exact_type of \a Exact. Bien. + */ + template <class T, class Exact> + struct gm_inherit<oln::image1d<T>, Exact > + { + typedef oln::image1d<T, Exact> ret; + };
+ /*! \class gm_inherit<oln::image1d<T>, Exact > + ** + ** Return \a image3d with an \a exact_type of \a Exact. + */ + template <class T, class Exact> + struct gm_inherit<oln::image3d<T>, Exact > + { + typedef oln::image3d<T, Exact> ret; + }; Heu... Petites questions idiotes... Le morpher a-t-il pour vocation de transformer uniquement vers du image1d<T, final>, image2d<T, final>, image3d<t, final>, ou bien doit-il fonctionner sur du image1d<T, pas_final> ? Vers du image1d_derived<T, mlc::final> par exemple?
Je suppose que la réponse est non. Si la réponse est du type non, mais c'est possible de le faire, j'attends les tests.
+ /*! \class generic_morpher Idem.
+ ** An abstract class from whom derive all other + ** concrete morphers. Ce genre de remarque est un peu inutile, non?
+ Define a default implementation + ** for all the dispatched methods of the image hierarchy. + */ "image" -> "oln::abstract::image", ou bien "abstract image".
Ajouter: ** \param Inherit Output type of the morpher. ** \param Deco Input type decorated. ** \param Exact Exact type Tu peux ajouter un \note qui souligne que Inherit n'est pas exactement (c'est le cas de le dire!) le type dont on hérite. Il me semble que Inherit est un verbe en anglais (hériter). "Inherit" -> "DestType"? "Deco" -> "SrcType" ?
+ /*! \brief Construct an instance of generic_morpher by assigning + ** \a Ima to Ima_. + */ Pas top.
+ generic_morpher(const Deco &Ima) : super_type(), Ima_(Ima) {} + + /// Default Constructor. + generic_morpher(): Ima(Deco()) {} Heu, ça marche, ça?
+ + /// The decorated image. + const Deco &Ima_; Je n'aime pas la majuscule de Ima_.
+ typedef oln_point_type(Deco) point_type; ???? + typedef oln_dpoint_type(Deco) dpoint_type; ???? + typedef oln_iter_type(Deco) iter_type; ???? + typedef oln_fwd_iter_type(Deco) fwd_iter_type; ???? + typedef oln_bkd_iter_type(Deco) bkd_iter_type; ???? + typedef oln_value_type(Deco) value_type; ???? + typedef oln_size_type(Deco) size_type; ???? Pour moi le type de point du morpher est le type de point en sortie, et non pas le type de point décoré.
+ typedef oln_impl_type(Deco) impl_type; Est-ce bien nécessaire?
+ /// Exact type of the decorated image. + typedef oln_exact_type(Deco) image_type; CF question bête plus haut. oln_exact_type(Deco) peut-il être différent de Deco?
+ /// Return the value stored at \a p in the decorated image. Perso, j'aurais insisté sur le coté "comportement par défaut". Idem pour tt les fonctions. + /// Return a pointer to the value container of the decorated image. "the value container" -> pas anglais.
+= post de Giovanni( qui m'a devancé :). -- Niels

"Damien" == Damien Thivolle <damien@lrde.epita.fr> writes:
- const value_type& + const value_type operator[](const abstract::point<point_type>& p) const
J'ai pas vu ce changement dans ChangeLog, ni le nom des macros. Ça se torche pas un ChangeLog, ça se soigne. Et après coup, ça se corrige.
participants (4)
-
Akim Demaille
-
Damien Thivolle
-
Giovanni Palma
-
Niels Van Vliet