
https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Thierry Geraud <thierry.geraud@lrde.epita.fr> Add traits and fix compile errors. * oln/core/gen/traits.hh, * oln/value/builtin.hh: New. * oln/arith/plus.hh (include): Fix. (set_trait_): New. (operator +): Update sig and use 'prepare'. * oln/arith/minus.hh: Likewise. * oln/core/concept/image.hh (Fast_Image): Fix. * oln/core/concept/point.hh (set_trait_): New. (assert_same_point_): New. * oln/core/concept/generalised_point.hh: Fix. * oln/core/concept/dpoint.hh (set_trait_): New. * oln/core/concept/operators.hh (include): Add oln/core/gen/traits.hh. * oln/core/init.hh: Cosmetic change. * oln/core/2d/image2d_b.hh (prepare): Fix. * oln/core/2d/box2d.hh (box2d): Fix. * oln/core/gen/fun.hh (fun_p2b_, fun_v2v_): Add & to ctor arg. (fun_p2v_, functorize_p2v): New. * oln/core/internal/box.hh: Cosmetic changes. * oln/core/internal/image_base.hh (operator |): Activate test. * oln/core/internal/iterator_on_points_base.hh: Fix. * oln/morpher/add_isubset.hh, * oln/morpher/add_isubset.hxx, * oln/morpher/add_neighborhood.hxx: Remove; obsolete. * oln/level/fill.hh (include): Update. (fill): Rename the internal routines as... (fill_from_value_, fill_from_values_): ...these... (fill_from_image_, fill_from_function_): ...and these. (fill_): Activate. (fill): Activate version for Function_p2v. (fill): New version for Image. arith/minus.hh | 35 +++-- arith/plus.hh | 33 +++-- core/2d/box2d.hh | 6 core/2d/image2d_b.hh | 2 core/concept/dpoint.hh | 23 +++ core/concept/generalised_point.hh | 11 - core/concept/image.hh | 2 core/concept/operators.hh | 2 core/concept/point.hh | 38 +++++ core/gen/fun.hh | 65 +++++++++- core/gen/traits.hh | 199 +++++++++++++++++++++++++++++++ core/init.hh | 2 core/internal/box.hh | 13 +- core/internal/image_base.hh | 6 core/internal/iterator_on_points_base.hh | 7 - level/fill.hh | 92 +++++++------- value/builtin.hh | 98 +++++++++++++++ 17 files changed, 534 insertions(+), 100 deletions(-) Index: oln/level/fill.hh --- oln/level/fill.hh (revision 914) +++ oln/level/fill.hh (working copy) @@ -29,8 +29,12 @@ #ifndef OLN_LEVEL_FILL_HH # define OLN_LEVEL_FILL_HH +#include <iostream> + # include <oln/core/concept/image.hh> -// # include <oln/core/concept/function.hh> +# include <oln/core/concept/point.hh> +# include <oln/core/gen/fun.hh> + namespace oln @@ -38,7 +42,7 @@ namespace ERROR { - struct FIRST_ARGUMENT_OF_oln_level_fill_IS_NOT_MUTABLE; + struct FIRST_ARGUMENT_OF_oln_level_fill_IS_NOT_MUTABLE; // FIXME: Use it! } @@ -53,16 +57,17 @@ template <typename I, typename V> void fill(Mutable_Image<I>& input, const V values[]); - template <typename I, typename V, typename P> - void fill(Mutable_Image<I>& input, V (*fun)(P)); + template <typename I, typename J> + void fill(Mutable_Image<I>& input, const Image<J>& ima); + template <typename I, typename F> + void fill(Mutable_Image<I>& input, const Function_p2v<F>& fun); + template <typename I, typename V, typename P> + void fill(Mutable_Image<I>& input, V (*fun)(P)); // FIXME: Inactivated. -// template <typename I, typename F> -// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun); - // template <typename I> // void fill(Value_Wise_Mutable_Image<I>& input, const oln_value(I)& value); @@ -74,24 +79,15 @@ { template <typename I> - void fill(Mutable_Image<I>& input, const oln_value(I)& value) + void fill_from_value_(Mutable_Image<I>& input, const oln_value(I)& value) { oln_piter(I) p(input.points()); for_all(p) input(p) = value; } -// template <typename I> -// void fill(Value_Wise_Mutable_Image<I>& input, -// const oln_value(I)& value) -// { -// oln_viter(I) v(input); -// for_all(v) -// input.value_(v) = value; -// } - template <typename I, typename V> - void fill(Mutable_Image<I>& input, const V values[]) + void fill_from_values_(Mutable_Image<I>& input, const V values[]) { oln_piter(I) p(input.points()); unsigned i = 0; @@ -99,20 +95,29 @@ input(p) = values[i++]; } - template <typename I, typename V, typename P> - void fill(Mutable_Image<I>& input, V (*fun)(P)) + template <typename I, typename J> + void fill_from_image_(Mutable_Image<I>& input, const Image<J>& ima) { oln_piter(I) p(input.points()); for_all(p) - input(p) = fun(p); + input(p) = ima(p); } -// template <typename I, typename F> -// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun) + template <typename I, typename F> + void fill_from_function_(Mutable_Image<I>& input, const F& f) + { + oln_piter(I) p(input.points()); + for_all(p) + input(p) = f(p); + } + +// template <typename I> +// void fill_(Value_Wise_Mutable_Image<I>& input, +// const oln_value(I)& value) // { -// oln_piter(I) p(input.points()); -// for_all(p) -// input(p) = fun.exact()(p); +// oln_viter(I) v(input); +// for_all(v) +// input.value_(v) = value; // } } // end of namespace oln::level::impl @@ -124,34 +129,37 @@ template <typename I> void fill(Mutable_Image<I>& input, const oln_value(I)& value) { - impl::fill(exact(input), value); + impl::fill_from_value_(exact(input), value); } template <typename I, typename V> void fill(Mutable_Image<I>& input, const V values[]) { - impl::fill(exact(input), values); + impl::fill_from_values_(exact(input), values); } - template <typename I, typename V, typename P> - void fill(Mutable_Image<I>& input, V (*fun)(P)) + template <typename I, typename J> + void fill(Mutable_Image<I>& input, const Image<J>& ima) { - impl::fill(exact(input), fun); + assert_same_grid_<I, J>::check(); + precondition(input.points() <= ima.points()); + impl::fill_from_image_(exact(input), exact(ima)); } -// template <typename I, typename F> -// void fill(Mutable_Image<I>& input, const abstract::fun_p2v<F>& fun) -// { -// impl::fill(exact(input), fun); -// } + template <typename I, typename F> + void fill(Mutable_Image<I>& input, const Function_p2v<F>& fun) + { + impl::fill_from_function_(exact(input), exact(fun)); + } -// template <typename I> -// void fill(Value_Wise_Mutable_Image<I>& input, const oln_value(I)& value) -// { -// impl::fill(exact(input), value); -// } + template <typename I, typename V, typename P> + void fill(Mutable_Image<I>& input, V (*f)(P)) + { + mlc::assert_< mlc_is_a(P, Point) >::check(); // FIXME: Add err msg. + impl::fill_from_function_(exact(input), functorize_p2v(f)); + } -# endif +# endif // ! OLN_INCLUDE_ONLY } // end of namespace oln::level Index: oln/arith/plus.hh --- oln/arith/plus.hh (revision 914) +++ oln/arith/plus.hh (working copy) @@ -28,27 +28,40 @@ #ifndef OLN_ARITH_PLUS_HH # define OLN_ARITH_PLUS_HH +# include <oln/core/concept/image.hh> +// # include <oln/core/internal/f_ch_value.hh> +# include <oln/core/gen/traits.hh> + namespace oln { - namespace arith + + // Trait. + + template <typename I, typename J> + struct set_trait_< Image, I, plus_id, Image, J > { + typedef oln_plus_trait(oln_value(I), oln_value(J)) V; + typedef oln_plain_value(I, V) ret; + }; // Fwd decl. - template <typename I> - oln_plain(I) - operator + (const Image<I>& lhs, const Image<I>& rhs); + template <typename I, typename J> + oln_plus_trait(I, J) + operator + (const Image<I>& lhs, const Image<J>& rhs); + # ifndef OLN_INCLUDE_ONLY - template <typename I> - oln_plain(I) - operator + (const Image<I>& lhs, const Image<I>& rhs) + template <typename I, typename J> + oln_plus_trait(I, J) + operator + (const Image<I>& lhs, const Image<J>& rhs) { - oln_plain(I) output; - init(output, with, lhs); + precondition(lhs.points() = rhs.points()); + oln_plus_trait(I, J) output; + prepare(output, with, lhs); oln_piter(I) p(lhs.points()); for_all(p) output(p) = lhs(p) + rhs(p); @@ -57,8 +70,6 @@ # endif // ! OLN_INCLUDE_ONLY - } // end of namespace oln::arith - } // end of namespace oln #endif // ! OLN_ARITH_PLUS_HH Index: oln/arith/minus.hh --- oln/arith/minus.hh (revision 914) +++ oln/arith/minus.hh (working copy) @@ -28,27 +28,40 @@ #ifndef OLN_ARITH_MINUS_HH # define OLN_ARITH_MINUS_HH +# include <oln/core/concept/image.hh> +// # include <oln/core/internal/f_ch_value.hh> +# include <oln/core/gen/traits.hh> + namespace oln { -// namespace arith -// { + // Trait. + + template <typename I, typename J> + struct set_trait_< Image, I, minus_id, Image, J > + { + typedef oln_minus_trait(oln_value(I), oln_value(J)) V; + typedef oln_plain_value(I, V) ret; + }; + // Fwd decl. - template <typename I> - oln_plain(I) - operator - (const Image<I>& lhs, const Image<I>& rhs); + template <typename I, typename J> + oln_minus_trait(I, J) + operator - (const Image<I>& lhs, const Image<J>& rhs); + # ifndef OLN_INCLUDE_ONLY - template <typename I> - oln_plain(I) - operator - (const Image<I>& lhs, const Image<I>& rhs) + template <typename I, typename J> + oln_minus_trait(I, J) + operator - (const Image<I>& lhs, const Image<J>& rhs) { - oln_plain(I) output; - init(output, with, lhs); + precondition(lhs.points() = rhs.points()); + oln_minus_trait(I, J) output; + prepare(output, with, lhs); oln_piter(I) p(lhs.points()); for_all(p) output(p) = lhs(p) - rhs(p); @@ -57,8 +70,6 @@ # endif // ! OLN_INCLUDE_ONLY -// } // end of namespace oln::arith - } // end of namespace oln #endif // ! OLN_ARITH_MINUS_HH Index: oln/core/concept/image.hh --- oln/core/concept/image.hh (revision 914) +++ oln/core/concept/image.hh (working copy) @@ -200,7 +200,7 @@ public automatic::get_impl<Fast_Image, Exact> { stc_using_from(Image, rvalue); - stc_using_from(Image, lvalue); + stc_using_from(Mutable_Image, lvalue); stc_typename(index); Index: oln/core/concept/point.hh --- oln/core/concept/point.hh (revision 914) +++ oln/core/concept/point.hh (working copy) @@ -72,9 +72,18 @@ }; // end of oln::Point<Exact> + /// Operator -. + template <typename P> - typename P::dpoint operator-(const Point<P>& lhs, const Point<P>& rhs); + struct set_trait_< Point, P, minus_id, Point, P > + { + typedef typename P::dpoint ret; + }; + + template <typename P> + typename P::dpoint + operator - (const Point<P>& lhs, const Point<P>& rhs); @@ -91,6 +100,28 @@ + namespace ERROR + { + + template < typename Type_1, + typename Type_2, + typename Point_1 = oln_point(Type_1), + typename Point_2 = oln_point(Type_2) > + struct both_types_should_have_the_same_point_ + { + }; + + } // end of namespace oln::ERROR + + + template <typename T1, typename T2> + struct assert_same_point_ + : public mlc::assert_< mlc::eq_<oln_point(T1), oln_point(T2)>, + ERROR::both_types_should_have_the_same_point_<T1, T2> > + {}; + + + # ifndef OLN_INCLUDE_ONLY @@ -134,12 +165,13 @@ } template <typename P> - typename P::dpoint operator-(const Point<P>& lhs, const Point<P>& rhs) + typename P::dpoint + operator-(const Point<P>& lhs, const Point<P>& rhs) { return lhs.op_minus_(exact(rhs)); } -# endif +# endif // ! OLN_INCLUDE_ONLY } // end of namespace oln Index: oln/core/concept/generalised_point.hh --- oln/core/concept/generalised_point.hh (revision 914) +++ oln/core/concept/generalised_point.hh (working copy) @@ -31,10 +31,6 @@ namespace oln { - /// FIXME: Instant value. - // oln_decl_instant_value(point); - - // Generalised_Point concept template <typename Exact> @@ -58,11 +54,10 @@ template <typename Exact> Generalised_Point<Exact>::Generalised_Point() { - }; - + } -# endif // OLN_INCLUDE_ONLY +# endif // ! OLN_INCLUDE_ONLY -} +} // end of namespace oln #endif // !OLN_CORE_CONCEPT_GENERALISED_POINTS_HH Index: oln/core/concept/dpoint.hh --- oln/core/concept/dpoint.hh (revision 914) +++ oln/core/concept/dpoint.hh (working copy) @@ -80,12 +80,35 @@ }; // end of oln::Dpoint<Exact> + /// \{ + /// Operator "Point - Dpoint". + + template <typename P, typename D> + struct set_trait_< Point, P, minus_id, Dpoint, D > + { + typedef P ret; + }; + template <typename P, typename D> P operator-(const Point<P>& lhs, const Dpoint<D>& rhs); + /// \} + + + /// \{ + /// Operator "Point + Dpoint". + + template <typename P, typename D> + struct set_trait_< Point, P, plus_id, Dpoint, D > + { + typedef P ret; + }; + template <typename P, typename D> P operator+(const Point<P>& lhs, const Dpoint<D>& rhs); + /// \} + /// \{ /// Invalid operators. Index: oln/core/concept/operators.hh --- oln/core/concept/operators.hh (revision 914) +++ oln/core/concept/operators.hh (working copy) @@ -29,6 +29,7 @@ # define OLN_CORE_CONCEPT_OPERATORS_HH # include <oln/core/equipment.hh> +# include <oln/core/gen/traits.hh> namespace oln @@ -76,7 +77,6 @@ - # ifndef OLN_INCLUDE_ONLY template <typename L, typename R> Index: oln/core/init.hh --- oln/core/init.hh (revision 914) +++ oln/core/init.hh (working copy) @@ -181,7 +181,7 @@ } -# endif // OLN_INCLUDE_ONLY +# endif // ! OLN_INCLUDE_ONLY } // end of namespace oln Index: oln/core/2d/image2d_b.hh --- oln/core/2d/image2d_b.hh (revision 914) +++ oln/core/2d/image2d_b.hh (working copy) @@ -250,7 +250,7 @@ bool box_ok = init(b, with, dat); postcondition(box_ok); unsigned border = 2; // FIXME: Use init! - array2d_<T,int> ptr = new array2d_<T,int>(b.pmin().row() - border, + array2d_<T,int>* ptr = new array2d_<T,int>(b.pmin().row() - border, b.pmin().col() - border, b.pmax().row() + border, b.pmax().col() + border); Index: oln/core/2d/box2d.hh --- oln/core/2d/box2d.hh (revision 914) +++ oln/core/2d/box2d.hh (working copy) @@ -63,6 +63,7 @@ public: // Note: we can't use stc_using because box2d isn't a templated class typedef super::point point; + typedef super::from_to_t from_to_t; box2d(); box2d(const box2d::from_to_t& dat); @@ -102,9 +103,10 @@ } template <typename D> - box2d::box2d(const internal::initializer_<D>& data) : - super(data) + box2d::box2d(const internal::initializer_<D>& data) { + bool box_ok = internal::init__(internal::tag::box_t(), *this, data.value()); + postcondition(box_ok); } Index: oln/core/gen/fun.hh --- oln/core/gen/fun.hh (revision 914) +++ oln/core/gen/fun.hh (working copy) @@ -31,6 +31,7 @@ # include <oln/core/internal/category_of.hh> # include <oln/core/concept/function.hh> # include <oln/core/concept/image.hh> +# include <oln/core/concept/point.hh> # include <oln/core/concept/value.hh> @@ -41,6 +42,10 @@ +// FIXME: Separate defs and decls. + + + namespace oln { @@ -105,7 +110,7 @@ typedef oln_arg_of_(F) argument; typedef oln_res_of_(F) result; - fun_p2b_(F f) : f_(f) {} + fun_p2b_(const F& f) : f_(f) {} result operator()(argument arg) const { @@ -138,6 +143,53 @@ + // ----------------------------- fun_p2v_<F> + + + // Fwd decl. + template <typename F> struct fun_p2v_; + + // Category. + namespace internal + { + template <typename F> + struct set_category_of_< fun_p2v_<F> > + { + typedef stc::is< Function_p2v > ret; + }; + } + + // Class. + template <typename F> + struct fun_p2v_ : public Function_p2v< fun_p2v_<F> > + { + typedef oln_arg_of_(F) argument; + typedef oln_res_of_(F) result; + + fun_p2v_(const F& f) : f_(f) {} + + result operator()(argument arg) const + { + return this->f_(arg); + } + + private: + F f_; + }; + + + // functorize_p2v + + template <typename V, typename P> + fun_p2v_<V (*)(P)> + functorize_p2v(V (*f)(P)) + { + mlc::assert_< mlc_is_a(P, Point) >::check(); // FIXME: Add err msg. + fun_p2v_<V (*)(P)> tmp(f); + return tmp; + } + + // ----------------------------- fun_v2v_<F> @@ -161,7 +213,7 @@ typedef oln_arg_of_(F) argument; typedef oln_res_of_(F) result; - fun_v2v_(F f) : f_(f) {} + fun_v2v_(const F& f) : f_(f) {} result operator()(argument arg) const { @@ -174,11 +226,12 @@ // functorize_v2v - template <typename R, typename A> - fun_v2v_<R (*)(A)> - functorize_v2v(R (*f)(A)) + + template <typename Vr, typename Va> + fun_v2v_<Vr (*)(Va)> + functorize_v2v(Vr (*f)(Va)) { - fun_v2v_<R (*)(A)> tmp(f); + fun_v2v_<Vr (*)(Va)> tmp(f); return tmp; } Index: oln/core/gen/traits.hh --- oln/core/gen/traits.hh (revision 0) +++ oln/core/gen/traits.hh (revision 0) @@ -0,0 +1,199 @@ +// 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_TRAITS_HH +# define OLN_CORE_GEN_TRAITS_HH + +# include <oln/core/internal/category_of.hh> + + +// arith + +# define oln_plus_trait(L, R) \ + typename oln::get_trait_<L, oln::plus_id, R>::ret + +# define oln_minus_trait(L, R) \ + typename oln::get_trait_<L, oln::minus_id, R>::ret + +# define oln_times_trait(L, R) \ + typename oln::get_trait_<L, oln::times_id, R>::ret + +# define oln_div_trait(L, R) \ + typename oln::get_trait_<L, oln::div_id, R>::ret + +# define oln_mod_trait(L, R) \ + typename oln::get_trait_<L, oln::mod_id, R>::ret + +// cmp + +# define oln_eq_trait(L, R) \ + typename oln::get_trait_<L, oln::eq_id, R>::ret + +# define oln_neq_trait(L, R) \ + typename oln::get_trait_<L, oln::neq_id, R>::ret + +// ord + +# define oln_less_trait(L, R) \ + typename oln::get_trait_<L, oln::less_id, R>::ret + +# define oln_leq_trait(L, R) \ + typename oln::get_trait_<L, oln::leq_id, R>::ret + +# define oln_geq_trait(L, R) \ + typename oln::get_trait_<L, oln::geq_id, R>::ret + +# define oln_greater_trait(L, R) \ + typename oln::get_trait_<L, oln::greater_id, R>::ret + +// logic + +# define oln_and_trait(L, R) \ + typename oln::get_trait_<L, oln::and_id, R>::ret + +# define oln_or_trait(L, R) \ + typename oln::get_trait_<L, oln::or_id, R>::ret + +# define oln_xor_trait(L, R) \ + typename oln::get_trait_<L, oln::xor_id, R>::ret + + + + + + + + +# define oln_internal_specialize_bin_trait_bool_(Name) \ + \ + template <template <class> class Cl, typename L, \ + template <class> class Cr, typename R> \ + struct set_trait_< Cl, L, Name##_id, Cr, R > \ + { \ + typedef bool ret; \ + } + + +# define oln_internal_specialize_bin_trait_T_(Name) \ + \ + template <template <class> class Cl, typename T, \ + template <class> class Cr> \ + struct set_trait_< Cl, T, Name##_id, Cr, T > \ + { \ + typedef T ret; \ + } + + + + +namespace oln +{ + + // set_trait_ + + template <template <class> class Cl, typename L, + typename Op, + template <class> class Cr, typename R> + struct set_trait_; + + + // ids + + struct plus_id; + struct minus_id; + struct times_id; + struct div_id; + struct mod_id; + + struct eq_id; + struct neq_id; + + struct less_id; + struct leq_id; + struct geq_id; + struct greater_id; + + struct and_id; + struct or_id; + struct xor_id; + + + + // default (see oln/core/concept/operators.hh) + + /* + + oln_internal_specialize_bin_trait_T_(plus); + oln_internal_specialize_bin_trait_T_(minus); + oln_internal_specialize_bin_trait_T_(times); + oln_internal_specialize_bin_trait_T_(div); + oln_internal_specialize_bin_trait_T_(mod); + + oln_internal_specialize_bin_trait_bool_(eq); + oln_internal_specialize_bin_trait_bool_(neq); + + oln_internal_specialize_bin_trait_bool_(less); + oln_internal_specialize_bin_trait_bool_(leq); + oln_internal_specialize_bin_trait_bool_(geq); + oln_internal_specialize_bin_trait_bool_(greater); + + oln_internal_specialize_bin_trait_T_(and); + oln_internal_specialize_bin_trait_T_(or); + oln_internal_specialize_bin_trait_T_(xor); + + */ + + + namespace internal + { + + // get_trait_cat_ + + template <typename Cl, typename L, typename Op, typename Cr, typename R> + struct get_trait_cat__; + + template < template <class> class Cl, typename L, + typename Op, + template <class> class Cr, typename R > + struct get_trait_cat__< stc::is<Cl>, L, Op, stc::is<Cr>, R > + { + typedef typename oln::set_trait_< Cl, L, Op, Cr, R >::ret ret; + }; + + } // end of namespace oln::internal + + + template <typename L, typename Op, typename R> + struct get_trait_ : public internal::get_trait_cat__< oln_category_of_(L), L, Op, oln_category_of_(R), R > + { + }; + + +} // end of namespace oln + + +#endif // ! OLN_CORE_GEN_TRAITS_HH Index: oln/core/internal/box.hh --- oln/core/internal/box.hh (revision 914) +++ oln/core/internal/box.hh (working copy) @@ -199,11 +199,11 @@ # ifndef OLN_INCLUDE_ONLY - namespace internal - { - // -------------------- box_<Exact> + // -------------------- internal::box_<Exact> + namespace internal + { template <typename Exact> box_<Exact>::box_() @@ -293,7 +293,9 @@ { return this->pmax_; } - } + + } // end of namespace oln::internal + // -------------------- box_fwd_piter_<B> @@ -421,7 +423,8 @@ return &p_; } -# endif // OLN_INCLUDE_ONLY +# endif // ! OLN_INCLUDE_ONLY + } // end of namespace oln Index: oln/core/internal/image_base.hh --- oln/core/internal/image_base.hh (revision 914) +++ oln/core/internal/image_base.hh (working copy) @@ -493,7 +493,7 @@ oln_decl_op_such_as(Image, Function_p2b); - // Specialization. + // Specialization "Image such_as f : P -> B". template <typename I, typename B, typename P> op_<const I, such_as, const fun_p2b_<B (*)(P)> > @@ -507,13 +507,13 @@ } - // Specialization. + // Specialization "Image such_as ima : P -> B". template <typename I, typename J> op_<const I, such_as, const fun_p2b_< Binary_Image<J> > > operator | (const Image<I>& ima, const Binary_Image<J>& f_ima_b) { - // FIXME: Activate precondition(f_ima_b.points() >= ima.points()); + precondition(f_ima_b.points() >= ima.points()); mlc::assert_equal_< oln_point(I), oln_point(J) >::check(); op_<const I, such_as, const fun_p2b_< Binary_Image<J> > > tmp(exact(ima), f_ima_b); return tmp; Index: oln/core/internal/iterator_on_points_base.hh --- oln/core/internal/iterator_on_points_base.hh (revision 914) +++ oln/core/internal/iterator_on_points_base.hh (working copy) @@ -41,7 +41,7 @@ namespace internal { template <typename Exact> struct iterator_on_points_base; - }; + } // Super type @@ -88,10 +88,9 @@ } # endif // !OLN_INCLUDE_ONLY -} + } // end of namespace oln::internal - -} +} // end of namespace oln #endif // !OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_BASE_HH Index: oln/value/builtin.hh --- oln/value/builtin.hh (revision 0) +++ oln/value/builtin.hh (revision 0) @@ -0,0 +1,98 @@ +// 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_VALUE_BUILTIN_HH +# define OLN_VALUE_BUILTIN_HH + +# include <oln/core/concept/value.hh> +# include <oln/core/gen/traits.hh> + + +namespace oln +{ + + + // Fwd decl. + namespace internal { template <typename Exact> struct builtin_base; } + + + // Virtual types. + template <typename Exact> + struct vtypes< internal::builtin_base<Exact> > + { + typedef stc::final< stc:is<Value> > category; + }; + + + namespace internal + { + + // Base class for builtin types. + template <typename Exact> + struct builtin_base : public Value<Exact> + { + protected: + builtin_base(); + }; + + } // end of namespace oln::internal + + + + // int + + template <> + struct super_trait_< int > + { + typedef internal::builtin_base<int> ret; + }; + + template <> + struct super_trait_< float > + { + typedef internal::builtin_base<float> ret; + }; + + + template <typename Op> + struct set_trait_< Value, int, Op, Value, float > + { + typedef float ret; + }; + + template <typename Op> + struct set_trait_< Value, float, Op, Value, int > + { + typedef float ret; + }; + + +} // end of namespace oln + + +#endif // ! OLN_VALUE_BUILTIN_HH +