https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Some fixes on level update and compute.
* mln/level/update.hh: Fix missing 'inline'.
Remove useless include.
* mln/level/compute.hh: Rely on level::update.
Remove redundant code.
compute.hh | 125 ++++---------------------------------------------------------
update.hh | 6 ++
2 files changed, 15 insertions(+), 116 deletions(-)
Index: mln/level/update.hh
--- mln/level/update.hh (revision 2548)
+++ mln/level/update.hh (working copy)
@@ -35,7 +35,6 @@
# include <mln/core/concept/accumulator.hh>
# include <mln/core/concept/image.hh>
-# include <mln/core/concept/meta_accumulator.hh>
@@ -92,6 +91,7 @@
{
template <typename A, typename I>
+ inline
mln_result(A)
update(Accumulator<A>& a_, const Image<I>& input_)
{
@@ -113,6 +113,7 @@
template <typename A, typename I>
+ inline
mln_result(A)
update_fastest(Accumulator<A>& a_, const Image<I>& input_)
{
@@ -141,6 +142,7 @@
{
template <typename A, typename I>
+ inline
mln_result(A)
update_dispatch(trait::image::speed::any,
Accumulator<A>& a, const Image<I>& input)
@@ -149,6 +151,7 @@
}
template <typename A, typename I>
+ inline
mln_result(A)
update_dispatch(trait::image::speed::fastest,
Accumulator<A>& a, const Image<I>& input)
@@ -157,6 +160,7 @@
}
template <typename A, typename I>
+ inline
mln_result(A)
update_dispatch(Accumulator<A>& a, const Image<I>& input)
{
Index: mln/level/compute.hh
--- mln/level/compute.hh (revision 2548)
+++ mln/level/compute.hh (working copy)
@@ -33,8 +33,7 @@
* \brief Compute an accumulator onto image pixel values.
*/
-# include <mln/core/concept/accumulator.hh>
-# include <mln/core/concept/image.hh>
+# include <mln/level/update.hh>
# include <mln/core/concept/meta_accumulator.hh>
@@ -50,6 +49,8 @@
* \param[in] a An accumulator.
* \param[in] input The input image.
* \return The accumulator result.
+ *
+ * It fully relies on level::update.
*/
template <typename A, typename I>
mln_result(A)
@@ -71,133 +72,27 @@
# ifndef MLN_INCLUDE_ONLY
- // Tests.
-
- namespace internal
- {
+ // Facades.
template <typename A, typename I>
inline
- void
- compute_tests(const Accumulator<A>& a_, const Image<I>&
input_)
- {
- const A& a = exact(a_);
- const I& input = exact(input_);
- mln_precondition(input.has_data());
- // sizeof(a.take(mln_value(I)()));
-
- (void) a;
- (void) input;
- }
-
- } // end of namespace internal
-
-
-
- // Implementations.
-
- namespace impl
- {
-
- namespace generic
- {
-
- template <typename A, typename I>
mln_result(A)
- compute(const Accumulator<A>& a_, const Image<I>& input_)
+ compute(const Accumulator<A>& a_, const Image<I>& input)
{
- trace::entering("level::impl::generic::compute");
-
- A a = exact(a_);
- const I& input = exact(input_);
- internal::compute_tests(a, input);
-
- a.init();
- mln_piter(I) p(input.domain());
- for_all(p)
- a.take(input(p));
-
- trace::exiting("level::impl::generic::compute");
- return a.to_result();
- }
-
- } // end of namespace mln::level::impl::generic
-
-
- template <typename A, typename I>
- mln_result(A)
- compute_fastest(const Accumulator<A>& a_, const Image<I>&
input_)
- {
- trace::entering("level::impl::compute_fastest");
+ trace::entering("level::compute");
A a = exact(a_);
- const I& input = exact(input_);
- internal::compute_tests(a, input);
+ level::internal::update_tests(a, input);
a.init();
- mln_pixter(const I) pxl(input);
- for_all(pxl)
- a.take(pxl.val());
-
- trace::exiting("level::impl::compute_fastest");
- return a.to_result();
- }
-
-
- } // end of namespace mln::level::impl
-
-
-
- // Dispatch.
-
- namespace internal
- {
-
- template <typename A, typename I>
- mln_result(A)
- compute_dispatch(trait::image::speed::any,
- const Accumulator<A>& a, const Image<I>& input)
- {
- return impl::generic::compute(a, input);
- }
-
- template <typename A, typename I>
- mln_result(A)
- compute_dispatch(trait::image::speed::fastest,
- const Accumulator<A>& a, const Image<I>& input)
- {
- return impl::compute_fastest(a, input);
- }
-
- template <typename A, typename I>
- mln_result(A)
- compute_dispatch(const Accumulator<A>& a, const Image<I>&
input)
- {
- return compute_dispatch(mln_trait_image_speed(I)(),
- a, input);
- }
-
- } // end of namespace internal
-
-
-
- // Facades.
-
- template <typename A, typename I>
- inline
- mln_result(A)
- compute(const Accumulator<A>& a, const Image<I>& input)
- {
- trace::entering("level::compute");
-
- internal::compute_tests(a, input);
- mln_result(A) r = internal::compute_dispatch(a, input);
+ level::internal::update_dispatch(a, input);
trace::exiting("level::compute");
- return r;
+ return a;
}
template <typename A, typename I>
+ inline
mln_accu_with(A, mln_value(I))::result
compute(const Meta_Accumulator<A>&, const Image<I>& input)
{