oln 10.112: Many corrections

Index: olena/ChangeLog from Damien Thivolle <damien@lrde.epita.fr> * olena/oln/core/abstract/image.hh: Correct macros. * olena/oln/core/abstract/image_with_impl.hh: Change the return type of `at' method to const value_type. * olena/oln/morpher/generic_morpher.hh: Correct comments. Change parameter names. Fix coding style. +2004-03-25 Damien Thivolle <damien@lrde.epita.fr> + + * olena/oln/core/abstract/image.hh: Change the return type of + `operator[]' method to const value_type. + Add macros for retrieving types associated to an image. * olena/oln/morpher/generic_morpher.hh: generic_morpher implementation. 2004-03-25 Giovanni Palma <giovanni@lrde.epita.fr> Index: olena/oln/core/abstract/image.hh --- olena/oln/core/abstract/image.hh Thu, 25 Mar 2004 20:12:45 +0100 thivol_d (oln/t/25_image.hh 1.28 600) +++ olena/oln/core/abstract/image.hh Fri, 26 Mar 2004 12:06:45 +0100 thivol_d (oln/t/25_image.hh 1.28 600) @@ -344,9 +344,9 @@ typename mute<ImgType>::ret # define oln_exact_type(ImgType) \ -mlc_exact_type(ImgType)::exact_type +mlc_exact_type(ImgType) # define oln_exact_type_(ImgType) \ -mlc_exact_type_(ImgType)::exact_type +mlc_exact_type_(ImgType) # define oln_iter_type(Iterable) \ mlc_exact_type(Iterable)::iter_type Index: olena/oln/core/abstract/image_with_impl.hh --- olena/oln/core/abstract/image_with_impl.hh Thu, 11 Mar 2004 17:12:19 +0100 thivol_d (oln/t/27_image_with 1.14.1.9 600) +++ olena/oln/core/abstract/image_with_impl.hh Fri, 26 Mar 2004 12:00:57 +0100 thivol_d (oln/t/27_image_with 1.14.1.9 600) @@ -196,7 +196,7 @@ ** \see image::operator[]() */ - const value_type& + const value_type at(const point_type& p) const { return impl_->at(p); Index: olena/oln/morpher/generic_morpher.hh --- olena/oln/morpher/generic_morpher.hh Thu, 25 Mar 2004 20:12:45 +0100 thivol_d (oln/m/18_generic_mo 1.1 600) +++ olena/oln/morpher/generic_morpher.hh Fri, 26 Mar 2004 12:51:44 +0100 thivol_d (oln/m/18_generic_mo 1.1 600) @@ -1,4 +1,4 @@ -// Copyright (C) 2001, 2003, 2004 EPITA Research and Development Laboratory +// Copyright (C) 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 @@ -32,76 +32,66 @@ # 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. - */ + /// Contain all the morpher relative declarations and functions. namespace morpher { - /*! \namespace abstract - ** - ** generic_morpher implementation. - */ + ///Implementation of oln::abstract::generic_morpher. namespace abstract { - /*! \class gm_inherit + /*! 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). ** - ** Perform a conditionnal inheritance for the \a generic_morpher - ** class regarding its template parameters. + ** \see oln::morpher::generic_morpher */ 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. - */ + /// 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. - */ + /// 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. - */ + /// 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 + /*! The Abstract morpher class. + ** + ** Define a default implementation for all the + ** dispatched methods of the image hierarchy. + ** + ** \param DestType Output type of the morpher. + ** + ** \param SrcType Input type decorated. ** - ** An abstract class from whom derive all other - ** concrete morphers. Define a default implementation - ** for all the dispatched methods of the image hierarchy. + ** \param Exact Exact type */ - template <class Inherit, class Deco, class Exact> + template <class DestType, class SrcType, class Exact> class generic_morpher : public gm_inherit< - Inherit, + DestType, Exact>::ret { protected: @@ -109,109 +99,132 @@ /*! \brief Construct an instance of generic_morpher by assigning ** \a Ima to Ima_. */ - generic_morpher(const Deco &Ima) : super_type(), Ima_(Ima) {} + generic_morpher(const SrcType &Ima) : super_type(), ima_(Ima) {} - /// Default Constructor. - generic_morpher(): Ima(Deco()) {} + /// Empty Constructor. + generic_morpher(): ima_(SrcType()) {} /// The decorated image. - const Deco &Ima_; + const SrcType &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; + typedef SrcType deco_type; + typedef oln_point_type(SrcType) point_type; + typedef oln_dpoint_type(SrcType) dpoint_type; + typedef oln_iter_type(SrcType) iter_type; + typedef oln_fwd_iter_type(SrcType) fwd_iter_type; + typedef oln_bkd_iter_type(SrcType) bkd_iter_type; + typedef oln_value_type(SrcType) value_type; + typedef oln_size_type(SrcType) size_type; /// Underlying implementation of the decorated image. - typedef oln_impl_type(Deco) impl_type; + typedef oln_impl_type(SrcType) impl_type; /// Exact type of the decorated image. - typedef oln_exact_type(Deco) image_type; + typedef SrcType image_type; - typedef typename gm_inherit<Inherit, Exact>::ret super_type; + typedef typename gm_inherit<DestType, Exact>::ret super_type; /// Return the decorated image. - const Deco& + const SrcType& get_ima() const { - return this->Ima_; + return ima_; } - /// Return the value stored at \a p in the decorated image. + /*! Default implementation of at. + ** + ** 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 to_exact(ima_).at(p); } - /// Return a reference to the value stored at \a p in the decorated image. + /*! Defaults implementation of at. + ** + ** 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 to_exact(ima_).at(p); } - /// Return a pointer to the value container of the decorated image. + /// Default implementation of impl. const impl_type* impl() const { - return this->Ima_.exact().impl(); + return to_exact(ima_).impl(); } - /// Return a pointer to the value container of the decorated image. + /// Default implementation of impl. impl_type* impl() { - return this->Ima_.exact().impl(); + return to_exact(ima_).impl(); } - /// Return a copy of the decorated image. + /*! Default implementation of clone_. + ** + ** Return a copy of the decorated image. + */ image_type clone_() const { - return this->Ima_.exact().clone_(); + return to_exact(ima_).clone_(); } - /// Return the size of the decorated image. + /*! Default implementation of npoints_. + ** + ** Return the size of the decorated image. + */ size_t npoints_() { - return this->Ima_.exact().npoints_(); + return to_exact(ima_).npoints_(); } - /// Assign \a rhs to the decorated image. + /*! Default implementation of assign. + ** + ** Assign \a rhs to the decorated image. + */ image_type& assign(deco_type& rhs) { - return this->Ima_.exact().assign(rhs); + return to_exact(ima_).assign(rhs); } - /// Assign the decorated image to \a r + /*! Default implementation of operator=. + ** + ** Assign the decorated image to \a r. + */ deco_type& operator=(const oln::io::internal::anything& r) { - return r.assign(this->Ima_); + return r.assign(ima_); } - /*! \brief Set the border width of the decorated image to + /*! Default implementation of border_set_width. + ** + ** 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); + return to_exact(ima_).border_set_width(min_border, copy_border); } - static std::string name() - { return "generic_morpher<" + super_type::name() + ">"; } + static std::string + name() + { + return "generic_morpher<" + super_type::name() + ">"; + } }; -- Damien Thivolle damien.thivolle@lrde.epita.fr

