URL:
https://svn.lrde.epita.fr/svn/oln/trunk
ChangeLog:
2009-04-28 Frederic Bour <bour(a)lrde.epita.fr>
Correct bugs, point functions.
* milena/mln/fun/point/col.hh: New.
* milena/mln/fun/point/row.hh: New.
* milena/mln/fun/point/sli.hh: New.
* milena/mln/fun/point: New.
* milena/mln/fun/spe/unary.hh: Improved proxy support.
* milena/mln/fun/unary.hh: Improved proxy support.
* milena/mln/trait/next/solve_proxy.hh: Typo errors correction.
* milena/sandbox/fred/tests/fun.cc,
* milena/sandbox/fred/tests/thru.cc: Add some tests for proxy.
---
mln/fun/point/col.hh | 84 ++++++++++++++++++++++++++++++++++++++++++
mln/fun/point/row.hh | 84 ++++++++++++++++++++++++++++++++++++++++++
mln/fun/point/sli.hh | 84 ++++++++++++++++++++++++++++++++++++++++++
mln/fun/spe/unary.hh | 26 ++++++++++++-
mln/fun/unary.hh | 2 -
mln/trait/next/solve_proxy.hh | 15 ++-----
sandbox/fred/tests/fun.cc | 2 -
sandbox/fred/tests/thru.cc | 12 ++++++
8 files changed, 295 insertions(+), 14 deletions(-)
Index: trunk/milena/mln/trait/next/solve_proxy.hh
===================================================================
--- trunk/milena/mln/trait/next/solve_proxy.hh (revision 3721)
+++ trunk/milena/mln/trait/next/solve_proxy.hh (revision 3722)
@@ -25,17 +25,12 @@
// 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
+#ifndef MLN_TRAIT_NEXT_SOLVE_PROXY_HH
+# define MLN_TRAIT_NEXT_SOLVE_PROXY_HH
-/*! \file mln/core/concept/proxy.hh
+/*! \file mln/trait/next/solve_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.
+ * \brief Proxy support for "next" trait solver.
*/
# include <mln/core/concept/object.hh>
@@ -99,4 +94,4 @@
} // end of namespace mln
-#endif // ! MLN_CORE_CONCEPT_PROXY_HH
+#endif // ! MLN_TRAIT_NEXT_SOLVE_PROXY_HH
Index: trunk/milena/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/mln/fun/spe/unary.hh (revision 3721)
+++ trunk/milena/mln/fun/spe/unary.hh (revision 3722)
@@ -202,9 +202,20 @@
using super::operator ();
+ lresult apply_rw(typename super::argument& value) const
+ {
+ return lresult(exact(*this), value);
+ }
+
+ template <typename U>
+ typename lresult_with<U>::ret apply_rw(U& value) const
+ {
+ return typename lresult_with<U>::ret(exact(*this), value);
+ }
+
lresult operator () (typename super::argument& value) const
{
- return lresult(this, value);
+ return apply_rw(value);
}
};
@@ -256,10 +267,21 @@
using super::operator ();
- lresult operator () (typename super::argument& value) const
+ lresult apply_rw(typename super::argument& value) const
{
return lresult(exact(*this), value);
}
+
+ template <typename U>
+ typename lresult_with<U>::ret apply_rw(U& value) const
+ {
+ return typename lresult_with<U>::ret(exact(*this), value);
+ }
+
+ lresult operator () (typename super::argument& value) const
+ {
+ return apply_rw(value);
+ }
};
} // end of namespace mln::fun::spe::impl
Index: trunk/milena/mln/fun/point/row.hh
===================================================================
--- trunk/milena/mln/fun/point/row.hh (revision 0)
+++ trunk/milena/mln/fun/point/row.hh (revision 3722)
@@ -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 rowistribute 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_POINT_ROW_HH
+# define MLN_FUN_POINT_ROW_HH
+
+/// \file mln/fun/point/row.hh
+///
+/// Meta function to retrieve/modify the row coord of a point.
+
+# include <mln/fun/unary.hh>
+# include <mln/core/point.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct row : unary<row> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename G, typename C>
+ struct set_precise_unary_<mln::fun::row, mln::point<G,C> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::point<G,C> argument;
+ typedef typename argument::coord result;
+ typedef argument& lvalue;
+
+ static result read(const argument& p)
+ {
+ return p.row();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.row() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_POINT_ROW_HH
Index: trunk/milena/mln/fun/point/sli.hh
===================================================================
--- trunk/milena/mln/fun/point/sli.hh (revision 0)
+++ trunk/milena/mln/fun/point/sli.hh (revision 3722)
@@ -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 rowistribute 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_POINT_SLI_HH
+# define MLN_FUN_POINT_SLI_HH
+
+/// \file mln/fun/point/sli.hh
+///
+/// Meta function to retrieve/modify the sli coord of a point.
+
+# include <mln/fun/unary.hh>
+# include <mln/core/point.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct sli : unary<sli> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename G, typename C>
+ struct set_precise_unary_<mln::fun::col, mln::point<G, C> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::point<G,C> argument;
+ typedef typename argument::coord result;
+ typedef argument& lvalue;
+
+ static result read(const argument& p)
+ {
+ return p.sli();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.sli() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_POINT_SLI_HH
Index: trunk/milena/mln/fun/point/col.hh
===================================================================
--- trunk/milena/mln/fun/point/col.hh (revision 0)
+++ trunk/milena/mln/fun/point/col.hh (revision 3722)
@@ -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 rowistribute 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_POINT_COL_HH
+# define MLN_FUN_POINT_COL_HH
+
+/// \file mln/fun/point/col.hh
+///
+/// Meta function to retrieve/modify the col coord of a point.
+
+# include <mln/fun/unary.hh>
+# include <mln/core/point.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct col : unary<col> {};
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename G, typename C>
+ struct set_precise_unary_<mln::fun::col, mln::point<G, C> >
+ {
+ typedef set_precise_unary_ ret;
+ typedef mln::point<G,C> argument;
+ typedef typename argument::coord result;
+ typedef argument& lvalue;
+
+ static result read(const argument& p)
+ {
+ return p.col();
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ l.col() = r;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_POINT_COL_HH
Index: trunk/milena/mln/fun/unary.hh
===================================================================
--- trunk/milena/mln/fun/unary.hh (revision 3721)
+++ trunk/milena/mln/fun/unary.hh (revision 3722)
@@ -71,7 +71,7 @@
template <typename T>
typename with<T>::ret::template lresult_with<T>::ret operator()(T&
v) const
{
- return typename with<T>::ret(storage_get())(v);
+ return typename with<T>::ret(storage_get()).apply_rw(v);
}
template <typename T, typename R>
Index: trunk/milena/sandbox/fred/tests/thru.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/thru.cc (revision 3721)
+++ trunk/milena/sandbox/fred/tests/thru.cc (revision 3722)
@@ -6,11 +6,16 @@
#include <mln/core/var.hh>
#include <mln/core/image/image2d.hh>
+
+#include <mln/fun/point/row.hh>
+
#include <mln/value/int_u8.hh>
#include <mln/debug/all.hh>
#include <iostream>
#include <typeinfo>
+#include <mln/trait/next/solve_proxy.hh>
+
#define dbg_print(val) std::cout << #val << "\n\t -> \t"
<< (val) << std::endl
int main()
@@ -32,5 +37,12 @@
data::fill_with_image(ima2, tmp);
+ mln::fun::row row;
+
+ mln_piter_(I) p(ima.domain());
+
+ for_all(p)
+ std::cout << row(p);
+
debug::println(ima2);
}
\ No newline at end of file
Index: trunk/milena/sandbox/fred/tests/fun.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/fun.cc (revision 3721)
+++ trunk/milena/sandbox/fred/tests/fun.cc (revision 3722)
@@ -2,10 +2,10 @@
#include <mln/fun/math/abs.hh>
#include <mln/fun/math/cos.hh>
#include <mln/fun/math/norm.hh>
-// #include <mln/fun/math/inc.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