URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-04-28 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Add world/ directory for inter_pixel images.
* mln/arith/all.hh: Update.
* mln/arith/div.hh: New div operator.
* mln/arith/div.spe.hh: New div operator.
* mln/io/magick/save.hh: Update.
* mln/io/plot/save.hh: Update.
* mln/world/inter_pixel/full.hh: Convert standard image
to inter_pixel image.
* mln/world/inter_pixel/neighb2d.hh: Define standard
inter_pixel neighborhood.
---
arith/all.hh | 1
arith/div.hh | 289 ++++++++++++++++++++++++++++++++++++++++++
arith/div.spe.hh | 121 +++++++++++++++++
io/magick/save.hh | 2
io/plot/save.hh | 4
world/inter_pixel/full.hh | 77 +++++++++++
world/inter_pixel/neighb2d.hh | 83 ++++++++++++
7 files changed, 574 insertions(+), 3 deletions(-)
Index: trunk/milena/mln/world/inter_pixel/full.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/full.hh (revision 0)
+++ trunk/milena/mln/world/inter_pixel/full.hh (revision 3720)
@@ -0,0 +1,77 @@
+// Copyright (C) 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_WORLD_INTER_PIXEL_FULL_HH
+# define MLN_WORLD_INTER_PIXEL_FULL_HH
+
+/// \file mln/world/inter_pixel/full.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/image/image2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ template <typename T>
+ image2d<T>
+ image2full(const image2d<T>& input)
+ {
+ image2d<T> output(2 * input.nrows() - 1,
+ 2 * input.ncols() - 1);
+ for (int row = 0; row < input.nrows(); ++row)
+ for (int col = 0; col < input.ncols(); ++col)
+ opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ return output;
+ }
+
+ template <typename T>
+ image2d<T>
+ full2image(const image2d<T>& input)
+ {
+ image2d<T> output((input.nrows() + 1) / 2,
+ (input.ncols() + 1) / 2);
+ for (int row = 0; row < input.nrows(); row += 2)
+ for (int col = 0; col < input.ncols(); col += 2)
+ opt::at(output, row / 2, col / 2) =
+ opt::at(input, row, col);
+ return output;
+ }
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_FULL
Index: trunk/milena/mln/world/inter_pixel/neighb2d.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 0)
+++ trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 3720)
@@ -0,0 +1,83 @@
+// Copyright (C) 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_WORLD_INTER_PIXEL_NEIGHB2D_HH
+# define MLN_WORLD_INTER_PIXEL_NEIGHB2D_HH
+
+/// \file mln/world/inter_pixel/neighb2d.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/alias/neighb2d.hh>
+# include <mln/make/double_neighb2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ typedef neighb< win::multiple<window2d, bool(*)(const point2d&)> > dbl_neighb2d;
+
+ const dbl_neighb2d& e2c()
+ {
+ static bool e2c_h[] = { 0, 1, 0,
+ 0, 0, 0,
+ 0, 1, 0 };
+ static bool e2c_v[] = { 0, 0, 0,
+ 1, 0, 1,
+ 0, 0, 0 };
+ static dbl_neighb2d nbh = make::double_neighb2d(is_row_odd, e2c_h, e2c_v);
+ return nbh;
+ }
+
+ const dbl_neighb2d& e2e()
+ {
+ static bool e2e_h[] = { 0, 0, 1, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 0, 0, 1, 0, 0 };
+ static bool e2e_v[] = { 0, 0, 0, 0, 0,
+ 0, 1, 0, 1, 0,
+ 1, 0, 0, 0, 1,
+ 0, 1, 0, 1, 0,
+ 0, 0, 0, 0, 0 };
+ static dbl_neighb2d nbh = make::double_neighb2d(is_row_odd, e2e_h, e2e_v);
+ return nbh;
+ }
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_NEIGHB2D
Index: trunk/milena/mln/arith/div.hh
===================================================================
--- trunk/milena/mln/arith/div.hh (revision 0)
+++ trunk/milena/mln/arith/div.hh (revision 3720)
@@ -0,0 +1,289 @@
+// 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 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_ARITH_DIV_HH
+# define MLN_ARITH_DIV_HH
+
+/// \file mln/arith/div.hh
+///
+/// Point-wise division between images.
+///
+/// \todo Speedup; some versions are not optimal.
+
+# include <mln/arith/includes.hh>
+
+// Specializations are in:
+# include <mln/arith/div.spe.hh>
+
+
+namespace mln
+{
+
+
+ namespace trait
+ {
+
+ template <typename L, typename R>
+ struct set_binary_< op::div, Image, L, Image, R >
+ {
+ typedef mln_trait_op_div(mln_value(L), mln_value(R)) value;
+ typedef mln_ch_value(L, value) ret;
+ };
+
+ template <typename I, typename S>
+ struct set_binary_< op::div, Image, I, mln::value::Scalar, S >
+ {
+ typedef mln_trait_op_div(mln_value(I), S) value;
+ typedef mln_ch_value(I, value) ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ template <typename L, typename R>
+ mln_trait_op_div(L,R)
+ operator/(const Image<L>& lhs, const Image<R>& rhs);
+
+ template <typename L, typename R>
+ L&
+ operator/=(Image<L>& lhs, const Image<R>& rhs);
+
+
+ template <typename I, typename S>
+ mln_trait_op_div(I,S)
+ operator/(const Image<I>& ima, const value::Scalar<S>& s);
+
+ template <typename I, typename S>
+ I&
+ operator/=(Image<I>& ima, const value::Scalar<S>& s);
+
+
+
+ namespace arith
+ {
+
+ /// Point-wise division of images \p lhs and \p rhs.
+ /*!
+ * \param[in] lhs First operand image.
+ * \param[in] rhs Second operand image.
+ * \param[out] output The result image.
+ *
+ * \pre \p output.domain == \p lhs.domain == \p rhs.domain
+ */
+ template <typename L, typename R, typename O>
+ void div(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output);
+
+
+ /// Point-wise division of the value \p val to image \p input.
+ /*!
+ * \param[in] input The image.
+ * \param[in] val The value.
+ * \param[out] output The result image.
+ *
+ * \pre \p output.domain == \p input.domain
+ */
+ template <typename I, typename V, typename O>
+ void div_cst(const Image<I>& input, const V& val, Image<O>& output);
+
+
+ /// Point-wise division of image \p rhs in image \p lhs.
+ /*!
+ * \param[in] lhs First operand image (subject to division).
+ * \param[in,out] rhs Second operand image (to div \p lhs).
+ *
+ * This addition performs: \n
+ * for all p of rhs.domain \n
+ * lhs(p) /= rhs(p)
+ *
+ * \pre \p rhs.domain <= \p lhs.domain
+ */
+ template <typename L, typename R>
+ void div_inplace(Image<L>& lhs, const Image<R>& rhs);
+
+
+ } // end of namespace mln::arith
+
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ template <typename L, typename R>
+ inline
+ mln_trait_op_div(L,R)
+ operator/(const Image<L>& lhs, const Image<R>& rhs)
+ {
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_trait_op_div(L,R) tmp;
+ initialize(tmp, lhs);
+ arith::div(lhs, rhs, tmp);
+ return tmp;
+ }
+
+ template <typename L, typename R>
+ inline
+ L&
+ operator/=(Image<L>& lhs, const Image<R>& rhs)
+ {
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ arith::div_inplace(lhs, rhs);
+ return exact(lhs);
+ }
+
+
+ template <typename I, typename S>
+ inline
+ mln_trait_op_div(I,S)
+ operator/(const Image<I>& ima, const value::Scalar<S>& s)
+ {
+ mln_precondition(exact(ima).is_valid());
+ mln_precondition(s != 0);
+ mln_trait_op_div(I,S) tmp;
+ initialize(tmp, ima);
+ arith::div_cst(ima, exact(s), tmp);
+ return tmp;
+ }
+
+ template <typename I, typename S>
+ inline
+ I&
+ operator/=(Image<I>& ima, const value::Scalar<S>& s)
+ {
+ mln_precondition(exact(ima).is_valid());
+ arith::div_cst(ima, exact(s), ima);
+ return exact(ima);
+ }
+
+
+
+ namespace arith
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+
+ template <typename L, typename R, typename O>
+ inline
+ void div_(const L& lhs, const R& rhs, O& output)
+ {
+ trace::entering("arith::impl::generic::div_");
+
+ mln_piter(L) p(lhs.domain());
+ for_all(p)
+ output(p) = lhs(p) / rhs(p);
+
+ trace::exiting("arith::impl::generic::div_");
+ }
+
+ template <typename L, typename R>
+ inline
+ void div_inplace_(L& lhs, const R& rhs)
+ {
+ trace::entering("arith::impl::generic::div_inplace_");
+
+ mln_piter(R) p(rhs.domain());
+ for_all(p)
+ lhs(p) /= rhs(p);
+
+ trace::exiting("arith::impl::generic::div_inplace_");
+ }
+
+ } // end of namespace mln::arith::impl::generic
+
+ } // end of namespace mln::arith::impl
+
+
+ // Facades.
+
+ template <typename L, typename R, typename O>
+ inline
+ void div(const Image<L>& lhs, const Image<R>& rhs, Image<O>& output)
+ {
+ trace::entering("arith::div");
+
+ mln_precondition(exact(rhs).domain() == exact(lhs).domain());
+ mln_precondition(exact(output).domain() == exact(lhs).domain());
+ impl::div_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs),
+ mln_trait_image_speed(O)(), exact(output));
+
+ trace::exiting("arith::div");
+ }
+
+ template <typename I, typename V, typename O>
+ inline
+ void div_cst(const Image<I>& input, const V& val, Image<O>& output)
+ {
+ trace::entering("arith::div_cst");
+
+ mln_precondition(exact(output).domain() == exact(input).domain());
+ div(input, pw::cst(val) | exact(input).domain(), output);
+ // Calls the previous version.
+
+ trace::exiting("arith::div_cst");
+ }
+
+ template <typename L, typename R>
+ inline
+ void div_inplace(Image<L>& lhs, const Image<R>& rhs)
+ {
+ trace::entering("arith::div_inplace");
+
+ mln_precondition(exact(rhs).domain() <= exact(lhs).domain());
+ impl::div_inplace_(mln_trait_image_speed(L)(), exact(lhs),
+ mln_trait_image_speed(R)(), exact(rhs));
+
+ trace::exiting("arith::div_inplace");
+ }
+
+ template <typename I, typename V>
+ inline
+ void div_cst_inplace(Image<I>& input, const V& val)
+ {
+ trace::entering("arith::div_cst_inplace");
+
+ mln_precondition(exact(input).is_valid());
+ div_inplace(input, pw::cst(val) | exact(input).domain());
+ // Calls the previous version.
+
+ trace::exiting("arith::div_cst_inplace");
+ }
+
+ } // end of namespace mln::arith
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ARITH_DIV_HH
Index: trunk/milena/mln/arith/all.hh
===================================================================
--- trunk/milena/mln/arith/all.hh (revision 3719)
+++ trunk/milena/mln/arith/all.hh (revision 3720)
@@ -55,6 +55,7 @@
}
# include <mln/arith/diff_abs.hh>
+# include <mln/arith/div.hh>
# include <mln/arith/min.hh>
# include <mln/arith/minus.hh>
# include <mln/arith/plus.hh>
Index: trunk/milena/mln/arith/div.spe.hh
===================================================================
--- trunk/milena/mln/arith/div.spe.hh (revision 0)
+++ trunk/milena/mln/arith/div.spe.hh (revision 3720)
@@ -0,0 +1,121 @@
+// 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 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_ARITH_DIV_SPE_HH
+# define MLN_ARITH_DIV_SPE_HH
+
+/// \file mln/arith/div.spe.hh
+///
+/// Specializations for mln::arith::div.
+
+# ifndef MLN_ARITH_DIV_HH
+# error "Forbidden inclusion of *.spe.hh"
+# endif // ! MLN_ARITH_DIV_HH
+
+# include <mln/arith/includes.hh>
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+namespace mln
+{
+
+ namespace arith
+ {
+
+ namespace impl
+ {
+
+ namespace generic
+ {
+ template <typename L, typename R, typename O>
+ void div_(const L& lhs, const R& rhs, O& output);
+
+ template <typename L, typename R>
+ void div_inplace_(L& lhs, const R& rhs);
+
+ }
+
+ template <typename L, typename R, typename O>
+ inline
+ void div_(trait::image::speed::any, const L& lhs,
+ trait::image::speed::any, const R& rhs,
+ trait::image::speed::any, O& output)
+ {
+ generic::div_(lhs, rhs, output);
+ }
+
+ template <typename L, typename R, typename O>
+ inline
+ void div_(trait::image::speed::fastest, const L& lhs,
+ trait::image::speed::fastest, const R& rhs,
+ trait::image::speed::fastest, O& output)
+ {
+ trace::entering("arith::impl::div_");
+
+ mln_pixter(const L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ mln_pixter(O) op(output);
+ for_all_3(lp, rp, op)
+ op.val() = lp.val() / rp.val();
+
+ trace::exiting("arith::impl::div_");
+ }
+
+ template <typename L, typename R>
+ inline
+ void div_inplace_(trait::image::speed::any, L& lhs,
+ trait::image::speed::any, const R& rhs)
+ {
+ generic::div_inplace_(lhs, rhs);
+ }
+
+ template <typename L, typename R>
+ inline
+ void div_inplace_(trait::image::speed::fastest, L& lhs,
+ trait::image::speed::fastest, const R& rhs)
+ {
+ trace::entering("arith::impl::div_inplace_");
+
+ mln_pixter(L) lp(lhs);
+ mln_pixter(const R) rp(rhs);
+ for_all_2(rp, lp)
+ lp.val() /= rp.val();
+
+ trace::exiting("arith::impl::div_inplace_");
+ }
+
+ } // end of namespace mln::arith::impl
+
+ } // end of namespace mln::arith
+
+} // end of namespace mln
+
+# endif // ! MLN_INCLUDE_ONLY
+
+#endif // ! MLN_ARITH_DIV_SPE_HH
Index: trunk/milena/mln/io/magick/save.hh
===================================================================
--- trunk/milena/mln/io/magick/save.hh (revision 3719)
+++ trunk/milena/mln/io/magick/save.hh (revision 3720)
@@ -102,7 +102,7 @@
mln::metal::equal<mln_value(I), value::rgb8>::value))
{
std::cerr << "error: trying to save an unsupported format" << std::endl;
- std::cerr << "formats supported: binary, 8bits grayscale (int_u8), 8bits truecolor (rgb8)" << std::endl;
+ std::cerr << "supported formats: binary, 8bits grayscale (int_u8), 8bits truecolor (rgb8)" << std::endl;
abort();
}
Index: trunk/milena/mln/io/plot/save.hh
===================================================================
--- trunk/milena/mln/io/plot/save.hh (revision 3719)
+++ trunk/milena/mln/io/plot/save.hh (revision 3720)
@@ -87,7 +87,7 @@
trace::entering("mln::io::plot::save");
std::ofstream file_out(filename.c_str());
- for (int i = 0; i < ima.ninds(); ++i)
+ for (unsigned i = 0; i < ima.ninds(); ++i)
file_out << start_value + i << ", " << ima.at_(i) << std::endl;
trace::exiting("mln::io::plot::save");
@@ -101,7 +101,7 @@
trace::entering("mln::io::plot::save");
std::ofstream file_out(filename.c_str());
- for (int i = 0; i < arr.nelements(); ++i)
+ for (unsigned i = 0; i < arr.nelements(); ++i)
file_out << start_value + i << ", " << arr[i] << std::endl;
trace::exiting("mln::io::plot::save");
URL: https://svn.lrde.epita.fr/svn/oln/trunk
ChangeLog:
2009-04-27 Frederic Bour <bour(a)lrde.epita.fr>
Merge new fun implementation to main milena directory.
* milena/mln/accu/inf.hh: New.
* milena/mln/accu/sup.hh: New.
* milena/mln/core/concept/meta_function.hh: New.
* milena/mln/core/image/thru_morpher.hh: New.
* milena/mln/core/image/thrubin_morpher.hh: New.
* milena/mln/fun/accu_result.hh: New.
* milena/mln/fun/binary.hh: New.
* milena/mln/fun/component/blue.hh: New.
* milena/mln/fun/component/comp.hh: New.
* milena/mln/fun/component/green.hh: New.
* milena/mln/fun/component/red.hh: New.
* milena/mln/fun/component/rgb.hh: New.
* milena/mln/fun/component: New.
* milena/mln/fun/compose.hh: New.
* milena/mln/fun/composition.hh: New.
* milena/mln/fun/from_accu.hh: New.
* milena/mln/fun/math/abs.hh: New.
* milena/mln/fun/math/cos.hh: New.
* milena/mln/fun/math/inf.hh: New.
* milena/mln/fun/math/norm.hh: New.
* milena/mln/fun/math/sup.hh: New.
* milena/mln/fun/math: New.
* milena/mln/fun/param.hh: New.
* milena/mln/fun/spe/binary.hh: New.
* milena/mln/fun/spe/unary.hh: New.
* milena/mln/fun/spe: New.
* milena/mln/fun/unary.hh: New.
* milena/mln/trait/fun.hh: New.
* milena/mln/trait/next/solve.hh: New.
* milena/mln/trait/next/solve_binary.hh: New.
* milena/mln/trait/next/solve_proxy.hh: New.
* milena/mln/trait/next/solve_unary.hh: New.
* milena/mln/trait/next: New.
* milena/sandbox/fred/mln/accu/inf.hh: Remove.
* milena/sandbox/fred/mln/accu/sup.hh: Remove.
* milena/sandbox/fred/mln/core/concept/meta_function.hh: Remove.
* milena/sandbox/fred/mln/core/image/thru_morpher.hh: Remove.
* milena/sandbox/fred/mln/core/image/thrubin_morpher.hh: Remove.
* milena/sandbox/fred/mln/fun/accu_result.hh: Remove.
* milena/sandbox/fred/mln/fun/binary.hh: Remove.
* milena/sandbox/fred/mln/fun/component/blue.hh: Remove.
* milena/sandbox/fred/mln/fun/component/comp.hh: Remove.
* milena/sandbox/fred/mln/fun/component/green.hh: Remove.
* milena/sandbox/fred/mln/fun/component/red.hh: Remove.
* milena/sandbox/fred/mln/fun/component/rgb.hh: Remove.
* milena/sandbox/fred/mln/fun/compose.hh: Remove.
* milena/sandbox/fred/mln/fun/composition.hh: Remove.
* milena/sandbox/fred/mln/fun/from_accu.hh: Remove.
* milena/sandbox/fred/mln/fun/math/abs.hh: Remove.
* milena/sandbox/fred/mln/fun/math/cos.hh: Remove.
* milena/sandbox/fred/mln/fun/math/inf.hh: Remove.
* milena/sandbox/fred/mln/fun/math/norm.hh: Remove.
* milena/sandbox/fred/mln/fun/math/sup.hh: Remove.
* milena/sandbox/fred/mln/fun/param.hh: Remove.
* milena/sandbox/fred/mln/fun/spe/binary.hh: Remove.
* milena/sandbox/fred/mln/fun/spe/unary.hh: Remove.
* milena/sandbox/fred/mln/fun/unary.hh: Remove.
* milena/sandbox/fred/mln/trait/fun.hh: Remove.
* milena/sandbox/fred/mln/trait/next/solve.hh: Remove.
* milena/sandbox/fred/mln/trait/next/solve_binary.hh: Remove.
* milena/sandbox/fred/mln/trait/next/solve_proxy.hh: Remove.
* milena/sandbox/fred/mln/trait/next/solve_unary.hh: Remove.
---
trunk/milena/mln/accu/inf.hh | 166 +++++++++++++
trunk/milena/mln/accu/sup.hh | 166 +++++++++++++
trunk/milena/mln/core/concept/meta_function.hh | 203 ++++++++++++++++
trunk/milena/mln/core/image/thru_morpher.hh | 306 +++++++++++++++++++++++++
trunk/milena/mln/core/image/thrubin_morpher.hh | 279 ++++++++++++++++++++++
trunk/milena/mln/fun/accu_result.hh | 69 +++++
trunk/milena/mln/fun/binary.hh | 94 +++++++
trunk/milena/mln/fun/component/blue.hh | 84 ++++++
trunk/milena/mln/fun/component/comp.hh | 174 ++++++++++++++
trunk/milena/mln/fun/component/green.hh | 84 ++++++
trunk/milena/mln/fun/component/red.hh | 84 ++++++
trunk/milena/mln/fun/component/rgb.hh | 40 +++
trunk/milena/mln/fun/compose.hh | 117 +++++++++
trunk/milena/mln/fun/composition.hh | 223 ++++++++++++++++++
trunk/milena/mln/fun/from_accu.hh | 95 +++++++
trunk/milena/mln/fun/math/abs.hh | 69 +++++
trunk/milena/mln/fun/math/cos.hh | 91 +++++++
trunk/milena/mln/fun/math/inf.hh | 69 +++++
trunk/milena/mln/fun/math/norm.hh | 119 +++++++++
trunk/milena/mln/fun/math/sup.hh | 69 +++++
trunk/milena/mln/fun/param.hh | 88 +++++++
trunk/milena/mln/fun/spe/binary.hh | 136 +++++++++++
trunk/milena/mln/fun/spe/unary.hh | 302 ++++++++++++++++++++++++
trunk/milena/mln/fun/unary.hh | 169 +++++++++++++
trunk/milena/mln/trait/fun.hh | 253 ++++++++++++++++++++
trunk/milena/mln/trait/next/solve.hh | 152 ++++++++++++
trunk/milena/mln/trait/next/solve_binary.hh | 302 ++++++++++++++++++++++++
trunk/milena/mln/trait/next/solve_proxy.hh | 95 +++++++
trunk/milena/mln/trait/next/solve_unary.hh | 171 +++++++++++++
29 files changed, 4269 insertions(+)
Index: trunk/milena/mln/trait/fun.hh
===================================================================
--- trunk/milena/mln/trait/fun.hh (revision 0)
+++ trunk/milena/mln/trait/fun.hh (revision 3716)
@@ -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_FUN_HH
+# define MLN_TRAIT_FUN_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::fun::is_assignable< Fun >::ret
+# define mln_trait_fun_is_assignable_(Fun) mln::trait::fun::is_assignable< Fun >::ret
+# define mln_trait_fun_is_assignable__1comma(A, B) typename mln::trait::fun::is_assignable< A, B >::ret
+# define mln_trait_fun_is_assignable__1comma_(A, B) mln::trait::fun::is_assignable< A, B >::ret
+
+# define mln_trait_fun_is_parametrable(Fun) typename mln::trait::fun::is_parametrable< Fun >::ret
+# define mln_trait_fun_is_parametrable_(Fun) mln::trait::fun::is_parametrable< Fun >::ret
+
+# define mln_trait_fun_lvalue(Fun) typename mln::trait::fun::get_lvalue< Fun >::ret
+# define mln_trait_fun_param(Fun) typename mln::trait::fun::get_param< Fun >::ret
+# define mln_trait_fun_storage(Fun) typename mln::trait::fun::get_storage< Fun >::ret
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace fun
+ {
+
+ 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/trait/next/solve_unary.hh
===================================================================
--- trunk/milena/mln/trait/next/solve_unary.hh (revision 0)
+++ trunk/milena/mln/trait/next/solve_unary.hh (revision 3716)
@@ -0,0 +1,171 @@
+// Copyright (C) 2006, 2008 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 MLN_TRAIT_NEXT_SOLVE_UNARY_HH
+# define MLN_TRAIT_NEXT_SOLVE_UNARY_HH
+
+/*!
+ * \file mln/trait/next/solve_unary.hh
+ *
+ * \brief FIXME
+ *
+ *
+ */
+
+# include <mln/core/category.hh>
+# include <mln/core/routine/exact.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/next/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ namespace internal
+ {
+
+
+ template < typename Name,
+ typename Category,
+ typename T >
+ struct trait_set_unary_;
+
+ template < typename Name,
+ template <class> class Category, typename _,
+ typename T >
+ struct trait_set_unary_< Name, Category<_>, T >
+ {
+ typedef typename mln::trait::next::set_unary_<Name, Category, T>::ret ret;
+ };
+
+
+ // Fwd decls.
+ template < typename Name,
+ typename Category, typename T >
+ struct get_unary_;
+
+
+ template < typename user_ret, /* != not_found and != undefined */
+ typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_
+ {
+ typedef user_ret ret; // The user has defined 'ret' so we return it.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_< /* user_ret == */ not_found,
+ Name, Category, T >
+ {
+ typedef not_found ret; // End of search due to a blocker; 'ret' is not found.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_get_unary_< /* user_ret == */ undefined,
+ Name, Category, T >
+ {
+ typedef typename mln::internal::super_category_< Category, T >::ret Super_Category;
+ typedef typename get_unary_<Name, Super_Category, T>::ret ret; // No user ret definition => Recursion.
+ };
+
+
+ template < typename Name,
+ typename Category, typename T >
+ struct get_unary_
+ {
+ typedef typename trait_set_unary_<Name, Category, T>::ret user_ret; // First get 'user_ret'
+ typedef helper_get_unary_<user_ret, Name, Category, T> helper; // Set the helper to make a decision.
+ typedef mlc_ret(helper) ret; // Return.
+ };
+
+
+ template < typename precise_ret,
+ typename Name,
+ typename Category, typename T >
+ struct helper_choose_unary_wrt_ /* precise_ret != undefined */
+ {
+ typedef precise_ret ret; // -> A precise ret has been defined so it is it.
+ };
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_choose_unary_wrt_< /* precise_ret == */ undefined,
+ Name, Category, T >
+ {
+ typedef typename get_unary_<Name, Category, T>::ret ret; // -> Go up into the category inheritance
+ // to fetch a ret from 'set_unary_'s.
+ };
+
+ template < typename Name,
+ typename Category, typename T >
+ struct helper_solve_unary_
+ {
+ typedef typename set_precise_unary_<Name, T>::ret precise_ret;
+ typedef helper_choose_unary_wrt_< precise_ret, /* undefined or not (?) */
+ Name, Category, T> helper;
+ typedef mlc_ret(helper) ret;
+ };
+
+ } // end of namespace mln::trait::next::internal
+
+
+ template < typename Name,
+ typename T_ >
+ struct solve_unary
+ {
+ typedef mln_exact(T_) T;
+ typedef typename mln::category<T>::ret Category;
+ typedef internal::helper_solve_unary_< Name, Category, T > meta_code;
+ typedef typename meta_code::ret ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_UNARY_HH
Index: trunk/milena/mln/trait/next/solve.hh
===================================================================
--- trunk/milena/mln/trait/next/solve.hh (revision 0)
+++ trunk/milena/mln/trait/next/solve.hh (revision 3716)
@@ -0,0 +1,152 @@
+// Copyright (C) 2006, 2008 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 MLN_TRAIT_NEXT_SOLVE_HH
+# define MLN_TRAIT_NEXT_SOLVE_HH
+
+/*!
+ * \file mln/trait/next/solve.hh
+ *
+ * \brief FIXME
+ *
+ *
+ */
+
+# include <mln/core/category.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+# define mln_trait_nunary(Name, T) typename mln::trait::next::solve_unary< Name, T >::ret
+# define mln_trait_nunary_(Name, T) mln::trait::next::solve_unary< Name, T >::ret
+
+# define mln_trait_nbinary(Name, T1, T2) typename mln::trait::next::solve_binary< Name, T1, T2 >::ret
+# define mln_trait_nbinary_(Name, T1, T2) mln::trait::next::solve_binary< Name, T1, T2 >::ret
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Unary case.
+
+
+ template < typename Name,
+ typename T >
+ struct set_precise_unary_
+ {
+ typedef undefined ret;
+ };
+
+
+ template < typename Name,
+ template <class> class Category_T, typename T >
+ struct set_unary_
+ {
+ typedef undefined ret;
+ };
+
+ template < typename Name,
+ typename T >
+ struct set_unary_< Name, Unknown, T > // Blocker; top of inheritance.
+ {
+ typedef not_found ret;
+ };
+
+
+
+
+ // Binary case.
+
+
+ template < typename Name,
+ typename L,
+ typename R >
+ struct set_precise_binary_
+ {
+ typedef undefined ret;
+ };
+
+
+ template < typename Name,
+ template <class> class Category_L, typename L,
+ template <class> class Category_R, typename R >
+ struct set_binary_
+ {
+ typedef undefined ret;
+ };
+
+ template < typename Name,
+ typename L,
+ template <class> class Category_R, typename R >
+ struct set_binary_< Name, Unknown, L, Category_R, R > // Left blocker.
+ {
+ typedef not_found ret;
+ };
+
+ template < typename Name,
+ template <class> class Category_L, typename L,
+ typename R >
+ struct set_binary_< Name, Category_L, L, Unknown, R > // Right blocker.
+ {
+ typedef not_found ret;
+ };
+
+ template < typename Name,
+ typename L,
+ typename R >
+ struct set_binary_< Name, Unknown, L, Unknown, R > // Blocker.
+ {
+ typedef not_found ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+# include <mln/trait/next/solve_unary.hh>
+# include <mln/trait/next/solve_binary.hh>
+# include <mln/trait/next/solve_proxy.hh>
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_HH
Index: trunk/milena/mln/trait/next/solve_proxy.hh
===================================================================
--- trunk/milena/mln/trait/next/solve_proxy.hh (revision 0)
+++ trunk/milena/mln/trait/next/solve_proxy.hh (revision 3716)
@@ -0,0 +1,95 @@
+// Copyright (C) 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 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_CORE_CONCEPT_PROXY_HH
+# define MLN_CORE_CONCEPT_PROXY_HH
+
+/*! \file mln/core/concept/proxy.hh
+ *
+ * \brief Definition of the concept of mln::Proxy.
+ *
+ * \todo preinc and predec are not tested; post-like ops are not handled.
+ *
+ * \todo add "op=(T)" when possible, so add a constness property.
+ * \todo add "opT()const" when possible.
+ */
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/proxy.hh>
+# include <mln/core/concept/proxy.hxx>
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Unary ops.
+
+ template < typename Op, typename P >
+ struct set_unary_< Op, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nunary(Op, S) ret;
+ };
+
+ // Binary ops.
+
+ template < typename Op, typename L, typename R >
+ struct set_binary_< Op, mln::Proxy, L, mln::Proxy, R >
+ {
+ typedef mln::internal::helper_unprox_binop<L, R> helper;
+ typedef mln_trait_nbinary(Op,
+ typename helper::L_ret,
+ typename helper::R_ret) ret;
+ };
+
+ template < typename Op, typename P, typename O >
+ struct set_binary_< Op, mln::Proxy, P, mln::Object, O >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nbinary(Op, S, O) ret;
+ };
+
+ template < typename Op, typename O, typename P >
+ struct set_binary_< Op, mln::Object, O, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nbinary(Op, O, S) ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_PROXY_HH
Index: trunk/milena/mln/trait/next/solve_binary.hh
===================================================================
--- trunk/milena/mln/trait/next/solve_binary.hh (revision 0)
+++ trunk/milena/mln/trait/next/solve_binary.hh (revision 3716)
@@ -0,0 +1,302 @@
+// Copyright (C) 2006, 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_TRAIT_NEXT_SOLVE_BINARY_HH
+# define MLN_TRAIT_NEXT_SOLVE_BINARY_HH
+
+/// \file mln/trait/next/solve_binary.hh
+///
+/// FIXME
+
+# include <mln/core/category.hh>
+# include <mln/core/routine/exact.hh>
+# include <mln/metal/equal.hh>
+# include <mln/metal/if.hh>
+# include <mln/metal/ret.hh>
+# include <mln/trait/next/solve.hh>
+
+
+// FIXME: Just for the record (use it...)
+
+# ifndef MLN_DEBUG_TRAITS
+# endif // ! MLN_DEBUG_TRAITS
+
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ namespace internal
+ {
+
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct trait_set_binary_;
+
+ template < typename Name,
+ template <class> class Category_L, typename _l, typename L,
+ template <class> class Category_R, typename _r, typename R >
+ struct trait_set_binary_< Name,
+ Category_L<_l>, L,
+ Category_R<_r>, R >
+ {
+ typedef typename mln::trait::next::set_binary_<Name,
+ Category_L, L,
+ Category_R, R>::ret ret;
+ };
+
+
+ // triplet_ret_
+
+ template < unsigned i_L_, unsigned i_R_, typename ret_ >
+ struct triplet_
+ {
+ typedef ret_ ret;
+ };
+
+
+ // merge_triplets_
+
+ template < typename L_trp, typename R_trp >
+ struct merge_triplets_;
+
+ template < unsigned L_i_L, unsigned L_i_R, typename L_ret,
+ unsigned R_i_L, unsigned R_i_R, typename R_ret >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, L_ret>,
+ triplet_<R_i_L, R_i_R, R_ret> >
+ {
+ typedef metal::bool_<(L_i_L <= R_i_L && L_i_R <= R_i_R)> take_L;
+ typedef metal::bool_<(R_i_L <= L_i_L && R_i_R <= L_i_R)> take_R;
+ typedef metal::or_<take_L, take_R> ok;
+ typedef typename metal::if_< metal::and_<ok, take_L>,
+ triplet_<L_i_L, L_i_R, L_ret>,
+ typename metal::if_< metal::and_<ok, take_R>,
+ triplet_<R_i_L, R_i_R, R_ret>,
+ triplet_<0,0, not_found> >::ret >::ret ret;
+ };
+
+ template < unsigned i_L, unsigned i_R, typename LR_ret >
+ struct merge_triplets_< triplet_<i_L, i_R, LR_ret>,
+ triplet_<i_L, i_R, LR_ret> >
+ {
+ typedef triplet_<i_L, i_R, LR_ret> ret;
+ };
+
+
+ template < unsigned L_i_L, unsigned L_i_R, unsigned L_i_max,
+ unsigned R_i_L, unsigned R_i_R, unsigned R_i_max >
+ // L_i_max and R_i_max differ
+ struct helper_merge_triplets_same_ret_
+ {
+ // The winning couple between L_* and R_* is the one which
+ // maximum index is the smallest; for instance, with:
+ // left branch giving L_i_L = 5 and L_i_R = 1 so L_i_max = 5
+ // right branch giving L_i_L = 3 and L_i_R = 4 so R_i_max = 4
+ // the right branch wins.
+ enum { i_L = (L_i_max < R_i_max ? L_i_L : R_i_L),
+ i_R = (L_i_max < R_i_max ? L_i_R : R_i_R) };
+ };
+
+ template < unsigned L_i_L, unsigned L_i_R, unsigned i_max,
+ unsigned R_i_L, unsigned R_i_R >
+ // L_i_max is equal to R_i_max
+ struct helper_merge_triplets_same_ret_< L_i_L, L_i_R, i_max,
+ R_i_L, R_i_R, i_max >
+ {
+ // The winning couple is the one with the minimum index.
+ enum { L_i_min = (L_i_L < L_i_R ? L_i_L : L_i_R),
+ R_i_min = (R_i_L < R_i_R ? R_i_L : R_i_R),
+ i_L = (L_i_min < R_i_min ? L_i_L : R_i_L),
+ i_R = (L_i_min < R_i_min ? L_i_R : R_i_R) };
+ };
+
+
+ template < unsigned L_i_L, unsigned L_i_R, typename LR_ret,
+ unsigned R_i_L, unsigned R_i_R >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, LR_ret>,
+ triplet_<R_i_L, R_i_R, LR_ret> >
+ {
+ typedef helper_merge_triplets_same_ret_< L_i_L, L_i_R, (L_i_L > L_i_R ? L_i_L : L_i_R),
+ R_i_L, R_i_R, (R_i_L > R_i_R ? R_i_L : R_i_R) > helper;
+ typedef triplet_<helper::i_L, helper::i_R, LR_ret> ret;
+ };
+
+ template < unsigned L_i_L, unsigned L_i_R, typename L_ret >
+ struct merge_triplets_< triplet_<L_i_L, L_i_R, L_ret>,
+ triplet_< 0, 0, not_found> >
+ {
+ typedef triplet_<L_i_L, L_i_R, L_ret> ret;
+ };
+
+ template < unsigned R_i_L, unsigned R_i_R, typename R_ret >
+ struct merge_triplets_< triplet_< 0, 0, not_found>,
+ triplet_<R_i_L, R_i_R, R_ret> >
+ {
+ typedef triplet_<R_i_L, R_i_R, R_ret> ret;
+ };
+
+ template <> // To disambiguate.
+ struct merge_triplets_< triplet_<0, 0, not_found>,
+ triplet_<0, 0, not_found> >
+ {
+ typedef triplet_<0u,0u, not_found> ret;
+ };
+
+
+
+ // Fwd decl.
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct get_binary_;
+
+
+ template < typename user_ret, /* != not_found and != undefined */
+ typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_
+ {
+ typedef triplet_< i_L, i_R, user_ret > ret; // The user has defined 'ret' so we return it.
+ };
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_< /* user_ret == */ not_found,
+ Name, i_L, Category_L, L, i_R, Category_R, R >
+ {
+ typedef triplet_< 0, 0, not_found > ret; // End of search due to a blocker; 'ret' is not found.
+ };
+
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct helper_get_binary_< /* user_ret == */ undefined,
+ Name, i_L,Category_L, L, i_R,Category_R, R >
+ {
+ // No user definition for 'ret' so treillis construction in a static recursive way.
+
+ // FIXME: We *do* need to handle this search with a priority!
+ // FIXME: for a result can be found in both branches...
+
+ typedef typename mln::internal::super_category_< Category_L, L >::ret Super_Category_L;
+ typedef typename mln::internal::super_category_< Category_R, R >::ret Super_Category_R;
+
+ typedef get_binary_< Name,
+ i_L + 1, Super_Category_L, L,
+ i_R, Category_R, R > L_branch;
+ typedef mlc_ret(L_branch) L_trp;
+
+ typedef get_binary_< Name,
+ i_L, Category_L, L,
+ i_R + 1, Super_Category_R, R > R_branch;
+ typedef mlc_ret(R_branch) R_trp;
+
+ typedef typename merge_triplets_< L_trp, R_trp >::ret ret;
+ };
+
+
+ template < typename Name,
+ unsigned i_L, typename Category_L, typename L,
+ unsigned i_R, typename Category_R, typename R >
+ struct get_binary_
+ {
+ typedef typename trait_set_binary_<Name, Category_L,L,
+ Category_R,R>::ret user_ret; // First get 'user_ret'
+ typedef helper_get_binary_<user_ret, Name, i_L,Category_L,L,
+ i_R,Category_R,R> helper; // Set the helper to make a decision.
+ typedef mlc_ret(helper) ret; // Return a triplet.
+ };
+
+
+ template < typename precise_ret,
+ typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_choose_binary_wrt_ /* precise_ret != undefined */
+ {
+ typedef precise_ret ret; // -> A precise ret has been defined so it is it.
+ };
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_choose_binary_wrt_< /* precise_ret == */ undefined,
+ Name, Category_L, L, Category_R, R >
+ {
+ typedef typename get_binary_< Name,
+ 0, Category_L, L,
+ 0, Category_R, R >::ret triplet; // Browse upwards the category inheritance
+ typedef mlc_ret(triplet) ret; // to fetch ret from 'get_binary_'s.
+ };
+
+
+ template < typename Name,
+ typename Category_L, typename L,
+ typename Category_R, typename R >
+ struct helper_solve_binary_
+ {
+ typedef typename set_precise_binary_<Name, L, R>::ret precise_ret; /* undefined or not (?) */
+ typedef helper_choose_binary_wrt_<precise_ret, Name, Category_L,L, Category_R,R> helper;
+ typedef mlc_ret(helper) ret;
+ };
+
+ } // end of namespace mln::trait::internal
+
+
+ // FIXME: Postfix solve_binary with a '-'(?)
+ template < typename Name,
+ typename L_,
+ typename R_ >
+ struct solve_binary
+ {
+ typedef mln_exact(L_) L;
+ typedef mln_exact(R_) R;
+ typedef typename mln::category<L>::ret Category_L;
+ typedef typename mln::category<R>::ret Category_R;
+ typedef internal::helper_solve_binary_< Name, Category_L, L, Category_R, R > meta_code;
+ typedef typename meta_code::ret ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRAIT_NEXT_SOLVE_BINARY_HH
Index: trunk/milena/mln/core/image/thru_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thru_morpher.hh (revision 0)
+++ trunk/milena/mln/core/image/thru_morpher.hh (revision 3716)
@@ -0,0 +1,306 @@
+// 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 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_CORE_IMAGE_THRU_MORPHER_HH
+# define MLN_CORE_IMAGE_THRU_MORPHER_HH
+
+# 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>
+
+///
+/// \file mln/core/image/thru_morpher.hh
+///
+/// \brief Definition of a morpher that morph image values through a function.
+///
+/// \todo Debug constness of thru_image
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename F> struct thru_image;
+
+ namespace internal
+ {
+ template <typename I, typename F> struct thru_image_write;
+ template <typename I, typename F> struct thru_image_read;
+
+ /// Find correct implementation
+ template <typename I, typename F>
+ struct thru_find_impl
+ {
+ 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,
+ mlc_and(mlc_not(mlc_is_const(I)),
+ mlc_equal(mln_trait_image_pw_io(I),
+ trait::image::pw_io::read_write))),
+ write, read) ret;
+ };
+
+ /// Data structure for \c mln::thru_image<I>.
+ template <typename I, typename F>
+ struct data< thru_image<I, F> >
+ {
+ data(I& ima, const F& f);
+
+ I ima_;
+ F f_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I, typename F>
+ struct image_< thru_image<I, F> > : image_< typename mln::internal::thru_find_impl<I, F>::ret > // Same as I except...
+ {
+ // ...these changes.
+ typedef trait::image::category::value_morpher category;
+ typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+ typedef trait::image::value_access::computed value_access;
+ };
+
+ template <typename I, typename F>
+ struct image_< mln::internal::thru_image_write<I, F> > : image_< I > // Same as I except...
+ {
+ typedef trait::image::vw_io::read_write vw_io;
+ };
+
+ template <typename I, typename F>
+ struct image_< mln::internal::thru_image_read<I, F> > : image_< I > // Same as I except...
+ {
+ typedef trait::image::vw_io::read vw_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ class thru_image_read : public internal::image_value_morpher< I, typename F::result, thru_image<I,F> >
+ {
+ public:
+
+ /// Skeleton.
+ typedef thru_image<tag::image_<I>, F> skeleton;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef typename F::result value;
+
+ /// Return type of read-only access.
+ typedef typename F::result rvalue;
+
+ rvalue operator()(const mln_psite(I)& p) const;
+
+ };
+
+ // Inheritance from read ?!
+ template <typename I, typename F>
+ class thru_image_write : public thru_image_read<I,F>
+ {
+ public:
+
+ /// Type returned by the read-write pixel value operator.
+// typedef typename F::template lresult<typename F::argument>::ret lvalue;
+ typedef typename F::lresult lvalue;
+
+ using thru_image_read<I,F>::operator();
+ lvalue operator()(const mln_psite(I)& p);
+
+ };
+ }
+
+ template <typename I, typename F>
+ class thru_image : public internal::thru_find_impl<I, F>::ret
+ {
+ public:
+
+ thru_image();
+ thru_image(I& ima);
+ thru_image(I& ima, const F& f);
+
+ void init_(I& ima, const F& f);
+
+ /// Const promotion via conversion.
+ operator thru_image<const I, F>() const;
+ };
+
+ template <typename I, typename F>
+ thru_image<I, F> thru(const mln::Function<F>& f,
+ Image<I>& ima);
+
+ template <typename I, typename F>
+ const thru_image<const I, F> thru(const mln::Function<F>& f,
+ const Image<I>& ima);
+
+ template <typename I, typename M>
+ thru_image<I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, Image<I>& ima);
+
+ template <typename I, typename M>
+ const thru_image<const I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, const Image<I>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // internal::data< thru_image<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ data< thru_image<I, F> >::data(I& ima, const F& f)
+ : ima_(ima),
+ f_(f)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ // thru_image<I>
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image()
+ {
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image(I& ima, const F& f)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::thru_image(I& ima)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, mln_value(I)());
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ thru_image<I, F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ mln_precondition(ima.is_valid());
+ this->data_ = new internal::data< thru_image<I, F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thru_image<I, F>::operator thru_image<const I, F>() const
+ {
+ thru_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+ return tmp;
+ }
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ typename thru_image_read<I, F>::rvalue
+ thru_image_read<I, F>::operator()(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ template <typename I, typename F>
+ inline
+ typename thru_image_write<I, F>::lvalue
+ thru_image_write<I, F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ }
+
+ // thru
+ template <typename I, typename F>
+ thru_image<I, F> thru(const mln::Function<F>& f,
+ Image<I>& ima)
+ {
+ thru_image<I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ thru_image<const I, F> thru(const mln::Function<F>& f,
+ const Image<I>& ima)
+ {
+ thru_image<const I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thru_image<I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thru_image<I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thru_image<const I, mln_fun_with(M, mln_value(I))>
+ thru(const mln::Meta_Function<M>& f, const Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thru_image<const I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_THRU_MORPHER_HH
Index: trunk/milena/mln/core/image/thrubin_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thrubin_morpher.hh (revision 0)
+++ trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3716)
@@ -0,0 +1,279 @@
+// 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 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_CORE_IMAGE_THRUBIN_MORPHER_HH
+# define MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
+
+# 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>
+
+///
+/// \file mln/core/image/thrubin_morpher.hh
+///
+/// \brief Definition of a morpher that morph values from two images through a binary function.
+///
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename F> struct thrubin_image;
+
+ namespace internal
+ {
+ /// Data structure for \c mln::thrubin_image<I>.
+ template <typename I1, typename I2, typename F>
+ struct data< thrubin_image<I1, I2, F> >
+ {
+ data(I1& ima1, I2& ima2, const F& f);
+
+ I1 ima1_;
+ I2 ima2_;
+ F f_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I1, typename I2, typename F>
+ struct image_< thrubin_image<I1, I2, F> > : image_< typename mln::internal::thrubin_find_impl<I1, , F>::ret > // Same as I except...
+ {
+ // ...these changes.
+ typedef trait::image::category::value_morpher category;
+ typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+ typedef trait::image::value_access::computed value_access;
+ typedef trait::image::vw_io::read vw_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ class thrubin_image_read : public internal::image_value_morpher< I, typename F::result, thrubin_image<I,F> >
+ {
+ public:
+
+ /// Skeleton.
+ typedef thrubin_image<tag::image_<I>, F> skeleton;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef typename F::result value;
+
+ /// Return type of read-only access.
+ typedef typename F::result rvalue;
+
+ rvalue operator()(const mln_psite(I)& p) const;
+
+ };
+
+ // Inheritance from read ?!
+ template <typename I, typename F>
+ class thrubin_image_write : public thrubin_image_read<I,F>
+ {
+ public:
+
+ /// Type returned by the read-write pixel value operator.
+// typedef typename F::template lresult<typename F::argument>::ret lvalue;
+ typedef typename F::lresult lvalue;
+
+ using thrubin_image_read<I,F>::operator();
+ lvalue operator()(const mln_psite(I)& p);
+
+ };
+ }
+
+ template <typename I, typename F>
+ class thrubin_image : public internal::thrubin_find_impl<I, F>::ret
+ {
+ public:
+
+ thrubin_image();
+ thrubin_image(I& ima);
+ thrubin_image(I& ima, const F& f);
+
+ void init_(I& ima, const F& f);
+
+ /// Const promotion via conversion.
+ operator thrubin_image<const I, F>() const;
+ };
+
+ template <typename I, typename F>
+ thrubin_image<I, F> thrubin(const mln::Function<F>& f,
+ Image<I>& ima);
+
+ template <typename I, typename F>
+ const thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
+ const Image<I>& ima);
+
+ template <typename I, typename M>
+ thrubin_image<I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, Image<I>& ima);
+
+ template <typename I, typename M>
+ const thrubin_image<const I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // internal::data< thrubin_image<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ data< thrubin_image<I, F> >::data(I& ima, const F& f)
+ : ima_(ima),
+ f_(f)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ // thrubin_image<I>
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image()
+ {
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image(I& ima, const F& f)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image(I& ima)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, mln_value(I)());
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ thrubin_image<I, F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ mln_precondition(ima.is_valid());
+ this->data_ = new internal::data< thrubin_image<I, F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::operator thrubin_image<const I, F>() const
+ {
+ thrubin_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+ return tmp;
+ }
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ typename thrubin_image_read<I, F>::rvalue
+ thrubin_image_read<I, F>::operator()(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ template <typename I, typename F>
+ inline
+ typename thrubin_image_write<I, F>::lvalue
+ thrubin_image_write<I, F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ }
+
+ // thrubin
+ template <typename I, typename F>
+ thrubin_image<I, F> thrubin(const mln::Function<F>& f,
+ Image<I>& ima)
+ {
+ thrubin_image<I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
+ const Image<I>& ima)
+ {
+ thrubin_image<const I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thrubin_image<I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thrubin_image<I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thrubin_image<const I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thrubin_image<const I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
Index: trunk/milena/mln/core/concept/meta_function.hh
===================================================================
--- trunk/milena/mln/core/concept/meta_function.hh (revision 0)
+++ trunk/milena/mln/core/concept/meta_function.hh (revision 3716)
@@ -0,0 +1,203 @@
+// 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_CORE_CONCEPT_META_FUNCTION_HH
+# define MLN_CORE_CONCEPT_META_FUNCTION_HH
+
+/// \file mln/core/concept/meta_function.hh
+///
+/// Definition of the concept of mln::Meta_Function.
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/function.hh>
+
+
+# define mln_fun_with(F, T) \
+typename F::template with< T >::ret
+
+# define mln_fun_with_(F, T) \
+F::with< T >::ret
+
+
+# define mln_fun_result(F, T) \
+typename F::template with< T >::ret::result
+
+
+# define mln_fun_result_(F, T) \
+F::with< T >::ret::result
+
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ template <typename E> struct Meta_Function;
+ template <typename E> struct Meta_Function_v2v;
+ template <typename E> struct Meta_Function_vv2v;
+
+ // Meta_Function category flag type.
+ template <>
+ struct Meta_Function<void>
+ {
+ typedef Object<void> super;
+ };
+
+
+ /*! \brief Base class for implementation of meta functions.
+ *
+ * The parameter \a E is the exact type.
+ *
+ * \see mln::doc::Meta_Function for a complete documentation of
+ * this class contents.
+ */
+ template <typename E>
+ struct Meta_Function : public Object<E>
+ {
+ typedef Meta_Function<void> category;
+ protected:
+ Meta_Function();
+ };
+
+ /*----------------------.
+ | Unary meta function. |
+ `----------------------*/
+
+ template <>
+ struct Meta_Function_v2v<void> { typedef Meta_Function<void> super; };
+
+ /// Base class for implementation of function-objects from
+ /// value to value.
+ ///
+ /// The parameter \a E is the exact type.
+ ///
+ template <typename E>
+ struct Meta_Function_v2v : public Meta_Function<E>
+ {
+ typedef Meta_Function_v2v<void> category;
+
+ protected:
+ Meta_Function_v2v();
+ Meta_Function_v2v(const Meta_Function_v2v&);
+ };
+
+ /*-----------------------.
+ | Binary meta function. |
+ `-----------------------*/
+
+ template <>
+ struct Meta_Function_vv2v<void> { typedef Meta_Function<void> super; };
+
+ /// Base class for implementation of function-objects from
+ /// value to value.
+ ///
+ /// The parameter \a E is the exact type.
+ ///
+ template <typename E>
+ struct Meta_Function_vv2v : public Meta_Function<E>
+ {
+ typedef Meta_Function_vv2v<void> category;
+
+ protected:
+ Meta_Function_vv2v();
+ Meta_Function_vv2v(const Meta_Function_vv2v&);
+ };
+
+ namespace fun
+ {
+
+ // To be specialized when some state (attributes) have to be transfered
+ // from the meta-function to the function.
+ // Warning: the first argument has to be an object with the exact type.
+ template <typename M, typename T>
+ mln_fun_with(M, T)
+ unmeta(const M&, T);
+
+ template <typename M, typename T>
+ void
+ unmeta(const Meta_Function<M>&, T); // Safety.
+
+ } // end of namespace mln::fun
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ inline
+ Meta_Function<E>::Meta_Function()
+ {
+ // FIXME: Check "with" on E.
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_v2v<E>::Meta_Function_v2v()
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_v2v<E>::Meta_Function_v2v(const Meta_Function_v2v<E>& rhs)
+ : Meta_Function<E>(rhs)
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_vv2v<E>::Meta_Function_vv2v()
+ {
+ }
+
+ template <typename E>
+ inline
+ Meta_Function_vv2v<E>::Meta_Function_vv2v(const Meta_Function_vv2v<E>& rhs)
+ : Meta_Function<E>(rhs)
+ {
+ }
+
+ namespace fun
+ {
+
+ template <typename M, typename T>
+ inline
+ mln_fun_with(M, T)
+ unmeta(const M&, T)
+ {
+ mlc_is_a(M, Meta_Function)::check();
+ mln_fun_with(M, T) a;
+ return a;
+ }
+
+ } // end of namespace mln::fun
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_META_FUNCTION_HH
Index: trunk/milena/mln/accu/inf.hh
===================================================================
--- trunk/milena/mln/accu/inf.hh (revision 0)
+++ trunk/milena/mln/accu/inf.hh (revision 3716)
@@ -0,0 +1,166 @@
+// 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 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_ACCU_INF_HH
+# define MLN_ACCU_INF_HH
+
+/// \file mln/accu/inf.hh
+///
+/// Define an accumulator that computes a inf.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/trait/value_.hh>
+# include <mln/util/pix.hh>
+# include <mln/fun/math/inf.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /// Generic inf accumulator class.
+ /*!
+ * The parameter \c T is the type of values.
+ */
+ template <typename T>
+ struct inf : public mln::accu::internal::base< const T&, inf<T> >
+ {
+ typedef T argument;
+
+ inf();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const inf<T>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ const T& to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ protected:
+
+ T t_;
+ mln::fun::inf::with<T, T>::ret fun_;
+ };
+
+
+ template <typename I> struct inf< util::pix<I> >;
+
+
+
+ namespace meta
+ {
+
+ /// Meta accumulator for inf.
+
+ struct inf : public Meta_Accumulator< inf >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::inf<T> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
+
+
+ # ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ inf<T>::inf()
+ {
+ init();
+ }
+
+ template <typename T>
+ inline
+ void
+ inf<T>::init()
+ {
+ t_ = mln_max(T);
+ }
+
+ template <typename T>
+ inline
+ void inf<T>::take_as_init(const argument& t)
+ {
+ t_ = t;
+ }
+
+ template <typename T>
+ inline
+ void inf<T>::take(const argument& t)
+ {
+ this->t_ = this->fun_(t_, t);
+ }
+
+ template <typename T>
+ inline
+ void
+ inf<T>::take(const inf<T>& other)
+ {
+ this->t_ = this->fun_(t_, other.t_);
+ }
+
+ template <typename T>
+ inline
+ const T&
+ inf<T>::to_result() const
+ {
+ return t_;
+ }
+
+ template <typename T>
+ inline
+ bool
+ inf<T>::is_valid() const
+ {
+ return true;
+ }
+
+ # endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_INF_HH
Index: trunk/milena/mln/accu/sup.hh
===================================================================
--- trunk/milena/mln/accu/sup.hh (revision 0)
+++ trunk/milena/mln/accu/sup.hh (revision 3716)
@@ -0,0 +1,166 @@
+// 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 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_ACCU_SUP_HH
+# define MLN_ACCU_SUP_HH
+
+/// \file mln/accu/sup.hh
+///
+/// Define an accumulator that computes a sup.
+
+# include <mln/accu/internal/base.hh>
+# include <mln/core/concept/meta_accumulator.hh>
+# include <mln/trait/value_.hh>
+# include <mln/util/pix.hh>
+# include <mln/fun/math/sup.hh>
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+
+ /// Generic sup accumulator class.
+ /*!
+ * The parameter \c T is the type of values.
+ */
+ template <typename T>
+ struct sup : public mln::accu::internal::base< const T&, sup<T> >
+ {
+ typedef T argument;
+
+ sup();
+
+ /// Manipulators.
+ /// \{
+ void init();
+ void take_as_init(const argument& t);
+ void take(const argument& t);
+ void take(const sup<T>& other);
+ /// \}
+
+ /// Get the value of the accumulator.
+ const T& to_result() const;
+
+ /// Check whether this accu is able to return a result.
+ /// Always true here.
+ bool is_valid() const;
+
+ protected:
+
+ T t_;
+ mln::fun::sup::with<T, T>::ret fun_;
+ };
+
+
+ template <typename I> struct sup< util::pix<I> >;
+
+
+
+ namespace meta
+ {
+
+ /// Meta accumulator for sup.
+
+ struct sup : public Meta_Accumulator< sup >
+ {
+ template <typename T>
+ struct with
+ {
+ typedef accu::sup<T> ret;
+ };
+ };
+
+ } // end of namespace mln::accu::meta
+
+
+
+ # ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ inline
+ sup<T>::sup()
+ {
+ init();
+ }
+
+ template <typename T>
+ inline
+ void
+ sup<T>::init()
+ {
+ t_ = mln_min(T);
+ }
+
+ template <typename T>
+ inline
+ void sup<T>::take_as_init(const argument& t)
+ {
+ t_ = t;
+ }
+
+ template <typename T>
+ inline
+ void sup<T>::take(const argument& t)
+ {
+ this->t_ = this->fun_(t_, t);
+ }
+
+ template <typename T>
+ inline
+ void
+ sup<T>::take(const sup<T>& other)
+ {
+ this->t_ = this->fun_(t_, other.t_);
+ }
+
+ template <typename T>
+ inline
+ const T&
+ sup<T>::to_result() const
+ {
+ return t_;
+ }
+
+ template <typename T>
+ inline
+ bool
+ sup<T>::is_valid() const
+ {
+ return true;
+ }
+
+ # endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_SUP_HH
Index: trunk/milena/mln/fun/binary.hh
===================================================================
--- trunk/milena/mln/fun/binary.hh (revision 0)
+++ trunk/milena/mln/fun/binary.hh (revision 3716)
@@ -0,0 +1,94 @@
+// 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_FUN_BINARY_HH
+# define MLN_FUN_BINARY_HH
+
+# include <mln/core/concept/meta_function.hh>
+# include <mln/fun/spe/binary.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ template <typename F>
+ struct binary : mln::Meta_Function_vv2v< binary<F> >
+ {
+ typedef F flag;
+ typedef mln_trait_fun_storage(flag) storage;
+
+ template <typename T1, typename T2>
+ struct with
+ {
+ typedef spe::binary<F, T1, T2> ret;
+ };
+
+ template <typename T1, typename T2>
+ typename with<T1, T2>::ret::result operator()(const T1& a, const T2& b) const
+ {
+ return typename with<T1, T2>::ret(storage_)(a, b);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value);
+ };
+
+ binary()
+ {
+ }
+
+ template <typename U>
+ binary(const U& param)
+ {
+ this->init(param);
+ }
+
+ stored<storage>& storage_get()
+ {
+ return storage_;
+ }
+
+ const stored<storage>& storage_get() const
+ {
+ return storage_;
+ }
+
+ protected:
+ stored<storage> storage_;
+ };
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_BINARY_HH */
Index: trunk/milena/mln/fun/spe/binary.hh
===================================================================
--- trunk/milena/mln/fun/spe/binary.hh (revision 0)
+++ trunk/milena/mln/fun/spe/binary.hh (revision 3716)
@@ -0,0 +1,136 @@
+// 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_FUN_SPE_BINARY_HH
+# define MLN_FUN_SPE_BINARY_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+/// \todo Implements parameter support
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace spe
+ {
+
+ // Forward declaration
+ template <typename Fun, typename T1, typename T2>
+ struct binary;
+
+ namespace impl
+ {
+
+ template <bool has_param, typename Fun, typename T1, typename T2>
+ struct binary_impl;
+
+ template <typename Fun, typename T1, typename T2>
+ struct binary_impl<false, Fun, T1, T2>
+ : mln::Function_v2v< binary<Fun, T1, T2> >
+ {
+ typedef Fun flag;
+ typedef mln_trait_nbinary(flag, T1, T2) def;
+
+ typedef typename def::argument1 argument1;
+ typedef typename def::argument2 argument2;
+ typedef typename def::result result;
+
+ result operator () (const argument1& a, const argument2& b) const
+ {
+ return def::read(a, b);
+ }
+
+
+ template <typename U>
+ void init(const U& value)
+ {
+ }
+
+ };
+
+ template <typename Fun, typename T1, typename T2>
+ struct binary_impl<true, Fun, T1, T2>
+ : mln::Function_v2v< binary<Fun, T1, T2> >
+ {
+ typedef Fun flag;
+ typedef mln_trait_nbinary(flag, T1, T2) def;
+
+ typedef typename def::argument1 argument1;
+ typedef typename def::argument2 argument2;
+ typedef typename def::result result;
+
+ typedef mln_trait_fun_param(def) param;
+ typedef mln_trait_fun_storage(def) storage;
+
+ result operator () (const argument1& a, const argument2& b) const
+ {
+ return def::read(storage_, a, b);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value);
+ }
+
+ protected:
+ mln::fun::stored<storage> storage_;
+ };
+
+ } // end of namespace mln::fun::spe::impl
+
+ template <typename Fun, typename T1, typename T2>
+ struct binary
+ : impl::binary_impl<mln_trait_fun_is_parametrable_(Fun)::value, Fun, T1, T2>
+ {
+ typedef impl::binary_impl<mln_trait_fun_is_parametrable_(Fun)::value, Fun, T1, T2> super;
+
+ binary()
+ {
+ }
+
+ template <typename U>
+ binary(const U& param)
+ {
+ this->super::init(param);
+ }
+
+ using super::operator();
+ };
+
+ } // end of namespace mln::fun::spe
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_SPE_BINARY_HH */
Index: trunk/milena/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/mln/fun/spe/unary.hh (revision 0)
+++ trunk/milena/mln/fun/spe/unary.hh (revision 3716)
@@ -0,0 +1,302 @@
+// 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_FUN_SPE_UNARY_HH
+# define MLN_FUN_SPE_UNARY_HH
+
+# include <mln/core/concept/function.hh>
+# include <mln/trait/next/solve.hh>
+# include <mln/trait/fun.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace spe
+ {
+
+ // Wrapper for bijective functions
+ template <typename Fun, typename T>
+ struct lwrapper
+ {
+ typedef typename Fun::result result;
+ typedef typename Fun::argument argument;
+ typedef typename Fun::lvalue lvalue;
+ typedef lwrapper lresult;
+
+ lwrapper(const Fun& f, T& x)
+ : x_(&x), f_(&f)
+ {
+ }
+
+ result to_result() const
+ {
+ return (*f_)(*const_cast<const T*>(x_));
+ };
+
+ operator result() const
+ {
+ return to_result();
+ };
+
+ const result& operator = (const result& r) const
+ {
+ argument x(*x_);
+ f_->set(x, r);
+ *x_ = x;
+
+ return r;
+ }
+
+ private:
+ T *x_;
+ const Fun *f_;
+ };
+
+ template <typename Fun>
+ struct lwrapper<Fun, typename Fun::argument>
+ {
+ typedef typename Fun::result result;
+ typedef typename Fun::argument argument;
+ typedef typename Fun::lvalue lvalue;
+ typedef lwrapper lresult;
+
+ lwrapper(const Fun& f, argument& x)
+ : x_(&x), f_(&f)
+ {
+ }
+
+ result to_result() const
+ {
+ return (*f_)(*const_cast<const argument*>(x_));
+ };
+
+ operator result() const
+ {
+ return to_result();
+ };
+
+ const result& operator = (const result& r) const
+ {
+ f_->set(*x_, r);
+
+ return r;
+ }
+
+ private:
+ argument *x_;
+ const Fun *f_;
+ };
+
+ template <typename Fun, typename Any, typename T>
+ struct lwrapper<Fun, lwrapper<Any, T> >
+ {
+ typedef typename Fun::result result;
+ typedef typename Fun::argument argument;
+ typedef typename Fun::lvalue lvalue;
+ typedef lwrapper lresult;
+
+ lwrapper(const Fun& f, const lwrapper<Any, T>& m)
+ : m_(m), f_(&f)
+ {
+ }
+
+ result to_result() const
+ {
+ return (*f_)(m_.to_result());
+ };
+
+ operator result() const
+ {
+ return to_result();
+ };
+
+ const result& operator = (const result& r) const
+ {
+ argument m(m_);
+ f_->set(m, r);
+ m_ = m;
+
+ return r;
+ }
+
+ private:
+ const lwrapper<Any, T> m_;
+ const Fun *f_;
+ };
+
+ template <typename Fun, typename T>
+ struct unary;
+
+ namespace impl
+ {
+
+ template <bool param, bool set, typename Fun, typename T>
+ struct unary_impl;
+
+ template <typename Fun, typename T>
+ struct unary_impl<false, false, Fun, T> : Function_v2v< unary<Fun, T> >
+ {
+ typedef Fun flag;
+ typedef mln_trait_nunary(Fun, T) def;
+
+ typedef typename def::argument argument;
+ typedef typename def::result result;
+
+ result operator () (const argument& value) const
+ {
+ return def::read(value);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ };
+
+ };
+
+ template <typename Fun, typename T>
+ struct unary_impl<false, true, Fun, T> : unary_impl<false, false, Fun, T>
+ {
+ typedef unary_impl<false, false, Fun, T> super;
+ typedef typename super::def::lvalue lvalue;
+
+ template <typename U>
+ struct lresult_with
+ {
+ typedef mln::fun::spe::lwrapper< unary<Fun, T>, U> ret;
+ };
+
+ typedef typename lresult_with<typename super::argument>::ret lresult;
+
+ void set(lvalue l, const typename super::result& r) const
+ {
+ super::def::write(l, r);
+ }
+
+ using super::operator ();
+
+ lresult operator () (typename super::argument& value) const
+ {
+ return lresult(this, value);
+ }
+ };
+
+ template <typename Fun, typename T>
+ struct unary_impl<true, false, Fun, T> : Function_v2v< unary<Fun, T> >
+ {
+ typedef Fun flag;
+ typedef mln_trait_nunary(Fun, T) def;
+
+ typedef typename def::argument argument;
+ typedef typename def::result result;
+
+ typedef mln_trait_fun_param(unary_impl) param;
+ typedef mln_trait_fun_storage(unary_impl) storage;
+
+ result operator () (const argument& value) const
+ {
+ return def::read(this->storage_, value);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value);
+ };
+
+ protected:
+ storage storage_;
+ };
+
+ template <typename Fun, typename T>
+ struct unary_impl<true, true, Fun, T> : unary_impl<true, false, Fun, T>
+ {
+ typedef unary_impl<true, false, Fun, T> super;
+ typedef typename super::def::lvalue lvalue;
+
+ template <typename U>
+ struct lresult_with
+ {
+ typedef mln::fun::spe::lwrapper< unary<Fun, T>, U> ret;
+ };
+
+ typedef typename lresult_with<typename super::argument>::ret lresult;
+
+ void set(lvalue l, const typename super::result& r) const
+ {
+ super::def::write(this->storage_, l, r);
+ }
+
+ using super::operator ();
+
+ lresult operator () (typename super::argument& value) const
+ {
+ return lresult(exact(*this), value);
+ }
+ };
+
+ } // end of namespace mln::fun::spe::impl
+
+ template <typename Fun, typename T>
+ struct unary
+ : impl::unary_impl<mlc_or(mln_trait_fun_is_parametrable(mln_trait_nunary(Fun, T)), mln_trait_fun_is_parametrable(Fun))::value,
+ mln_trait_fun_is_assignable_(mln_trait_nunary(Fun, T))::value, Fun, T>
+ {
+ typedef mln_trait_nunary(Fun, T) def;
+ typedef impl::unary_impl<mlc_or(mln_trait_fun_is_parametrable(def), mln_trait_fun_is_parametrable(Fun))::value,
+ mln_trait_fun_is_assignable_(def)::value,
+ Fun,
+ T>
+ super;
+
+ unary() {}
+
+ template <typename U>
+ unary(const U& param)
+ {
+ this->init(param);
+ }
+
+ using super::operator();
+ };
+
+ } // end of namespace mln::fun::spe
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+template <typename F, typename T>
+std::ostream& operator << (std::ostream& o, const mln::fun::spe::lwrapper<F, T>& m)
+{
+ return o << m.to_result();
+}
+
+#endif /* ! UNARY_HH */
Index: trunk/milena/mln/fun/math/cos.hh
===================================================================
--- trunk/milena/mln/fun/math/cos.hh (revision 0)
+++ trunk/milena/mln/fun/math/cos.hh (revision 3716)
@@ -0,0 +1,91 @@
+// 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_FUN_MATH_COS_HH
+# define MLN_FUN_MATH_COS_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/value/builtin/floatings.hh>
+# include <mln/value/builtin/integers.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct cos : unary<cos> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_unary_<mln::fun::cos, mln::value::Floating, T>
+ {
+ typedef set_unary_ ret;
+ typedef T result;
+ typedef T argument;
+ typedef T& lvalue;
+
+ static result read(const argument& x)
+ {
+ return math::cos(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = math::acos(x);
+ }
+ };
+
+ template <typename T>
+ struct set_unary_<mln::fun::cos, mln::value::Integer, T>
+ {
+ typedef set_unary_ ret;
+ typedef double result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return math::cos((result)x);
+ }
+
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_COS_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/abs.hh
===================================================================
--- trunk/milena/mln/fun/math/abs.hh (revision 0)
+++ trunk/milena/mln/fun/math/abs.hh (revision 3716)
@@ -0,0 +1,69 @@
+// 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_FUN_MATH_ABS_HH
+# define MLN_FUN_MATH_ABS_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/value/concept/scalar.hh>
+# include <mln/math/abs.hh>
+
+namespace mln
+{
+
+ // Absolute value, pure
+ namespace fun
+ {
+ struct abs : unary<abs> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_unary_<mln::fun::abs, mln::value::Scalar, T>
+ {
+ typedef set_unary_ ret;
+ typedef T result;
+ typedef T argument;
+
+ static result read(const argument& x)
+ {
+ return math::abs(x);
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_MATH_ABS_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/sup.hh
===================================================================
--- trunk/milena/mln/fun/math/sup.hh (revision 0)
+++ trunk/milena/mln/fun/math/sup.hh (revision 3716)
@@ -0,0 +1,69 @@
+// 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_FUN_MATH_SUP_HH
+# define MLN_FUN_MATH_SUP_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/math/max.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct sup : binary<sup> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_binary_<mln::fun::sup, mln::Object, T, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef T result;
+ typedef T argument1;
+ typedef T argument2;
+
+ static result read(const argument1& a, const argument1& b)
+ {
+ return math::max(a, b);
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_SUP_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/norm.hh
===================================================================
--- trunk/milena/mln/fun/math/norm.hh (revision 0)
+++ trunk/milena/mln/fun/math/norm.hh (revision 3716)
@@ -0,0 +1,119 @@
+// 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_FUN_MATH_NORM_HH
+# define MLN_FUN_MATH_NORM_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/norm/all.hh>
+
+namespace mln
+{
+
+ // Common norm functions, reversible
+ namespace fun
+ {
+ namespace norm
+ {
+ struct l1 : unary<l1> {};
+
+ struct l2 : unary<l2> {};
+
+ struct linfty : unary<linfty> {};
+ }
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::l1, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::l1(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::l2, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::l2(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::norm::linfty, mln::algebra::vec<n, T> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::algebra::vec<n, T> argument;
+ typedef argument& lvalue;
+ typedef mln_sum_product(argument,argument) result;
+
+ static result read(const argument& x)
+ {
+ return mln::norm::linfty(x);
+ }
+
+ static void write(lvalue l, const result& x)
+ {
+ l = l / read(l) * x;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! NORM_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/inf.hh
===================================================================
--- trunk/milena/mln/fun/math/inf.hh (revision 0)
+++ trunk/milena/mln/fun/math/inf.hh (revision 3716)
@@ -0,0 +1,69 @@
+// 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_FUN_MATH_INF_HH
+# define MLN_FUN_MATH_INF_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/math/min.hh>
+
+namespace mln
+{
+
+ // Cosinus, bijective
+ namespace fun
+ {
+ struct inf : binary<inf> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename T>
+ struct set_binary_<mln::fun::inf, mln::Object, T, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef T result;
+ typedef T argument1;
+ typedef T argument2;
+
+ static result read(const argument1& a, const argument1& b)
+ {
+ return math::min(a, b);
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_MATH_INF_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/unary.hh
===================================================================
--- trunk/milena/mln/fun/unary.hh (revision 0)
+++ trunk/milena/mln/fun/unary.hh (revision 3716)
@@ -0,0 +1,169 @@
+// 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_FUN_UNARY_HH
+# define MLN_FUN_UNARY_HH
+
+# include <mln/core/concept/meta_function.hh>
+# include <mln/fun/spe/unary.hh>
+# include <mln/trait/next/solve.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ // Forward declarations, for composition with unary::operator()(Fun)
+ struct compose;
+
+ namespace internal
+ {
+
+ template <typename U>
+ struct unary_with {};
+
+ }
+
+ template <typename F>
+ struct unary: mln::Meta_Function_v2v< F >
+ {
+ typedef F flag;
+ typedef mln_trait_fun_param(flag) param;
+ typedef mln_trait_fun_storage(flag) storage;
+
+ template <typename T>
+ struct with {
+ typedef mln_trait_nunary(internal::unary_with<F>, T) def;
+ typedef typename def::ret ret;
+ };
+
+ template <typename T>
+ typename with<T>::ret::result operator()(const T& v) const
+ {
+ return with<T>::def::call(exact(*this), v);
+ }
+
+ template <typename T>
+ typename with<T>::ret::template lresult_with<T>::ret operator()(T& v) const
+ {
+ return typename with<T>::ret(storage_get())(v);
+ }
+
+ template <typename T, typename R>
+ void set(T& v, const R& r) const
+ {
+ typename with<T>::ret(storage_).set(v, r);
+ }
+
+ template <typename U>
+ void init(const U& value)
+ {
+ storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value);
+ };
+
+ unary()
+ {
+ }
+
+ template <typename U>
+ unary(const U& param)
+ {
+ this->init(param);
+ }
+
+ stored<storage>& storage_get()
+ {
+ return storage_;
+ }
+
+ const stored<storage>& storage_get() const
+ {
+ return storage_;
+ }
+
+ protected:
+ stored<storage> storage_;
+ };
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Any type
+ template <typename F, typename T>
+ struct set_unary_< mln::fun::internal::unary_with<F>, mln::Object, T>
+ {
+ struct ret_t
+ {
+ typedef mln::fun::spe::unary<F, T> ret;
+
+ static typename ret::result call(const F& f, const T& v)
+ {
+ return ret(f.storage_get())(v);
+ }
+ };
+
+ typedef ret_t ret;
+ };
+
+ // Meta Function
+ template <typename F, typename G>
+ struct set_unary_< mln::fun::internal::unary_with<F>, mln::Meta_Function, G>
+ {
+ // FIXME: Workaround for cyclic references (unary -> unary_with -> compose -> unary)
+ template <typename T>
+ struct identity
+ {
+ typedef T ret;
+ };
+
+ struct ret_t
+ {
+ typedef typename identity<mln::fun::compose>::ret::template with<F, G>::ret ret;
+
+ static typename ret::result call(const F& f, const G& g)
+ {
+ return ret()(f, g);
+ }
+
+ };
+
+ typedef ret_t ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_UNARY_HH */
Index: trunk/milena/mln/fun/from_accu.hh
===================================================================
--- trunk/milena/mln/fun/from_accu.hh (revision 0)
+++ trunk/milena/mln/fun/from_accu.hh (revision 3716)
@@ -0,0 +1,95 @@
+// 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_FUN_FROM_ACCU_HH
+# define MLN_FUN_FROM_ACCU_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // from_accu: wrap an accumulator into a function
+ namespace fun
+ {
+ template <typename A>
+ struct from_accu : unary_param<from_accu<A>, A*>
+ {
+ from_accu() : unary_param<from_accu<A>, A*>() {};
+ from_accu(A* a) : unary_param<from_accu<A>, A*>(a) {};
+ };
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+ template <typename A, typename T>
+ struct set_unary_<mln::fun::from_accu<A>, mln::Object, T>
+ {
+ typedef set_unary_ ret;
+ typedef typename A::result result;
+ typedef typename A::argument argument;
+ typedef A* param;
+
+ set_unary_()
+ {
+ }
+
+ set_unary_(const param& accu)
+ : accu_(accu)
+ {
+ }
+
+ result read(const argument& x) const
+ {
+ mln_precondition(accu_ != 0);
+
+ accu_->take(x);
+ return accu_->to_result ();
+ }
+
+ void init(const param& accu)
+ {
+ accu_ = accu;
+ }
+
+ protected:
+ A* accu_;
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_FROM_ACCU_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/param.hh
===================================================================
--- trunk/milena/mln/fun/param.hh (revision 0)
+++ trunk/milena/mln/fun/param.hh (revision 3716)
@@ -0,0 +1,88 @@
+// 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_FUN_PARAM_HH
+# define MLN_FUN_PARAM_HH
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ template <typename T>
+ struct stored
+ {
+ typedef T value;
+
+ const T& to_value() const
+ {
+ return t_;
+ }
+
+ T& to_value()
+ {
+ return t_;
+ }
+
+ operator const T& () const
+ {
+ return to_value();
+ }
+
+ operator T& ()
+ {
+ return to_value();
+ }
+
+ stored& operator = (const T& t)
+ {
+ t_ = t;
+ return *this;
+ }
+
+ protected:
+ T t_;
+ };
+
+ template <>
+ struct stored<void>
+ {
+ };
+
+ template <typename F>
+ struct parameter
+ {
+ typedef void param;
+ typedef void storage;
+ };
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_PARAM_HH */
Index: trunk/milena/mln/fun/composition.hh
===================================================================
--- trunk/milena/mln/fun/composition.hh (revision 0)
+++ trunk/milena/mln/fun/composition.hh (revision 3716)
@@ -0,0 +1,223 @@
+// 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_FUN_COMPOSITION_HH
+# define MLN_FUN_COMPOSITION_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/fun/binary.hh>
+# include <mln/fun/param.hh>
+
+namespace mln
+{
+ // Composition
+ namespace fun
+ {
+
+ namespace internal
+ {
+
+ // Compositions may take this has initialization parameter
+ template <typename F, typename G>
+ struct composition_param
+ {
+ composition_param(const F& f, const G& g) : f_(f), g_(g) {}
+ composition_param() {}
+
+ F f_;
+ G g_;
+ };
+
+ // Composition types...
+ template <template <class> class CatF, typename F,
+ template <class> class CatG, typename G>
+ struct composition;
+
+ } // end of namespace mln::fun::internal
+
+ template <template <class> class CatF, typename F,
+ template <class> class CatG, typename G>
+ struct parameter< internal::composition<CatF, F, CatG, G> >
+ {
+ typedef internal::composition_param<F, G> param;
+ };
+
+ namespace internal
+ {
+
+ // Meta
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>
+ : mln::fun::unary< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G> >
+ {
+ typedef mln::fun::unary< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G> > super;
+
+ composition() {};
+ composition(const composition_param<F, G>& p) : super(p) {};
+
+ typedef composition exact_type;
+ };
+
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>
+ : mln::fun::binary< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G> >
+ {
+ typedef mln::fun::binary< composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G> > super;
+
+ composition() {};
+ composition(const composition_param<F, G>& p) : super(p) {};
+
+ typedef composition exact_type;
+ };
+
+ // Concrete
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Function_v2v, G>
+ {
+ typedef mln::fun::spe::unary< composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>, typename G::argument> exact_type;
+ };
+
+ template <typename F, typename G>
+ struct composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>
+ {
+ typedef mln::fun::spe::binary< composition<mln::Meta_Function_v2v, F, mln::Function_vv2v, G>,
+ typename G::argument1, typename G::argument2> exact_type;
+ };
+
+ // Unary compositions implementation inherit from composition_unary_impl...
+ template <bool has_lvalue, typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper;
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper<false, F, F_spe, G, G_spe>
+ {
+ typedef typename G_spe::argument argument;
+ typedef typename F_spe::result result;
+ typedef composition_param<F, G> param;
+
+ static result read(const param& p, const argument& x)
+ {
+ return p.f_(p.g_(x));
+ }
+ };
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl_helper<true, F, F_spe, G, G_spe>
+ : composition_unary_impl_helper<false, F, F_spe, G, G_spe>
+ {
+ typedef composition_unary_impl_helper<false, F, F_spe, G, G_spe> super;
+ typedef typename G_spe::lvalue lvalue;
+
+ composition_unary_impl_helper() {}
+ composition_unary_impl_helper(const typename super::param& p) : super(p) {}
+
+ static void write(const typename super::param& p, lvalue l, const typename super::result& x)
+ {
+ typename G_spe::result r(p.g_(l));
+
+ p.f_.set(r, x);
+ p.g_.set(l, r);
+ }
+ };
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_unary_impl
+ : composition_unary_impl_helper<mln_trait_fun_is_assignable_(G_spe)::value, F, F_spe, G, G_spe>
+ {
+ typedef composition_unary_impl_helper<mln_trait_fun_is_assignable_(G_spe)::value, F, F_spe, G, G_spe> super;
+
+ composition_unary_impl() {}
+ composition_unary_impl(const typename super::param& p) : super(p) {}
+ };
+
+ template <typename F, typename F_spe, typename G, typename G_spe>
+ struct composition_binary_impl
+ {
+ typedef typename G_spe::argument1 argument1;
+ typedef typename G_spe::argument2 argument2;
+ typedef typename F_spe::result result;
+ typedef composition_param<F, G> param;
+
+ static result read(const param& p, const argument1& a, const argument2& b)
+ {
+ return p.f_(p.g_(a, b));
+ }
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename F, typename G, typename T>
+ struct set_precise_unary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>, T>
+ {
+ typedef typename G::template with<T>::ret G_fun;
+ typedef typename F::template with<typename G_fun::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_unary_impl<F, F_fun, G, G_fun> ret;
+ };
+
+ template <typename F, typename G, typename T1, typename T2>
+ struct set_precise_binary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>, T1, T2>
+ {
+ typedef typename G::template with<T1, T2>::ret G_fun;
+ typedef typename F::template with<typename G_fun::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_binary_impl<F, F_fun, G, G_fun> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_precise_unary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Function_v2v, G>,
+ typename G::argument>
+ {
+ typedef typename F::template with<typename G::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_unary_impl<F, F_fun, G, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_precise_binary_<mln::fun::internal::composition<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>,
+ typename G::argument1, typename G::argument2>
+ {
+ typedef typename F::template with<typename G::result>::ret F_fun;
+
+ typedef mln::fun::internal::composition_binary_impl<F, F_fun, G, G> ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_COMPOSITION_HH */
Index: trunk/milena/mln/fun/component/blue.hh
===================================================================
--- trunk/milena/mln/fun/component/blue.hh (revision 0)
+++ trunk/milena/mln/fun/component/blue.hh (revision 3716)
@@ -0,0 +1,84 @@
+// 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 blueistribute 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 coveblue by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be coveblue by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_BLUE_HH
+# define MLN_FUN_COMPONENT_BLUE_HH
+
+/// \file mln/fun/component/blue.hh
+///
+/// Meta function to retrieve/modify the blue component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct blue : unary<blue> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::blue, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::blue_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.blue();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.blue() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_BLUE_HH
Index: trunk/milena/mln/fun/component/red.hh
===================================================================
--- trunk/milena/mln/fun/component/red.hh (revision 0)
+++ trunk/milena/mln/fun/component/red.hh (revision 3716)
@@ -0,0 +1,84 @@
+// 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_RED_HH
+# define MLN_FUN_COMPONENT_RED_HH
+
+/// \file mln/fun/component/red.hh
+///
+/// Meta function to retrieve/modify the red component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct red : unary<red> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::red, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::red_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.red();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.red() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_RED_HH
Index: trunk/milena/mln/fun/component/rgb.hh
===================================================================
--- trunk/milena/mln/fun/component/rgb.hh (revision 0)
+++ trunk/milena/mln/fun/component/rgb.hh (revision 3716)
@@ -0,0 +1,40 @@
+// 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_RGB_HH
+# define MLN_FUN_COMPONENT_RGB_HH
+
+/// \file mln/fun/component/red.hh
+///
+/// Meta functions to retrieve/modify rgb components.
+
+# include <mln/fun/component/red.hh>
+# include <mln/fun/component/green.hh>
+# include <mln/fun/component/blue.hh>
+
+#endif // MLN_FUN_COMPONENT_RGB_HH
Index: trunk/milena/mln/fun/component/comp.hh
===================================================================
--- trunk/milena/mln/fun/component/comp.hh (revision 0)
+++ trunk/milena/mln/fun/component/comp.hh (revision 3716)
@@ -0,0 +1,174 @@
+// 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_HH
+# define MLN_FUN_COMPONENT_COMP_HH
+
+/// \file mln/fun/component/comp.hh
+///
+/// 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/value/rgb.hh>
+# include <mln/value/int_u.hh>
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct comp : binary<comp> {};
+
+ struct pcomp;
+
+ template <>
+ struct parameter<pcomp>
+ {
+ typedef unsigned param;
+ };
+
+ struct pcomp : unary<pcomp>
+ {
+ pcomp() : unary<pcomp>(0) {};
+ pcomp(unsigned i = 0) : unary<pcomp>(i) {};
+ };
+
+ struct comp_count : unary<comp_count> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ 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> >
+ {
+ typedef set_precise_unary_ ret;
+// typedef mln::fun::pcomp flag;
+
+ typedef mln::value::rgb<n> argument;
+ typedef mln::value::int_u<n> result;
+ typedef argument& lvalue;
+
+ static result read(unsigned p_i, const argument& v)
+ {
+ return v.comp(p_i);
+ }
+
+ static void write(unsigned p_i, lvalue l, const result& x)
+ {
+ l.comp(p_i) = x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::pcomp, 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;
+ typedef argument& lvalue;
+
+ static result read(unsigned p_i, const argument& v)
+ {
+ return v[p_i];
+ }
+
+ static void write(unsigned p_i, lvalue l, const result& x)
+ {
+ l[p_i] = x;
+ }
+ };
+
+ } // 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/green.hh
===================================================================
--- trunk/milena/mln/fun/component/green.hh (revision 0)
+++ trunk/milena/mln/fun/component/green.hh (revision 3716)
@@ -0,0 +1,84 @@
+// 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 greenistribute 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 covegreen by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covegreen by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_GREEN_HH
+# define MLN_FUN_COMPONENT_GREEN_HH
+
+/// \file mln/fun/component/green.hh
+///
+/// Meta function to retrieve/modify the green component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct green : unary<green> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::green, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::green_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.green();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.green() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_GREEN_HH
Index: trunk/milena/mln/fun/compose.hh
===================================================================
--- trunk/milena/mln/fun/compose.hh (revision 0)
+++ trunk/milena/mln/fun/compose.hh (revision 3716)
@@ -0,0 +1,117 @@
+// 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_FUN_COMPOSE_HH
+# define MLN_FUN_COMPOSE_HH
+
+# include <mln/fun/binary.hh>
+# include <mln/fun/composition.hh>
+# include <mln/fun/param.hh>
+
+namespace mln
+{
+ // Composition
+ namespace fun
+ {
+ struct compose : binary<compose> {};
+
+ namespace internal
+ {
+
+ template <template <class> class CatF, typename F, template <class> class CatG, typename G>
+ struct compose_helper;
+
+ }
+
+ template <template <class> class CatF, typename F,
+ template <class> class CatG, typename G>
+ struct parameter< internal::compose_helper<CatF, F, CatG, G> >
+ {
+ typedef typename internal::composition<CatF, F, CatG, G>::exact_type result;
+ typedef typename result::param param;
+ };
+
+ namespace internal
+ {
+
+ template <template <class> class CatF, typename F, template <class> class CatG, typename G>
+ struct compose_helper
+ {
+ typedef F argument1;
+ typedef G argument2;
+
+ typedef typename composition<CatF, F, CatG, G>::exact_type result;
+ typedef mln_trait_fun_param(result) param;
+
+ static result read(const F& f, const G& g)
+ {
+ return result(param(f, g));
+ }
+ };
+
+ } // end of namespace mln::fun::internal
+
+ } // end of namespace mln::fun
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // All kinds of supported compositions (meta : unary) with (meta or not : unary or binary)
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Meta_Function_v2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Meta_Function_vv2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Function_v2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Function_v2v, G> ret;
+ };
+
+ template <typename F, typename G>
+ struct set_binary_< mln::fun::compose, mln::Meta_Function_v2v, F, mln::Function_vv2v, G>
+ {
+ typedef mln::fun::internal::compose_helper<mln::Meta_Function_v2v, F, mln::Function_vv2v, G> ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif /* ! MLN_FUN_COMPOSE_HH */
Index: trunk/milena/mln/fun/accu_result.hh
===================================================================
--- trunk/milena/mln/fun/accu_result.hh (revision 0)
+++ trunk/milena/mln/fun/accu_result.hh (revision 3716)
@@ -0,0 +1,69 @@
+// 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_FUN_ACCU_RESULT_HH
+# define MLN_FUN_ACCU_RESULT_HH
+
+# include <mln/fun/unary.hh>
+# include <mln/core/concept/accumulator.hh>
+# include <mln/math/acos.hh>
+# include <mln/math/cos.hh>
+
+namespace mln
+{
+
+ // accu_result: return result of given accumulator.
+ namespace fun
+ {
+ struct accu_result : unary<accu_result> {};
+ }
+
+ namespace trait
+ {
+
+ namespace next
+ {
+ template <typename E>
+ struct set_unary_<mln::fun::accu_result, mln::Accumulator, E>
+ {
+ typedef set_unary_ ret;
+ typedef typename E::result result;
+ typedef mln::Accumulator<E> argument;
+
+ static result read(const argument& x)
+ {
+ return exact(x).to_result();
+ }
+ };
+
+ }
+
+ }
+
+}
+
+#endif /* ! MLN_FUN_ACCU_RESULT_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/mln/trait/fun.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_unary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/trait/next/solve.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_proxy.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_binary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/core/image/thrubin_morpher.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/core/image/thru_morpher.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/core/concept/meta_function.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/composition.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/binary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/compose.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/accu_result.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/from_accu.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/unary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/param.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/blue.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/red.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/rgb.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/comp.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/component/green.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/spe/binary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/spe/unary.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/cos.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/abs.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/sup.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/norm.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/fun/math/inf.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/accu/sup.hh (deleted)
===================================================================
Index: trunk/milena/sandbox/fred/mln/accu/inf.hh (deleted)
===================================================================
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-04-27 Frederic Bour <bour(a)lrde.epita.fr>
Add functions working on components, add proxy support for new.
* fred/mln/core/image/thrubin_morpher.hh: New.
* fred/mln/fun/component/blue.hh: New.
* fred/mln/fun/component/comp.hh: New.
* fred/mln/fun/component/green.hh: New.
* fred/mln/fun/component/red.hh: New.
* fred/mln/fun/component/rgb.hh: New.
* fred/mln/fun/component: New.
* fred/mln/fun/spe/unary.hh: Debug parameter handling.
* fred/mln/trait/fun.hh: Debug parameter handling.
* fred/mln/trait/next/solve.hh: Add proxy support.
* fred/mln/trait/next/solve_proxy.hh: New.
* fred/tests/cos.cc: Add/remove tests.
* fred/tests/fun.cc: Add/remove tests.
---
mln/core/image/thrubin_morpher.hh | 279 ++++++++++++++++++++++++++++++++++++++
mln/fun/component/blue.hh | 84 +++++++++++
mln/fun/component/comp.hh | 174 +++++++++++++++++++++++
mln/fun/component/green.hh | 84 +++++++++++
mln/fun/component/red.hh | 84 +++++++++++
mln/fun/component/rgb.hh | 40 +++++
mln/fun/spe/unary.hh | 8 -
mln/trait/fun.hh | 49 +++++-
mln/trait/next/solve.hh | 2
mln/trait/next/solve_proxy.hh | 95 ++++++++++++
tests/cos.cc | 1
tests/fun.cc | 33 ++--
12 files changed, 910 insertions(+), 23 deletions(-)
Index: trunk/milena/sandbox/fred/tests/cos.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/cos.cc (revision 3714)
+++ trunk/milena/sandbox/fred/tests/cos.cc (revision 3715)
@@ -11,6 +11,7 @@
mln::fun::compose compose;
double x;
+
dbg_print(cos(compose)(cos,cos)(x) = 0.857553);
dbg_print(x);
dbg_print(cos(compose)(cos,cos)(0.));
Index: trunk/milena/sandbox/fred/tests/fun.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/fun.cc (revision 3714)
+++ trunk/milena/sandbox/fred/tests/fun.cc (revision 3715)
@@ -3,8 +3,9 @@
#include <mln/fun/math/cos.hh>
#include <mln/fun/math/norm.hh>
// #include <mln/fun/math/inc.hh>
-// #include <mln/fun/math/red.hh>
-
+#include <mln/fun/component/red.hh>
+#include <mln/fun/component/comp.hh>
+#include <mln/value/rgb8.hh>
#include <iostream>
#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
@@ -13,7 +14,9 @@
mln::fun::abs abs;
mln::fun::cos cos;
// mln::fun::inc inc;
-// mln::fun::red red;
+ mln::fun::red red;
+ mln::fun::comp comp;
+ mln::fun::pcomp comp1(1);
mln::fun::norm::l1 l1;
mln::fun::norm::l2 l2;
@@ -41,9 +44,9 @@
dbg_print(cos(0.));
dbg_print(cos(mln::math::acos(0.5)));
-// // RED
-// mln_invariant(red(mln::value::rgb8(8,13,21)) == 8);
-// dbg_print(red(mln::value::rgb8(8,13,21)));
+ // RED
+ mln_invariant(red(mln::value::rgb8(8,13,21)) == 8);
+ dbg_print(red(mln::value::rgb8(8,13,21)));
// NORM
mln::algebra::vec<3, double> v;
@@ -77,13 +80,17 @@
}
// RED
-// {
-// mln::value::rgb8 rgb(8,13,21);
-// dbg_print(rgb);
-// dbg_print(red(rgb) = 0);
-// // FIXME: Doesn't compile! mln_invariant(red(rgb) == 0);
-// dbg_print(rgb);
-// }
+ {
+ mln::value::rgb8 rgb(8,13,21);
+ dbg_print(rgb);
+ 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;
+ }
// NORM
{
Index: trunk/milena/sandbox/fred/mln/trait/fun.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/fun.hh (revision 3714)
+++ trunk/milena/sandbox/fred/mln/trait/fun.hh (revision 3715)
@@ -96,20 +96,21 @@
};
template <typename T>
- struct param_flag_solver<T, typename except_void_t<typename T::flag>::ret>
+ struct param_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::param>::ret>
{
- typedef typename param_solver<typename T::flag, void>::ret ret;
+ typedef mln::fun::parameter<typename T::flag> ret;
};
template <typename T, typename V>
- struct param_def_solver : param_flag_solver<T, 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 T::def>::ret>
+ struct param_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::param>::ret>
{
- typedef typename param_solver<typename T::def, void>::ret ret;
+ typedef mln::fun::parameter<typename T::def> ret;
};
template <typename T, typename V>
@@ -138,6 +139,44 @@
};
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;
Index: trunk/milena/sandbox/fred/mln/trait/next/solve.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve.hh (revision 3714)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve.hh (revision 3715)
@@ -147,6 +147,6 @@
# include <mln/trait/next/solve_unary.hh>
# include <mln/trait/next/solve_binary.hh>
-
+# include <mln/trait/next/solve_proxy.hh>
#endif // ! MLN_TRAIT_NEXT_SOLVE_HH
Index: trunk/milena/sandbox/fred/mln/trait/next/solve_proxy.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/trait/next/solve_proxy.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/trait/next/solve_proxy.hh (revision 3715)
@@ -0,0 +1,95 @@
+// Copyright (C) 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 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_CORE_CONCEPT_PROXY_HH
+# define MLN_CORE_CONCEPT_PROXY_HH
+
+/*! \file mln/core/concept/proxy.hh
+ *
+ * \brief Definition of the concept of mln::Proxy.
+ *
+ * \todo preinc and predec are not tested; post-like ops are not handled.
+ *
+ * \todo add "op=(T)" when possible, so add a constness property.
+ * \todo add "opT()const" when possible.
+ */
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/concept/proxy.hh>
+# include <mln/core/concept/proxy.hxx>
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ // Unary ops.
+
+ template < typename Op, typename P >
+ struct set_unary_< Op, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nunary(Op, S) ret;
+ };
+
+ // Binary ops.
+
+ template < typename Op, typename L, typename R >
+ struct set_binary_< Op, mln::Proxy, L, mln::Proxy, R >
+ {
+ typedef mln::internal::helper_unprox_binop<L, R> helper;
+ typedef mln_trait_nbinary(Op,
+ typename helper::L_ret,
+ typename helper::R_ret) ret;
+ };
+
+ template < typename Op, typename P, typename O >
+ struct set_binary_< Op, mln::Proxy, P, mln::Object, O >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nbinary(Op, S, O) ret;
+ };
+
+ template < typename Op, typename O, typename P >
+ struct set_binary_< Op, mln::Object, O, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_nbinary(Op, O, S) ret;
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_PROXY_HH
Index: trunk/milena/sandbox/fred/mln/core/image/thrubin_morpher.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/core/image/thrubin_morpher.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/core/image/thrubin_morpher.hh (revision 3715)
@@ -0,0 +1,279 @@
+// 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 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_CORE_IMAGE_THRUBIN_MORPHER_HH
+# define MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
+
+# 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>
+
+///
+/// \file mln/core/image/thrubin_morpher.hh
+///
+/// \brief Definition of a morpher that morph values from two images through a binary function.
+///
+
+namespace mln
+{
+
+ // Forward declaration.
+ template <typename I, typename F> struct thrubin_image;
+
+ namespace internal
+ {
+ /// Data structure for \c mln::thrubin_image<I>.
+ template <typename I1, typename I2, typename F>
+ struct data< thrubin_image<I1, I2, F> >
+ {
+ data(I1& ima1, I2& ima2, const F& f);
+
+ I1 ima1_;
+ I2 ima2_;
+ F f_;
+ };
+
+ } // end of namespace mln::internal
+
+
+ namespace trait
+ {
+
+ template <typename I1, typename I2, typename F>
+ struct image_< thrubin_image<I1, I2, F> > : image_< typename mln::internal::thrubin_find_impl<I1, , F>::ret > // Same as I except...
+ {
+ // ...these changes.
+ typedef trait::image::category::value_morpher category;
+ typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
+ typedef trait::image::value_access::computed value_access;
+ typedef trait::image::vw_io::read vw_io;
+ };
+
+ } // end of namespace mln::trait
+
+
+
+ // FIXME: Doc!
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ class thrubin_image_read : public internal::image_value_morpher< I, typename F::result, thrubin_image<I,F> >
+ {
+ public:
+
+ /// Skeleton.
+ typedef thrubin_image<tag::image_<I>, F> skeleton;
+
+ /// Point_Site associated type.
+ typedef mln_psite(I) psite;
+
+ /// Value associated type.
+ typedef typename F::result value;
+
+ /// Return type of read-only access.
+ typedef typename F::result rvalue;
+
+ rvalue operator()(const mln_psite(I)& p) const;
+
+ };
+
+ // Inheritance from read ?!
+ template <typename I, typename F>
+ class thrubin_image_write : public thrubin_image_read<I,F>
+ {
+ public:
+
+ /// Type returned by the read-write pixel value operator.
+// typedef typename F::template lresult<typename F::argument>::ret lvalue;
+ typedef typename F::lresult lvalue;
+
+ using thrubin_image_read<I,F>::operator();
+ lvalue operator()(const mln_psite(I)& p);
+
+ };
+ }
+
+ template <typename I, typename F>
+ class thrubin_image : public internal::thrubin_find_impl<I, F>::ret
+ {
+ public:
+
+ thrubin_image();
+ thrubin_image(I& ima);
+ thrubin_image(I& ima, const F& f);
+
+ void init_(I& ima, const F& f);
+
+ /// Const promotion via conversion.
+ operator thrubin_image<const I, F>() const;
+ };
+
+ template <typename I, typename F>
+ thrubin_image<I, F> thrubin(const mln::Function<F>& f,
+ Image<I>& ima);
+
+ template <typename I, typename F>
+ const thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
+ const Image<I>& ima);
+
+ template <typename I, typename M>
+ thrubin_image<I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, Image<I>& ima);
+
+ template <typename I, typename M>
+ const thrubin_image<const I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // internal::data< thrubin_image<I,S> >
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ data< thrubin_image<I, F> >::data(I& ima, const F& f)
+ : ima_(ima),
+ f_(f)
+ {
+ }
+
+ } // end of namespace mln::internal
+
+ // thrubin_image<I>
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image()
+ {
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image(I& ima, const F& f)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::thrubin_image(I& ima)
+ {
+ mln_precondition(ima.is_valid());
+ init_(ima, mln_value(I)());
+ }
+
+ template <typename I, typename F>
+ inline
+ void
+ thrubin_image<I, F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->is_valid());
+ mln_precondition(ima.is_valid());
+ this->data_ = new internal::data< thrubin_image<I, F> >(ima, f);
+ }
+
+ template <typename I, typename F>
+ inline
+ thrubin_image<I, F>::operator thrubin_image<const I, F>() const
+ {
+ thrubin_image<const I, F> tmp(this->data_->ima_, this->data_->f_);
+ return tmp;
+ }
+
+ namespace internal
+ {
+
+ template <typename I, typename F>
+ inline
+ typename thrubin_image_read<I, F>::rvalue
+ thrubin_image_read<I, F>::operator()(const mln_psite(I)& p) const
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ template <typename I, typename F>
+ inline
+ typename thrubin_image_write<I, F>::lvalue
+ thrubin_image_write<I, F>::operator()(const mln_psite(I)& p)
+ {
+ mln_precondition(this->is_valid());
+ return this->data_->f_(this->data_->ima_(p));
+ }
+
+ }
+
+ // thrubin
+ template <typename I, typename F>
+ thrubin_image<I, F> thrubin(const mln::Function<F>& f,
+ Image<I>& ima)
+ {
+ thrubin_image<I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename F>
+ thrubin_image<const I, F> thrubin(const mln::Function<F>& f,
+ const Image<I>& ima)
+ {
+ thrubin_image<const I, F> tmp(exact(ima), exact(f));
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thrubin_image<I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thrubin_image<I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+ template <typename I, typename M>
+ thrubin_image<const I, mln_fun_with(M, mln_value(I))>
+ thrubin(const mln::Meta_Function<M>& f, const Image<I>& ima)
+ {
+ typedef mln_fun_with(M, mln_value(I)) F;
+ thrubin_image<const I, F> tmp(exact(ima), F());
+
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_IMAGE_THRUBIN_MORPHER_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/blue.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/blue.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/blue.hh (revision 3715)
@@ -0,0 +1,84 @@
+// 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 blueistribute 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 coveblue by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be coveblue by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_BLUE_HH
+# define MLN_FUN_COMPONENT_BLUE_HH
+
+/// \file mln/fun/component/blue.hh
+///
+/// Meta function to retrieve/modify the blue component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct blue : unary<blue> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::blue, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::blue_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.blue();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.blue() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_BLUE_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/red.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/red.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/red.hh (revision 3715)
@@ -0,0 +1,84 @@
+// 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_RED_HH
+# define MLN_FUN_COMPONENT_RED_HH
+
+/// \file mln/fun/component/red.hh
+///
+/// Meta function to retrieve/modify the red component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct red : unary<red> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::red, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::red_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.red();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.red() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_RED_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/rgb.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/rgb.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/rgb.hh (revision 3715)
@@ -0,0 +1,40 @@
+// 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_RGB_HH
+# define MLN_FUN_COMPONENT_RGB_HH
+
+/// \file mln/fun/component/red.hh
+///
+/// Meta functions to retrieve/modify rgb components.
+
+# include <mln/fun/component/red.hh>
+# include <mln/fun/component/green.hh>
+# include <mln/fun/component/blue.hh>
+
+#endif // MLN_FUN_COMPONENT_RGB_HH
Index: trunk/milena/sandbox/fred/mln/fun/component/comp.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/comp.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/comp.hh (revision 3715)
@@ -0,0 +1,174 @@
+// 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_HH
+# define MLN_FUN_COMPONENT_COMP_HH
+
+/// \file mln/fun/component/comp.hh
+///
+/// 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/value/rgb.hh>
+# include <mln/value/int_u.hh>
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct comp : binary<comp> {};
+
+ struct pcomp;
+
+ template <>
+ struct parameter<pcomp>
+ {
+ typedef unsigned param;
+ };
+
+ struct pcomp : unary<pcomp>
+ {
+ pcomp() : unary<pcomp>(0) {};
+ pcomp(unsigned i = 0) : unary<pcomp>(i) {};
+ };
+
+ struct comp_count : unary<comp_count> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ 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> >
+ {
+ typedef set_precise_unary_ ret;
+// typedef mln::fun::pcomp flag;
+
+ typedef mln::value::rgb<n> argument;
+ typedef mln::value::int_u<n> result;
+ typedef argument& lvalue;
+
+ static result read(unsigned p_i, const argument& v)
+ {
+ return v.comp(p_i);
+ }
+
+ static void write(unsigned p_i, lvalue l, const result& x)
+ {
+ l.comp(p_i) = x;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::pcomp, 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;
+ typedef argument& lvalue;
+
+ static result read(unsigned p_i, const argument& v)
+ {
+ return v[p_i];
+ }
+
+ static void write(unsigned p_i, lvalue l, const result& x)
+ {
+ l[p_i] = x;
+ }
+ };
+
+ } // 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/sandbox/fred/mln/fun/component/green.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/component/green.hh (revision 0)
+++ trunk/milena/sandbox/fred/mln/fun/component/green.hh (revision 3715)
@@ -0,0 +1,84 @@
+// 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 greenistribute 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 covegreen by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covegreen by the GNU General
+// Public License.
+
+#ifndef MLN_FUN_COMPONENT_GREEN_HH
+# define MLN_FUN_COMPONENT_GREEN_HH
+
+/// \file mln/fun/component/green.hh
+///
+/// Meta function to retrieve/modify the green component.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct green : unary<green> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::green, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::value::rgb<n> argument;
+ typedef typename argument::green_t result;
+ typedef argument& lvalue;
+
+ static result read(const argument& x)
+ {
+ return x.green();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.green() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_GREEN_HH
Index: trunk/milena/sandbox/fred/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/sandbox/fred/mln/fun/spe/unary.hh (revision 3714)
+++ trunk/milena/sandbox/fred/mln/fun/spe/unary.hh (revision 3715)
@@ -217,8 +217,8 @@
typedef typename def::argument argument;
typedef typename def::result result;
- typedef mln_trait_fun_param(def) param;
- typedef mln_trait_fun_storage(def) storage;
+ typedef mln_trait_fun_param(unary_impl) param;
+ typedef mln_trait_fun_storage(unary_impl) storage;
result operator () (const argument& value) const
{
@@ -266,11 +266,11 @@
template <typename Fun, typename T>
struct unary
- : impl::unary_impl<mln_trait_fun_is_parametrable_(mln_trait_nunary(Fun, T))::value,
+ : impl::unary_impl<mlc_or(mln_trait_fun_is_parametrable(mln_trait_nunary(Fun, T)), mln_trait_fun_is_parametrable(Fun))::value,
mln_trait_fun_is_assignable_(mln_trait_nunary(Fun, T))::value, Fun, T>
{
typedef mln_trait_nunary(Fun, T) def;
- typedef impl::unary_impl<mln_trait_fun_is_parametrable_(def)::value,
+ typedef impl::unary_impl<mlc_or(mln_trait_fun_is_parametrable(def), mln_trait_fun_is_parametrable(Fun))::value,
mln_trait_fun_is_assignable_(def)::value,
Fun,
T>