- /// Default Constructor. - generic_morpher(): Ima(Deco()) {} + /// Empty Constructor. + generic_morpher(): ima_(SrcType()) {} Même question que dans l'autre poste. Teste ce constructeur.
+ typedef SrcType deco_type;
+ typedef oln_point_type(SrcType) point_type; + typedef oln_dpoint_type(SrcType) dpoint_type; + typedef oln_iter_type(SrcType) iter_type; + typedef oln_fwd_iter_type(SrcType) fwd_iter_type; + typedef oln_bkd_iter_type(SrcType) bkd_iter_type; + typedef oln_value_type(SrcType) value_type; + typedef oln_size_type(SrcType) size_type;
/// Underlying implementation of the decorated image. - typedef oln_impl_type(Deco) impl_type; + typedef oln_impl_type(SrcType) impl_type;
/// Exact type of the decorated image. - typedef oln_exact_type(Deco) image_type; + typedef SrcType image_type; Tu n'as peut-etre pas eu le temps de répondre à toutes les questions de mon poste précédant, mais je posais la question suivante: Le type de point d'un morpher décorant une image2d (IN) en image3d (OUT), est-il point2d ou bien point3d? Pour moi c'est un point3d. Si tu penses la même chose, merci de changer les: typedef oln_TOTO_type(SrcType) TOTO_type; en typedef oln_TOTO_type(DestType) TOTO_type; (Je ne suis pas sur de moi, j'hésite entre DestType et upper_type, i.e. j'hésite entre le type d'image dont le exact_type n'est pas un morpher et celui dont le exact_type est un morpher).
+ typedef SrcType deco_type; typedef SrcType src_type; Non?
+ typedef SrcType image_type; ? (cf 5 lignes plus haut)
-- Niels

+ typedef oln_point_type(SrcType) point_type; + typedef oln_dpoint_type(SrcType) dpoint_type; + typedef oln_iter_type(SrcType) iter_type; + typedef oln_fwd_iter_type(SrcType) fwd_iter_type; + typedef oln_bkd_iter_type(SrcType) bkd_iter_type; + typedef oln_value_type(SrcType) value_type; + typedef oln_size_type(SrcType) size_type;
/// Underlying implementation of the decorated image. - typedef oln_impl_type(Deco) impl_type; + typedef oln_impl_type(SrcType) impl_type;
/// Exact type of the decorated image. - typedef oln_exact_type(Deco) image_type; + typedef SrcType image_type;
Tu n'as peut-etre pas eu le temps de répondre à toutes les questions de mon poste précédant, mais je posais la question suivante: Le type de point d'un morpher décorant une image2d (IN) en image3d (OUT), est-il point2d ou bien point3d? Pour moi c'est un point3d. Si tu penses la même chose, merci de changer les: typedef oln_TOTO_type(SrcType) TOTO_type; en typedef oln_TOTO_type(DestType) TOTO_type; (Je ne suis pas sur de moi, j'hésite entre DestType et upper_type, i.e. j'hésite entre le type d'image dont le exact_type n'est pas un morpher et celui dont le exact_type est un morpher).
Désolé, je ne voulais pas poster ça, mozilla a planté. De toutes façons on vient d'en discuter, le problème n'est pas là mais dans l'utilisation de traits pour récupérer les différents types. Désolé, -- Niels
participants (3)
-
Akim Demaille
-
Damien Thivolle
-
Niels Van Vliet