
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2009-05-05 Frederic Bour <bour@lrde.epita.fr> Tidy source code of new functions, renamed trait::fun to trait::function. * mln/core/image/thru_morpher.hh, * mln/core/image/thrubin_morpher.hh, * mln/fun/accu_result.hh, * mln/fun/binary.hh: tidied. * mln/fun/component/comp.hh: Splitted into multiples files: * mln/fun/component/comp_count.hh: New, * mln/fun/component/ithcomp.hh: New, * mln/fun/component/scomp.hh: New. Static i'th component extraction. * mln/fun/math/cos.hh, * mln/fun/math/inf.hh, * mln/fun/math/sup.hh, * mln/fun/point/col.hh, * mln/fun/point/row.hh, * mln/fun/point/sli.hh, * mln/fun/spe/binary.hh, * mln/fun/spe/unary.hh, * mln/fun/unary.hh: tidied. * mln/trait/fun.hh: Removed. Renamed to: * mln/trait/functions.hh: New. * sandbox/fred/tests/fun.cc: Small update. --- mln/core/image/thru_morpher.hh | 4 mln/core/image/thrubin_morpher.hh | 2 mln/fun/accu_result.hh | 18 +- mln/fun/binary.hh | 4 mln/fun/component/comp.hh | 75 ----------- mln/fun/component/comp_count.hh | 99 ++++++++++++++ mln/fun/component/ithcomp.hh | 83 ++++++++++++ mln/fun/component/scomp.hh | 90 +++++++++++++ mln/fun/math/cos.hh | 6 mln/fun/math/inf.hh | 6 mln/fun/math/sup.hh | 6 mln/fun/point/col.hh | 8 - mln/fun/point/row.hh | 4 mln/fun/spe/binary.hh | 4 mln/fun/spe/unary.hh | 4 mln/fun/unary.hh | 2 mln/trait/functions.hh | 253 ++++++++++++++++++++++++++++++++++++++ sandbox/fred/tests/fun.cc | 17 +- 18 files changed, 578 insertions(+), 107 deletions(-) Index: trunk/milena/mln/trait/fun.hh (deleted) =================================================================== Index: trunk/milena/mln/trait/functions.hh =================================================================== --- trunk/milena/mln/trait/functions.hh (revision 0) +++ trunk/milena/mln/trait/functions.hh (revision 3754) @@ -0,0 +1,253 @@ +// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory (LRDE) +// +// 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 F 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_TRAIT_FUNCTIONS_HH +# define MLN_TRAIT_FUNCTIONS_HH + +# include <mln/metal/bexpr.hh> +# include <mln/metal/if.hh> +# include <mln/fun/param.hh> +# include <mln/trait/next/solve.hh> + +# define mln_trait_fun_is_assignable(Fun) typename mln::trait::function::is_assignable< Fun >::ret +# define mln_trait_fun_is_assignable_(Fun) mln::trait::function::is_assignable< Fun >::ret +# define mln_trait_fun_is_assignable__1comma(A, B) typename mln::trait::function::is_assignable< A, B >::ret +# define mln_trait_fun_is_assignable__1comma_(A, B) mln::trait::function::is_assignable< A, B >::ret + +# define mln_trait_fun_is_parametrable(Fun) typename mln::trait::function::is_parametrable< Fun >::ret +# define mln_trait_fun_is_parametrable_(Fun) mln::trait::function::is_parametrable< Fun >::ret + +# define mln_trait_fun_lvalue(Fun) typename mln::trait::function::get_lvalue< Fun >::ret +# define mln_trait_fun_param(Fun) typename mln::trait::function::get_param< Fun >::ret +# define mln_trait_fun_storage(Fun) typename mln::trait::function::get_storage< Fun >::ret + +namespace mln +{ + + namespace trait + { + + namespace function + { + + namespace internal + { + + namespace introspect + { + + template <typename T> + struct except_void_t + { + typedef void ret; + }; + + template <> + struct except_void_t<void>; + + // Lvalue solver + + template <typename T, typename V> + struct has_lvalue_t + { + typedef metal::false_ ret; + typedef void type; + }; + + template <typename T> + struct has_lvalue_t<T, typename except_void_t<typename T::lvalue>::ret> + { + typedef metal::true_ ret; + typedef typename T::lvalue type; + }; + + // Parameter solver + template <typename T, typename V> + struct param_solver; + + template <typename T, typename V> + struct param_flag_solver + { + typedef typename mln::fun::parameter<T> ret; + }; + + template <typename T> + struct param_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::param>::ret> + { + typedef mln::fun::parameter<typename T::flag> ret; + }; + + template <typename T, typename V> + struct param_def_solver + { + typedef typename param_flag_solver<T, V>::ret ret; + }; + + template <typename T> + struct param_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::param>::ret> + { + typedef mln::fun::parameter<typename T::def> ret; + }; + + template <typename T, typename V> + struct param_solver : param_def_solver<T, V> + { + }; + + template <typename T> + struct param_solver<T, typename except_void_t<typename T::param>::ret> + { + typedef T ret; + }; + + template <typename T, typename V> + struct has_param_t + { + typedef metal::false_ ret; + typedef void type; + }; + + template <typename T> + struct has_param_t<T, typename except_void_t<typename param_solver<T,void>::ret::param>::ret> + { + typedef metal::true_ ret; + typedef typename param_solver<T,void>::ret::param type; + }; + + template <typename T, typename V> + struct storage_solver; + + template <typename T, typename V> + struct storage_flag_solver + { + typedef typename mln::fun::parameter<T> ret; + }; + + template <typename T> + struct storage_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::storage>::ret> + { + typedef mln::fun::parameter<typename T::flag> ret; + }; + + template <typename T, typename V> + struct storage_def_solver + { + typedef typename storage_flag_solver<T, V>::ret ret; + }; + + template <typename T> + struct storage_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::storage>::ret> + { + typedef mln::fun::parameter<typename T::def> ret; + }; + + template <typename T, typename V> + struct storage_solver : storage_def_solver<T, V> + { + }; + + template <typename T> + struct storage_solver<T, typename except_void_t<typename T::storage>::ret> + { + typedef T ret; + }; + + template <typename T, typename V> + struct has_storage_t + { + typedef has_param_t<T, V> has_param; + + typedef metal::false_ ret; + typedef typename has_param::type type; + + template <typename U> + static inline + const U& compute(const U& t) + { + return t; + } + + }; + + template <typename T> + struct has_storage_t<T, typename except_void_t<typename param_solver<T,void>::ret::storage>::ret> + { + typedef metal::true_ ret; + typedef typename param_solver<T,void>::ret def; + + typedef typename def::storage type; + + template <typename U> + static inline + type compute(const U& p) + { + return def::compute(p); + }; + + }; + + } // end of namespace mln::trait::fun::internal::introspect + + } // end of namespace mln::trait::fun::internal + + template <typename F> + struct is_assignable + { + typedef typename internal::introspect::has_lvalue_t<F, void>::ret ret; + }; + + template <typename F> + struct is_parametrable + { + typedef typename internal::introspect::has_param_t<F, void>::ret ret; + }; + + template <typename F> + struct get_lvalue + { + typedef typename internal::introspect::has_lvalue_t<F, void>::type ret; + }; + + template <typename F> + struct get_param + { + typedef typename internal::introspect::has_param_t<F, void>::type ret; + }; + + template <typename F> + struct get_storage + { + typedef typename internal::introspect::has_storage_t<F, void>::type ret; + }; + + } // end of namespace mln::trait::fun + + } // end of namespace mln::trait + +} // end of namespace mln + +#endif // ! MLN_TRAIT_FUN_HH Index: trunk/milena/mln/core/image/thru_morpher.hh =================================================================== --- trunk/milena/mln/core/image/thru_morpher.hh (revision 3753) +++ trunk/milena/mln/core/image/thru_morpher.hh (revision 3754) @@ -32,7 +32,7 @@ # include <mln/core/internal/image_value_morpher.hh> # include <mln/core/concept/meta_function.hh> # include <mln/metal/bexpr.hh> -# include <mln/trait/fun.hh> +# include <mln/trait/functions.hh> /// /// \file mln/core/image/thru_morpher.hh @@ -58,7 +58,7 @@ { typedef thru_image_write<I, F> write; typedef thru_image_read<I, F> read; - typedef mlc_if(mlc_and(typename trait::fun::is_assignable<F>::ret, + typedef mlc_if(mlc_and(mln_trait_fun_is_assignable(F), mlc_and(mlc_not(mlc_is_const(I)), mlc_equal(mln_trait_image_pw_io(I), trait::image::pw_io::read_write))), Index: trunk/milena/mln/core/image/thrubin_morpher.hh =================================================================== --- trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3753) +++ trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3754) @@ -32,7 +32,7 @@ # include <mln/core/internal/image_value_morpher.hh> # include <mln/core/concept/meta_function.hh> # include <mln/metal/bexpr.hh> -# include <mln/trait/fun.hh> +# include <mln/trait/functions.hh> /// \file mln/core/image/thrubin_morpher.hh /// Index: trunk/milena/mln/fun/spe/binary.hh =================================================================== --- trunk/milena/mln/fun/spe/binary.hh (revision 3753) +++ trunk/milena/mln/fun/spe/binary.hh (revision 3754) @@ -30,7 +30,7 @@ # include <mln/core/concept/function.hh> # include <mln/trait/next/solve.hh> -# include <mln/trait/fun.hh> +# include <mln/trait/functions.hh> /// \todo Implements parameter support @@ -99,7 +99,7 @@ template <typename U> void init(const U& value) { - storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value); + storage_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value); } protected: Index: trunk/milena/mln/fun/spe/unary.hh =================================================================== --- trunk/milena/mln/fun/spe/unary.hh (revision 3753) +++ trunk/milena/mln/fun/spe/unary.hh (revision 3754) @@ -30,7 +30,7 @@ # include <mln/core/concept/function.hh> # include <mln/trait/next/solve.hh> -# include <mln/trait/fun.hh> +# include <mln/trait/functions.hh> namespace mln { @@ -239,7 +239,7 @@ template <typename U> void init(const U& value) { - storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value); + storage_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value); }; protected: Index: trunk/milena/mln/fun/point/row.hh =================================================================== --- trunk/milena/mln/fun/point/row.hh (revision 3753) +++ trunk/milena/mln/fun/point/row.hh (revision 3754) @@ -55,10 +55,10 @@ { template <typename G, typename C> - struct set_precise_unary_<mln::fun::row, mln::point<G,C> > + struct set_precise_unary_<fun::row, point<G,C> > { typedef set_precise_unary_ ret; - typedef mln::point<G,C> argument; + typedef point<G,C> argument; typedef typename argument::coord result; typedef argument& lvalue; Index: trunk/milena/mln/fun/point/col.hh =================================================================== --- trunk/milena/mln/fun/point/col.hh (revision 3753) +++ trunk/milena/mln/fun/point/col.hh (revision 3754) @@ -42,7 +42,9 @@ namespace fun { - struct col : unary<col> {}; + struct col : unary<col> + { + }; } // end of namespace mln::fun @@ -55,10 +57,10 @@ { template <typename G, typename C> - struct set_precise_unary_<mln::fun::col, mln::point<G, C> > + struct set_precise_unary_<fun::col, point<G, C> > { typedef set_precise_unary_ ret; - typedef mln::point<G,C> argument; + typedef point<G,C> argument; typedef typename argument::coord result; typedef argument& lvalue; Index: trunk/milena/mln/fun/math/cos.hh =================================================================== --- trunk/milena/mln/fun/math/cos.hh (revision 3753) +++ trunk/milena/mln/fun/math/cos.hh (revision 3754) @@ -82,10 +82,10 @@ }; - } + } // end of namespace mln::trait::next - } + } // end of namespace mln -} +} // end of namespace mln #endif /* ! MLN_FUN_MATH_COS_HH */ \ No newline at end of file Index: trunk/milena/mln/fun/math/sup.hh =================================================================== --- trunk/milena/mln/fun/math/sup.hh (revision 3753) +++ trunk/milena/mln/fun/math/sup.hh (revision 3754) @@ -60,11 +60,11 @@ } }; - } + } // end of namespace mln::trait::next - } + } // end of namespace mln::trait -} +} // end of namespace mln #endif /* ! MLN_FUN_MATH_SUP_HH */ Index: trunk/milena/mln/fun/math/inf.hh =================================================================== --- trunk/milena/mln/fun/math/inf.hh (revision 3753) +++ trunk/milena/mln/fun/math/inf.hh (revision 3754) @@ -60,11 +60,11 @@ } }; - } + } // end of namespace mln::trait::next - } + } // end of namespace mln::trait -} +} // end of namespace mln #endif /* ! MLN_FUN_MATH_INF_HH */ Index: trunk/milena/mln/fun/unary.hh =================================================================== --- trunk/milena/mln/fun/unary.hh (revision 3753) +++ trunk/milena/mln/fun/unary.hh (revision 3754) @@ -83,7 +83,7 @@ template <typename U> void init(const U& value) { - storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value); + storage_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value); }; unary() Index: trunk/milena/mln/fun/binary.hh =================================================================== --- trunk/milena/mln/fun/binary.hh (revision 3753) +++ trunk/milena/mln/fun/binary.hh (revision 3754) @@ -31,7 +31,7 @@ # include <mln/core/concept/meta_function.hh> # include <mln/fun/spe/binary.hh> # include <mln/trait/next/solve.hh> -# include <mln/trait/fun.hh> +# include <mln/trait/functions.hh> namespace mln { @@ -60,7 +60,7 @@ template <typename U> void init(const U& value) { - storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value); + storage_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value); }; binary() Index: trunk/milena/mln/fun/component/scomp.hh =================================================================== --- trunk/milena/mln/fun/component/scomp.hh (revision 0) +++ trunk/milena/mln/fun/component/scomp.hh (revision 3754) @@ -0,0 +1,90 @@ +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Laboratory (LRDE) +// +// 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_FUN_COMPONENT_SCOMP_HH +# define MLN_FUN_COMPONENT_SCOMP_HH + +/// \file mln/fun/component/scomp.hh +/// +/// Meta function to retrieve/modify the i'th component, where i is +/// statically defined. + +# include <mln/fun/unary.hh> +# include <mln/fun/component/comp.hh> + +namespace mln +{ + + namespace fun + { + + template <unsigned ith> + struct scomp : unary< scomp<ith> > + { + }; + + } // end of namespace mln::fun + +# ifndef MLN_INCLUDE_ONLY + + namespace trait + { + + namespace next + { + + template <unsigned ith, typename T> + struct set_unary_<fun::scomp<ith>, mln::Object, T> + { + typedef set_unary_ ret; + typedef mln_trait_nunary(fun::comp, T) comp_t; + + typedef T argument; + typedef mln_result(comp_t) result; + typedef mln_lvalue(comp_t) lvalue; + + static result read(const argument& v) + { + return comp_t::read(ith, v); + } + + static void write(lvalue l, const result& r) + { + comp_t::write(ith, l, r); + } + }; + + } // end of namespace mln::trait::next + + } // end of namespace mln::trait + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + +#endif // MLN_FUN_COMPONENT_COMP_HH Index: trunk/milena/mln/fun/component/ithcomp.hh =================================================================== --- trunk/milena/mln/fun/component/ithcomp.hh (revision 0) +++ trunk/milena/mln/fun/component/ithcomp.hh (revision 3754) @@ -0,0 +1,83 @@ +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Laboratory (LRDE) +// +// 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_FUN_COMPONENT_ITHCOMP_HH +# define MLN_FUN_COMPONENT_ITHCOMP_HH + +/// \file mln/fun/component/ithcomp.hh +/// +/// Meta function to retrieve/modify the i'th component with a binary +/// function f(i, vec). + +# include <mln/fun/binary.hh> +# include <mln/fun/component/comp.hh> + +namespace mln +{ + + namespace fun + { + + struct ithcomp : binary<ithcomp> + { + }; + + } // end of namespace mln::fun + +# ifndef MLN_INCLUDE_ONLY + + namespace trait + { + + namespace next + { + + template <typename I, typename T> + struct set_binary_<mln::fun::ithcomp, mln::value::Integer, I, mln::Object, T> + { + typedef set_binary_ ret; + typedef I argument1; + typedef T argument2; + typedef mln_trait_nunary(mln::fun::comp, T) comp_t; + typedef mln_result(comp_t) result; + + static result read(const argument1& i, const argument2& v) + { + return comp_t::read(i, v); + } + }; + + } // end of namespace mln::trait::next + + } // end of namespace mln::trait + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + +#endif // MLN_FUN_COMPONENT_ITHCOMP_HH Index: trunk/milena/mln/fun/component/comp_count.hh =================================================================== --- trunk/milena/mln/fun/component/comp_count.hh (revision 0) +++ trunk/milena/mln/fun/component/comp_count.hh (revision 3754) @@ -0,0 +1,99 @@ +// Copyright (C) 2007, 2008, 2009 EPITA Research and Development +// Laboratory (LRDE) +// +// 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_FUN_COMPONENT_COMP_COUNT_HH +# define MLN_FUN_COMPONENT_COMP_COUNT_HH + +/// \file mln/fun/component/comp_count.hh +/// +/// Meta function to retrieve the number of components a vector has. + +# include <mln/fun/unary.hh> +# include <mln/value/rgb.hh> +# include <mln/value/int_u.hh> +# include <mln/algebra/vec.hh> + +namespace mln +{ + + namespace fun + { + + struct comp_count : unary<comp_count> + { + }; + + } // end of namespace mln::fun + +# ifndef MLN_INCLUDE_ONLY + + namespace trait + { + + namespace next + { + + template <unsigned n> + struct set_precise_unary_<mln::fun::comp_count, mln::value::rgb<n> > + { + typedef set_precise_unary_ ret; + + typedef mln::value::rgb<n> argument; + typedef unsigned result; + typedef argument& lvalue; + + static result read(const argument&) + { + return 3; + } + }; + + template <unsigned n, typename T> + struct set_precise_unary_<mln::fun::comp_count, mln::algebra::vec<n,T> > + { + typedef set_precise_unary_ ret; + + typedef mln::algebra::vec<n,T> argument; + typedef unsigned result; + typedef argument& lvalue; + + static result read(const argument&) + { + return n; + } + }; + + } // end of namespace mln::trait::next + + } // end of namespace mln::trait + +# endif // ! MLN_INCLUDE_ONLY + +} // end of namespace mln + +#endif // MLN_FUN_COMPONENT_COMP_COUNT_HH Index: trunk/milena/mln/fun/component/comp.hh =================================================================== --- trunk/milena/mln/fun/component/comp.hh (revision 3753) +++ trunk/milena/mln/fun/component/comp.hh (revision 3754) @@ -33,10 +33,7 @@ /// /// Meta function to retrieve/modify a component. -# include <mln/fun/unary.hh> -# include <mln/fun/binary.hh> -# include <mln/fun/param.hh> -# include <mln/trait/next/solve.hh> +# include <mln/fun/unary_param.hh> # include <mln/value/rgb.hh> # include <mln/value/int_u.hh> # include <mln/algebra/vec.hh> @@ -47,24 +44,12 @@ namespace fun { - struct comp : binary<comp> {}; - - struct pcomp; - - template <> - struct parameter<pcomp> - { - typedef unsigned param; - }; - - struct pcomp : unary<pcomp> + struct comp : unary_param<comp,unsigned> { - pcomp() : unary<pcomp>(0) {}; - pcomp(unsigned i = 0) : unary<pcomp>(i) {}; + comp() : unary_param<comp,unsigned>(0) {}; + comp(unsigned i) : unary_param<comp,unsigned>(i) {}; }; - struct comp_count : unary<comp_count> {}; - } // end of namespace mln::fun # ifndef MLN_INCLUDE_ONLY @@ -75,57 +60,10 @@ namespace next { - template <typename E, typename T> - struct set_binary_<mln::fun::comp, mln::value::Integer, E, mln::Object, T> - { - typedef set_binary_ ret; - typedef E argument1; - typedef T argument2; - typedef mln_trait_nunary(mln::fun::pcomp, T) pcomp_t; - typedef mln_result(pcomp_t) result; - - static result read(const argument1& i, const argument2& v) - { - pcomp_t c; - return c.read(i, v); - } - }; - - template <unsigned n> - struct set_precise_unary_<mln::fun::comp_count, mln::value::rgb<n> > - { - typedef set_precise_unary_ ret; - - typedef mln::value::rgb<n> argument; - typedef unsigned result; - typedef argument& lvalue; - - static result read(const argument&) - { - return n; - } - }; - - template <unsigned n, typename T> - struct set_precise_unary_<mln::fun::comp_count, mln::algebra::vec<n,T> > - { - typedef set_precise_unary_ ret; - - typedef mln::algebra::vec<n,T> argument; - typedef unsigned result; - typedef argument& lvalue; - - static result read(const argument&) - { - return n; - } - }; - template <unsigned n> - struct set_precise_unary_<mln::fun::pcomp, mln::value::rgb<n> > + struct set_precise_unary_<mln::fun::comp, mln::value::rgb<n> > { typedef set_precise_unary_ ret; -// typedef mln::fun::pcomp flag; typedef mln::value::rgb<n> argument; typedef mln::value::int_u<n> result; @@ -143,10 +81,9 @@ }; template <unsigned n, typename T> - struct set_precise_unary_<mln::fun::pcomp, mln::algebra::vec<n,T> > + struct set_precise_unary_<mln::fun::comp, mln::algebra::vec<n,T> > { typedef set_precise_unary_ ret; - typedef mln::fun::pcomp flag; typedef mln::algebra::vec<n,T> argument; typedef T result; Index: trunk/milena/mln/fun/accu_result.hh =================================================================== --- trunk/milena/mln/fun/accu_result.hh (revision 3753) +++ trunk/milena/mln/fun/accu_result.hh (revision 3754) @@ -30,8 +30,6 @@ # include <mln/fun/unary.hh> # include <mln/core/concept/accumulator.hh> -# include <mln/math/acos.hh> -# include <mln/math/cos.hh> namespace mln { @@ -39,8 +37,12 @@ // accu_result: return result of given accumulator. namespace fun { - struct accu_result : unary<accu_result> {}; - } + + struct accu_result : unary<accu_result> + { + }; + + } // end of namespace mln::fun namespace trait { @@ -48,7 +50,7 @@ namespace next { template <typename E> - struct set_unary_<mln::fun::accu_result, mln::Accumulator, E> + struct set_unary_<fun::accu_result, Accumulator, E> { typedef set_unary_ ret; typedef typename E::result result; @@ -60,10 +62,10 @@ } }; - } + } // end of namespace mln::trait::next - } + } // end of namespace mln::trait -} +} // end of namespace mln #endif /* ! MLN_FUN_ACCU_RESULT_HH */ \ No newline at end of file Index: trunk/milena/sandbox/fred/tests/fun.cc =================================================================== --- trunk/milena/sandbox/fred/tests/fun.cc (revision 3753) +++ trunk/milena/sandbox/fred/tests/fun.cc (revision 3754) @@ -4,19 +4,23 @@ #include <mln/fun/math/norm.hh> #include <mln/fun/component/red.hh> #include <mln/fun/component/comp.hh> +#include <mln/fun/component/ithcomp.hh> +#include <mln/fun/component/scomp.hh> #include <mln/value/rgb8.hh> #include <iostream> #define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl + int main() { mln::fun::abs abs; mln::fun::cos cos; // mln::fun::inc inc; mln::fun::red red; - mln::fun::comp comp; - mln::fun::pcomp comp1(1); + mln::fun::ithcomp ithcomp; + mln::fun::comp comp(1); + mln::fun::scomp<1> comp1; mln::fun::norm::l1 l1; mln::fun::norm::l2 l2; @@ -86,10 +90,11 @@ dbg_print(red(rgb) = 0); mln_invariant(red(rgb) == 0); dbg_print(rgb); - dbg_print(comp(0, rgb)); - dbg_print(comp(1, rgb)); - dbg_print(comp(2, rgb)); - comp1(rgb) = 2; + dbg_print(ithcomp(0, rgb)); + dbg_print(ithcomp(1, rgb)); + dbg_print(ithcomp(2, rgb)); + dbg_print(comp1(rgb) = 2); + dbg_print(comp(rgb)); } // NORM