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>