935: Add a couple of morphers: ''read/write count'' and ''f:v->v applied on image''.

https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Add a couple of morphers: ''read/write count'' and ''f:v->v applied on image''. * oln/core/gen/rw_count_image.hh: New. * oln/core/internal/op_fv2v_applied_on_image.hh: New. * oln/core/gen/neighb.hh: Update. * oln/core/gen/inplace.hh (inplace): Remove const. * oln/core/gen/op.hh (oln_decl_op_applied_on, applied_on): New. * oln/core/internal/image_base.hh (value_morpher_): New. * oln/core/internal/category_of.hh (oln_strip_, strip_): Remove. * oln/core/internal/point_set_base.hh: Update. * oln/core/internal/image_ops.hh: Update. (operator<<): New specializations. * oln/stc/scoop.hh (stc_is_not_found_type): New. * oln/level/fill.hh (fill): New inplace versions. * oln/level/local.hh: Fix window versions. * oln/level/clone.hh: Update. core/gen/inplace.hh | 7 core/gen/neighb.hh | 1 core/gen/op.hh | 4 core/gen/rw_count_image.hh | 227 ++++++++++++++++++++++++++++++ core/internal/category_of.hh | 36 ---- core/internal/image_base.hh | 33 ++++ core/internal/image_ops.hh | 49 +++++- core/internal/op_fv2v_applied_on_image.hh | 193 +++++++++++++++++++++++++ core/internal/point_set_base.hh | 2 level/clone.hh | 18 +- level/fill.hh | 41 +++++ level/local.hh | 8 - stc/scoop.hh | 2 13 files changed, 563 insertions(+), 58 deletions(-) Index: oln/core/gen/neighb.hh --- oln/core/gen/neighb.hh (revision 934) +++ oln/core/gen/neighb.hh (working copy) @@ -40,6 +40,7 @@ // Op. oln_decl_op_extended_by(Image, Neighborhood); + oln_decl_inplace_image_op(extended_by, +, Neighborhood); Index: oln/core/gen/rw_count_image.hh --- oln/core/gen/rw_count_image.hh (revision 0) +++ oln/core/gen/rw_count_image.hh (revision 0) @@ -0,0 +1,227 @@ +// 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 OLN_CORE_GEN_RW_COUNT_IMAGE_HH +# define OLN_CORE_GEN_RW_COUNT_IMAGE_HH + +# include <oln/core/internal/image_base.hh> +# include <oln/core/internal/value_proxy.hh> +# include <oln/core/gen/inplace.hh> + + +namespace oln +{ + +# define current rw_count_image<I> + + + // Fwd decl. + template <typename I> class rw_count_image; + + + /// Virtual types. + template <typename I> + struct vtypes< current > + { + typedef I delegatee; + typedef behavior::identity behavior; + + typedef typename mlc::if_< stc_is_found_type(I, lvalue), + internal::value_proxy_< current >, + stc::not_delegated >::ret lvalue; + + typedef internal::triplet<I, unsigned, unsigned> data; + + typedef rw_count_image< oln_plain(I) > plain; + typedef rw_count_image< pl::rec<I> > skeleton; + }; + + + /// Super type. + template <typename I> + struct super_trait_< current > + { + typedef internal::single_image_morpher_< current > ret; + }; + + + /// Class to count the number of read and write in images. + + template <typename I> + class rw_count_image : public internal::single_image_morpher_< current > + { + typedef internal::single_image_morpher_< current > super; + public: + + stc_using(point); + stc_using(rvalue); + stc_using(lvalue); + stc_using(value); + stc_using(data); + stc_using(delegatee); + + rw_count_image(); + rw_count_image(Mutable_Image<I>& ima); + + rvalue impl_read(const point& p) const; + lvalue impl_read_write(const point& p); + void impl_write(const point& p, const value& v); + + delegatee& impl_image(); + const delegatee& impl_image() const; + + unsigned nreads() const; + unsigned nwrites() const; + + }; // end of rw_count_image<I> + + + template <typename I, typename D> + bool prepare(rw_count_image<I>& target, with_t, const D& dat); + + + template <typename I> + current rw_count(Mutable_Image<I>& ima); + + template <typename I> + inplace_< current > rw_count(inplace_<I> ima); + + + +# ifndef OLN_INCLUDE_ONLY + + template <typename I> + current::rw_count_image() + { + } + + template <typename I> + current::rw_count_image(Mutable_Image<I>& ima) + { + precondition(exact(ima).has_data()); + unsigned nreads = 0, nwrites = 0; + this->data_ = new data(exact(ima), nreads, nwrites); + } + + template <typename I> + typename current::rvalue + current::impl_read(const typename current::point& p) const + { + assert(this->has_data()); + assert(this->image().has_data()); + const_cast<unsigned&>(this->data_->second) += 1; + return this->data_->first(p); + } + + template <typename I> + typename current::lvalue + current::impl_read_write(const typename current::point& p) + { + assert(this->has_data()); + assert(this->image().has_data()); + lvalue tmp(*this, p); + return tmp; + } + + template <typename I> + void + current::impl_write(const typename current::point& p, + const typename current::value& v) + { + assert(this->has_data()); + assert(this->image().has_data()); + this->data_->third += 1; + this->image().write_(p, v); + } + + template <typename I> + typename current::delegatee& + current::impl_image() + { + assert(this->has_data()); + return this->data_->first; + } + + template <typename I> + const typename current::delegatee& + current::impl_image() const + { + assert(this->has_data()); + return this->data_->first; + } + + template <typename I> + unsigned + current::nreads() const + { + assert(this->has_data()); + return this->data_->second; + } + + template <typename I> + unsigned + current::nwrites() const + { + assert(this->has_data()); + return this->data_->third; + } + + template <typename I> + current rw_count(Mutable_Image<I>& ima) + { + current tmp(ima); + return tmp; + } + + template <typename I> + inplace_< current > rw_count(inplace_<I> ima) + { + current tmp_ = rw_count(ima.unwrap()); + inplace_< current > tmp(tmp_); + return tmp; + } + + template <typename I, typename D> + bool prepare(rw_count_image<I>& target, with_t, const D& dat) + { + precondition(not target.has_data()); + target.data__() = new typename rw_count_image<I>::data; + bool ima_ok = prepare(target.data__()->first, with, dat); + target.data__()->second = 0; + target.data__()->third = 0; + postcondition(ima_ok); + return ima_ok; + } + +# endif // ! OLN_INCLUDE_ONLY + +# undef current + +} // end of namespace oln + + +#endif // ! OLN_CORE_GEN_RW_COUNT_IMAGE_HH Index: oln/core/gen/inplace.hh --- oln/core/gen/inplace.hh (revision 934) +++ oln/core/gen/inplace.hh (working copy) @@ -54,7 +54,7 @@ template <typename I> inplace_<I> - inplace(const Mutable_Image<I>& ima); + inplace(Mutable_Image<I>& ima); @@ -82,10 +82,9 @@ template <typename I> inplace_<I> - inplace(const Mutable_Image<I>& ima) + inplace(Mutable_Image<I>& ima) { - I& ima_ = const_cast<I&>(exact(ima)); - inplace_<I> tmp(ima_); + inplace_<I> tmp(exact(ima)); return tmp; } Index: oln/core/gen/op.hh --- oln/core/gen/op.hh (revision 934) +++ oln/core/gen/op.hh (working copy) @@ -83,7 +83,7 @@ operator OpSym (inplace_<L> lhs, Rconcept<R>& rhs) \ { \ mlc::assert_< mlc_is_a(L, Mutable_Image) >::check(); \ - op_<L, OpName, R> tmp(exact(lhs), exact(rhs)); \ + op_<L, OpName, R> tmp(lhs.unwrap(), exact(rhs)); \ return inplace(tmp); \ } \ \ @@ -95,6 +95,7 @@ # define oln_decl_op_such_as(Lconcept, Rconcept) oln_decl_op_( such_as, Lconcept, |, Rconcept) # define oln_decl_op_restricted_to(Lconcept, Rconcept) oln_decl_op_( restricted_to, Lconcept, |, Rconcept) # define oln_decl_op_over(Lconcept, Rconcept) oln_decl_op_( over, Lconcept, /, Rconcept) +# define oln_decl_op_applied_on(Lconcept, Rconcept) oln_decl_op_( applied_on, Lconcept, <<, Rconcept) // ... @@ -110,6 +111,7 @@ struct such_as; struct restricted_to; struct over; + struct applied_on; /// \} Index: oln/core/internal/point_set_base.hh --- oln/core/internal/point_set_base.hh (revision 934) +++ oln/core/internal/point_set_base.hh (working copy) @@ -154,7 +154,7 @@ op_<const S, such_as, const fun_p2b_<B (*)(P)> > operator | (const Point_Set<S>& lhs, B (*f)(P)) { - typedef oln_strip_(P) P_; + typedef mlc_basic(P) P_; mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg. mlc::assert_equal_< P_, oln_point(S) >::check(); op_<const S, such_as, const fun_p2b_<B (*)(P)> > tmp(exact(lhs), f); Index: oln/core/internal/image_ops.hh --- oln/core/internal/image_ops.hh (revision 934) +++ oln/core/internal/image_ops.hh (working copy) @@ -32,6 +32,7 @@ # include <oln/core/internal/op_image_restricted_to_pset.hh> # include <oln/core/internal/op_image_such_as_fp2b.hh> # include <oln/core/internal/op_fp2v_over_pset.hh> +# include <oln/core/internal/op_fv2v_applied_on_image.hh> # include <oln/core/gen/literal.hh> @@ -59,6 +60,10 @@ oln_decl_op_over(Function_p2v, Point_Set); + // Function_v2v << Image ( f(ima), i.e., for all p, ( f(ima) )(p) = f( ima(p) ) ) + + oln_decl_op_applied_on(Function_v2v, Image); + // Specialization "f : P -> V over Point_Set". @@ -67,7 +72,7 @@ op_<const fun_p2v_<V (*)(P)>, over, const S> operator / (V (*f)(P), const Point_Set<S>& pts) { - typedef oln_strip_(P) P_; + typedef mlc_basic(P) P_; mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg. mlc::assert_equal_< P_, oln_point(S) >::check(); op_<const fun_p2v_<V (*)(P)>, over, const S> tmp(f, exact(pts)); @@ -93,7 +98,7 @@ op_<const I, such_as, const fun_p2b_<B (*)(P)> > operator | (const Image<I>& ima, B (*f)(P)) { - typedef oln_strip_(P) P_; + typedef mlc_basic(P) P_; mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg. mlc::assert_equal_< P_, oln_point(I) >::check(); op_<const I, such_as, const fun_p2b_<B (*)(P)> > tmp(exact(ima), f); @@ -104,7 +109,7 @@ op_<I, such_as, const fun_p2b_<B (*)(P)> > operator | (Mutable_Image<I>& ima, B (*f)(P)) { - typedef oln_strip_(P) P_; + typedef mlc_basic(P) P_; mlc::assert_< mlc_is_a(P_, Point) >::check(); // FIXME: Add err msg. mlc::assert_equal_< P_, oln_point(I) >::check(); op_<I, such_as, const fun_p2b_<B (*)(P)> > tmp(exact(ima), f); @@ -115,7 +120,7 @@ inplace_< op_<I, such_as, const fun_p2b_<B (*)(P)> > > operator | (inplace_<I> ima, B (*f)(P)) { - return inplace(ima.unwrap() | f); + return (ima.unwrap() | f).inplace(); } @@ -145,9 +150,43 @@ inplace_< op_<I, such_as, const fun_p2b_< Binary_Image<J> > > > operator | (inplace_<I> ima, const Binary_Image<J>& f_ima_b) { - return inplace(ima.unwrap() | f_ima_b); + return (ima.unwrap() | f_ima_b).inplace(); + } + + + // Specialization + + template <typename W, typename V, typename I> + op_<const fun_v2v_<W (*)(V)>, applied_on, const I> + operator << (W (*f)(V), const Image<I>& ima) + { + op_<const fun_v2v_<W (*)(V)>, applied_on, const I> tmp(f, exact(ima)); + return tmp; } + template <typename W, typename V, typename I> + op_<const fun_v2v_<W (*)(V)>, applied_on, I> + operator << (W (*f)(V), Mutable_Image<I>& ima) + { + op_<const fun_v2v_<W (*)(V)>, applied_on, I> tmp(f, exact(ima)); + return tmp; + } + + template <typename W, typename V, typename I> + inplace_< op_<const fun_v2v_<W (*)(V)>, applied_on, I> > + operator << (W (*f)(V), inplace_<I> ima) + { + return (f << ima.unwrap()).inplace(); + } + + template <typename F, typename I> + inplace_< op_<const F, applied_on, I> > + operator << (const Function_v2v<F>& f, inplace_<I> ima) + { + return (exact(f) << ima.unwrap()).inplace(); + } + + } // end of namespace oln Index: oln/core/internal/image_base.hh --- oln/core/internal/image_base.hh (revision 934) +++ oln/core/internal/image_base.hh (working copy) @@ -74,6 +74,7 @@ template <typename Exact> struct image_morpher_; template <typename Exact> struct single_image_morpher_; template <typename Exact> struct image_extension_; + template <typename Exact> struct value_morpher_; template <typename Exact> struct multiple_image_morpher_; } @@ -117,6 +118,12 @@ }; template <typename Exact> + struct super_trait_< internal::value_morpher_<Exact> > + { + typedef internal::single_image_morpher_<Exact> ret; + }; + + template <typename Exact> struct super_trait_< internal::multiple_image_morpher_<Exact> > { typedef internal::image_morpher_<Exact> ret; @@ -198,6 +205,15 @@ }; template <typename Exact> + struct vtypes< internal::value_morpher_<Exact> > + { + typedef stc::final< behavior::identity > behavior; + typedef stc::not_delegated value; + typedef stc::not_delegated lvalue; + typedef stc::not_delegated rvalue; + }; + + template <typename Exact> struct vtypes< internal::multiple_image_morpher_<Exact> > { typedef stc::abstract n; @@ -307,6 +323,16 @@ }; + /// value_morpher_<Exact> + + template <typename Exact> + class value_morpher_ : public single_image_morpher_<Exact> + { + protected: + value_morpher_(); + }; + + /// multiple_image_morpher_<Exact> template <typename Exact> @@ -410,6 +436,13 @@ { } + // value_morpher_<Exact> + + template <typename Exact> + value_morpher_<Exact>::value_morpher_() + { + } + // multiple_image_morpher_<Exact> template <typename Exact> Index: oln/core/internal/op_fv2v_applied_on_image.hh --- oln/core/internal/op_fv2v_applied_on_image.hh (revision 0) +++ oln/core/internal/op_fv2v_applied_on_image.hh (revision 0) @@ -0,0 +1,193 @@ +// 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 OLN_CORE_INTERNAL_OP_FV2V_APPLIED_ON_IMAGE_HH +# define OLN_CORE_INTERNAL_OP_FV2V_APPLIED_ON_IMAGE_HH + +# include <oln/core/internal/image_base.hh> +# include <oln/core/concept/function.hh> +# include <oln/core/gen/op.hh> + + +namespace oln +{ + + +# define current \ + special_op_< stc::is<Function_v2v>, F, applied_on, stc::is<Image>, I > + + + // Fwd decl. + namespace internal { template <typename F, typename I> class current; } + + + // Super type. + template <typename F, typename I> + struct super_trait_< internal::current > + { + typedef internal::value_morpher_< op_<F, applied_on, I> > ret; + }; + + +# define super \ + super_trait_< internal::current >::ret + + + // Virtual types. + template <typename F, typename I> + struct vtypes< internal::current > + { + typedef I delegatee; + typedef internal::pair<I,F> data; + + typedef oln_result(F) rvalue; + typedef mlc_basic(rvalue) value; + + typedef typename mlc::if_< mlc::and_list_< mlc_is_not_const(I), + stc_is_found_type(I, lvalue), + mlc_is_reference(oln_result(F)), + mlc_is_not_const(oln_result(F)) >, + stc_find_type(I, lvalue), + stc::not_delegated >::ret lvalue; + + typedef op_<F, applied_on, oln_plain(I)> plain; + typedef op_<F, applied_on, pl::rec<I> > skeleton; + }; + + + namespace internal + { + + /// Implementation class for the result of "Function_v2v F << Image I". + + template <typename F, typename I> + class current : public super + { + typedef op_<F, applied_on, I> Exact; + public: + + stc_using(delegatee); + stc_using(data); + + stc_using(psite); + stc_using(value); + stc_using(rvalue); + typedef stc_find_type(Exact, lvalue) lvalue; // FIXME: macro; propagate in similar classes. + + delegatee& impl_image(); + const delegatee& impl_image() const; + + rvalue impl_read(const psite& p) const; + lvalue impl_read_write(const psite& p); + void impl_write(const psite& p, const value& v); + + const F& fun() const; + + protected: + special_op_(); + special_op_(F& f, I& ima); + }; + + +# ifndef OLN_INCLUDE_ONLY + + template <typename F, typename I> + current::special_op_() + { + } + + template <typename F, typename I> + current::special_op_(F& f, I& ima) + { + this->data_ = new data(ima, f); + } + + template <typename F, typename I> + typename current::delegatee& + current::impl_image() + { + assert(this->has_data()); + return this->data_->first; + } + + template <typename F, typename I> + const typename current::delegatee& + current::impl_image() const + { + assert(this->has_data()); + return this->data_->first; + } + + template <typename F, typename I> + typename current::rvalue + current::impl_read(const typename current::psite& p) const + { + assert(this->image().has_data()); + return this->fun()(this->image()(p)); + } + + template <typename F, typename I> + typename current::lvalue + current::impl_read_write(const typename current::psite& p) + { + assert(this->image().has_data()); + return this->fun()(this->image()(p)); + } + + template <typename F, typename I> + void + current::impl_write(const typename current::psite& p, + const typename current::value& v) + { + assert(this->image().has_data()); + this->image()(p) = v; + } + + template <typename F, typename I> + const F& + current::fun() const + { + assert(this->has_data()); + return this->data_->second; + } + +# endif // ! OLN_INCLUDE_ONLY + + } // end of namespace oln::internal + + + // FIXME: Add init. + + +# undef super +# undef current + + +} // end of namespace oln + + +#endif // ! OLN_CORE_INTERNAL_OP_FV2V_APPLIED_ON_IMAGE_HH Index: oln/core/internal/category_of.hh --- oln/core/internal/category_of.hh (revision 934) +++ oln/core/internal/category_of.hh (working copy) @@ -28,9 +28,10 @@ #ifndef OLN_CORE_INTERNAL_CATEGORY_OF_HH # define OLN_CORE_INTERNAL_CATEGORY_OF_HH +# include <mlc/basic.hh> + # define oln_category_of_(Type) typename oln::internal::category_of_< Type >::ret -# define oln_strip_(Type) typename oln::internal::strip_< Type >::ret namespace oln @@ -44,36 +45,6 @@ namespace internal { - // Strip_ - - - template <typename T> - struct strip_ - { - typedef T ret; - }; - - template <typename T> - struct strip_< T* > - { - typedef typename strip_<T>::ret ret; - }; - - template <typename T> - struct strip_< T& > - { - typedef typename strip_<T>::ret ret; - }; - - template <typename T> - struct strip_< const T > - { - typedef typename strip_<T>::ret ret; - }; - - - - // Category_of_ @@ -93,8 +64,7 @@ template <typename T> struct category_of_ { - typedef typename strip_<T>::ret T_; - typedef typename set_category_of_<T_>::ret ret; + typedef typename set_category_of_< mlc_basic(T) >::ret ret; }; // ... Index: oln/stc/scoop.hh --- oln/stc/scoop.hh (revision 934) +++ oln/stc/scoop.hh (working copy) @@ -35,6 +35,7 @@ # include <mlc/abort.hh> # include <mlc/bool.hh> # include <mlc/pair.hh> +# include <mlc/basic.hh> # include <mlc/cmp.hh> # include <mlc/if.hh> # include <mlc/is_a.hh> @@ -119,6 +120,7 @@ # define stc_type_is_not_found(Type) stc::is_not_found< stc_deferred(Type) > # define stc_is_found_type(From, Type) stc::is_found< stc_deferred_type(From, Type) > +# define stc_is_not_found_type(From, Type) stc::is_not_found< stc_deferred_type(From, Type) > Index: oln/level/fill.hh --- oln/level/fill.hh (revision 934) +++ oln/level/fill.hh (working copy) @@ -34,6 +34,7 @@ # include <oln/core/concept/image.hh> # include <oln/core/concept/point.hh> # include <oln/core/gen/fun.hh> +# include <oln/core/gen/inplace.hh> @@ -68,6 +69,20 @@ // template <typename I> // void fill(Value_Wise_Mutable_Image<I>& target, const oln_value(I)& value); + // versions for temporary images + + template <typename I> + void fill(inplace_<I> target, /* with */ const oln_value(I)& value); + + template <typename I, typename J> + void fill(inplace_<I> target, /* with */ const Image<J>& data); + + template <typename I, typename F> + void fill(inplace_<I> target, /* with */ const Function_p2v<F>& fun); + + template <typename I, typename V, typename P> + void fill(inplace_<I> target, /* with */ V (*fun)(P)); + # ifndef OLN_INCLUDE_ONLY @@ -141,6 +156,32 @@ impl::fill_from_function_(exact(target), functorize_p2v(f)); } + // with inplace_<I> + + template <typename I> + void fill(inplace_<I> target, const oln_value(I)& value) + { + fill(target.unwrap(), value); + } + + template <typename I, typename J> + void fill(inplace_<I> target, const Image<J>& data) + { + fill(target.unwrap(), data); + } + + template <typename I, typename F> + void fill(inplace_<I> target, const Function_p2v<F>& fun) + { + fill(target.unwrap(), fun); + } + + template <typename I, typename V, typename P> + void fill(inplace_<I> target, V (*fun)(P)) + { + fill(target.unwrap(), fun); + } + # endif // ! OLN_INCLUDE_ONLY } // end of namespace oln::level Index: oln/level/local.hh --- oln/level/local.hh (revision 934) +++ oln/level/local.hh (working copy) @@ -129,7 +129,7 @@ const oln_point(I)& p, const Window<W>& win) { - f.init_with(input(p)); + f.init(); oln_qiter(W) q(p, win); for_all(q) if (input.owns_(q)) @@ -146,9 +146,7 @@ const oln_point(I)& p, const Window<W>& win) { - f.init_with(input(p)); - if (f.value() = true) - return true; + f.init(); oln_qiter(W) q(p, win); for_all(q) { @@ -169,7 +167,7 @@ const oln_point(I)& p, const Window<W>& win) { - f.init_with(input(p)); + f.init(); oln_qiter(W) q(p, win); for_all(q) { Index: oln/level/clone.hh --- oln/level/clone.hh (revision 934) +++ oln/level/clone.hh (working copy) @@ -29,7 +29,8 @@ #ifndef OLN_LEVEL_CLONE_HH # define OLN_LEVEL_CLONE_HH -# include <oln/core/concept/image.hh> +# include <oln/level/fill.hh> + namespace oln { @@ -37,7 +38,7 @@ namespace level { - /// Fwd decl. + // Fwd decl. template <typename I> oln_plain(I) clone(const Image<I>& input); @@ -47,28 +48,27 @@ namespace impl { - /// Generic version. + // Generic version. template <typename I> oln_plain(I) clone(const Image<I>& input) { - oln_plain(I) output(input.points()); - oln_piter(I) p(input.points()); - for_all(p) - output(p) = input(p); + oln_plain(I) output; + prepare(output, with, input); + level::fill(output, input); return output; } } // end of namespace oln::level::impl - /// Facade. + // Facade. template <typename I> oln_plain(I) clone(const Image<I>& input) { return impl::clone(input); } -# endif +# endif // ! OLN_INCLUDE_ONLY } // end of namespace oln::level
participants (1)
-
Thierry Geraud