https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Change requirements for accumulators.
Now an accumulator have to pass a qualified result as
super class parameter. In addition no result typedef is
required.
* doc/examples/tuto_bis.cc: Update.
* mln/core/macros.hh (mln_q_result, mln_q_result_): New.
* mln/core/concept/object.hh (unqualif): New include.
* mln/core/concept/accumulator.hh (q_result): New.
(to_result, operator): Update return type.
* mln/accu/min.hh: Update.
* mln/accu/internal/base.hh (result, q_result): Factor.
doc/examples/tuto_bis.cc | 3 ++-
mln/accu/internal/base.hh | 3 ++-
mln/accu/min.hh | 7 +++----
mln/core/concept/accumulator.hh | 11 ++++++-----
mln/core/concept/object.hh | 3 +++
mln/core/macros.hh | 6 ++++++
6 files changed, 22 insertions(+), 11 deletions(-)
Index: doc/examples/tuto_bis.cc
--- doc/examples/tuto_bis.cc (revision 2557)
+++ doc/examples/tuto_bis.cc (working copy)
@@ -215,6 +215,7 @@
// }
+ border::thickness = 0;
image2d<int> ima(3, 5);
@@ -337,7 +338,7 @@
fun::i2v::array<int> m(nbasins + 1);
- accu::compute<accu::mean>(cell, label, m);
+ accu::compute<accu::meta::mean>(cell, label, m);
for (unsigned i = 1; i <= nbasins; ++i)
std::cout << "mean value of basin #" << i << " is
" << m(i) << std::endl;
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 2557)
+++ mln/core/macros.hh (working copy)
@@ -281,6 +281,12 @@
# define mln_qiter_(T) T::fwd_qiter
/// \}
+/// Shortcuts to access the qualified-result type associated to T.
+/// \{
+# define mln_q_result(T) typename T::q_result
+# define mln_q_result_(T) T::q_result
+/// \}
+
/// Shortcuts to access the qualified-subject type associated to T.
/// \{
# define mln_q_subject(T) typename T::q_subject
Index: mln/core/concept/object.hh
--- mln/core/concept/object.hh (revision 2557)
+++ mln/core/concept/object.hh (working copy)
@@ -41,10 +41,13 @@
# include <mln/core/contract.hh>
# include <mln/core/internal/fixme.hh>
# include <mln/trace/all.hh>
+
+// metal
# include <mln/metal/is_a.hh>
# include <mln/metal/is.hh>
# include <mln/metal/is_not.hh>
# include <mln/metal/ret.hh>
+# include <mln/metal/unqualif.hh>
/*! \mainpage Documentation of milena
Index: mln/core/concept/accumulator.hh
--- mln/core/concept/accumulator.hh (revision 2557)
+++ mln/core/concept/accumulator.hh (working copy)
@@ -68,13 +68,14 @@
/*
typedef argument;
typedef result;
+ typedef q_result;
void init();
void take(const argument& t);
void take(const E& other);
- result to_result() const;
- operator mlc_unqualif(result) const;
+ q_result to_result() const;
+ operator q_result const;
bool is_valid() const;
*/
@@ -96,6 +97,7 @@
{
typedef mln_argument(E) argument;
typedef mln_result(E) result;
+ typedef mln_q_result(E) q_result;
void (E::*m1)() = & E::init;
m1 = 0;
@@ -104,10 +106,9 @@
void (E::*m3)(const E&) = & E::take;
m3 = 0;
- result (E::*m4)() const = & E::to_result;
+ q_result (E::*m4)() const = & E::to_result;
m4 = 0;
- typedef mlc_fix_return(mlc_const_return(result)) result_;
- result_ (E::*m5)() const = & E::operator result_;
+ q_result (E::*m5)() const = & E::operator q_result;
m5 = 0;
bool (E::*m6)() const = & E::is_valid;
Index: mln/accu/min.hh
--- mln/accu/min.hh (revision 2557)
+++ mln/accu/min.hh (working copy)
@@ -51,10 +51,9 @@
* The parameter \c T is the type of values.
*/
template <typename T>
- struct min_ : public mln::accu::internal::base< T, min_<T> >
+ struct min_ : public mln::accu::internal::base< const T&, min_<T> >
{
typedef T argument;
- typedef T result;
min_();
@@ -67,7 +66,7 @@
/// \}
/// Get the value of the accumulator.
- T to_result() const;
+ const T& to_result() const;
/// Check whether this accu is able to return a result.
/// Always true here.
@@ -144,7 +143,7 @@
template <typename T>
inline
- T
+ const T&
min_<T>::to_result() const
{
return t_;
Index: mln/accu/internal/base.hh
--- mln/accu/internal/base.hh (revision 2557)
+++ mln/accu/internal/base.hh (working copy)
@@ -59,7 +59,8 @@
R subj_();
// As an accumulator:
- typedef R result;
+ typedef R q_result;
+ typedef mlc_unqualif(R) result;
protected:
base();