https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Replace dynamic dispatch in data::paste by static dispatch.
* mln/metal/bool.hh: Upgrade file doc style.
* mln/data/paste.spe.hh (paste_): Rename as...
(paste_dispatch): ...this.
Replace dynamic dispatch by static dispatch:
(paste_direct_ext_dispatch): New.
(paste_direct_noext_dispatch): New.
(paste_one_block_dispatch): New.
* mln/data/paste.hh: Update.
data/paste.hh | 2
data/paste.spe.hh | 140 ++++++++++++++++++++++++++++++++++--------------------
metal/bool.hh | 8 +--
3 files changed, 94 insertions(+), 56 deletions(-)
Index: mln/metal/bool.hh
--- mln/metal/bool.hh (revision 3126)
+++ mln/metal/bool.hh (working copy)
@@ -1,4 +1,5 @@
// 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
@@ -28,10 +29,9 @@
#ifndef MLN_METAL_BOOL_HH
# define MLN_METAL_BOOL_HH
-/*! \file mln/metal/bool.hh
- *
- * \brief Definition of a Boolean value type.
- */
+/// \file mln/metal/bool.hh
+///
+/// Definition of a Boolean value type.
# include <string>
Index: mln/data/paste.spe.hh
--- mln/data/paste.spe.hh (revision 3126)
+++ mln/data/paste.spe.hh (working copy)
@@ -67,6 +67,7 @@
namespace generic
{
+ // Forward declaration.
template <typename I, typename J>
void paste(const Image<I>& input, Image<J>& output);
}
@@ -151,73 +152,99 @@
// Dispatch.
+
namespace internal
{
template <typename I, typename J>
- inline
- void paste_(mln::trait::image::value_access::direct,
- mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::some,
- mln::trait::image::ext_domain::some,
- const Image<I>& input_,
- Image<J>& output_)
+ inline // Direct access and extension.
+ void paste_direct_ext_dispatch(metal::true_, // Same value size.
+ const I& input,
+ J& output)
{
- const I& input = exact(input_);
- J& output = exact(output_);
-
- if (sizeof(mln_value(I)) == sizeof(mln_value(J)))
- {
- if (border::get(input) == border::get(output) &&
- input.domain() == output.domain())
+ if (input.domain() == output.domain()
+ && border::get(input) == border::get(output))
impl::paste_fastest(input, output);
else
impl::paste_lines(input, output);
}
- else
+
+ template <typename I, typename J>
+ inline // Direct access and extension.
+ void paste_direct_ext_dispatch(metal::false_, // Different value size.
+ const I& input,
+ J& output)
+ {
impl::paste_fast(input, output);
}
template <typename I, typename J>
inline
- void paste_(mln::trait::image::value_access::direct,
- mln::trait::image::value_access::direct,
- mln::trait::image::ext_domain::none,
- mln::trait::image::ext_domain::none,
- const Image<I>& input_,
- Image<J>& output_)
+ void paste_dispatch(trait::image::value_access::direct,
+ trait::image::value_access::direct,
+ trait::image::ext_domain::some,
+ trait::image::ext_domain::some,
+ const Image<I>& input,
+ Image<J>& output)
{
- const I& input = exact(input_);
- J& output = exact(output_);
-
+ enum { same_size = sizeof(mln_value(I)) == sizeof(mln_value(J)) };
+ paste_direct_ext_dispatch(metal::bool_<same_size>(),
+ exact(input), exact(output));
+ }
- if (sizeof(mln_value(I)) == sizeof(mln_value(J)))
+ template <typename I, typename J>
+ inline // Direct access and no extension.
+ void paste_direct_noext_dispatch(metal::true_, // Same value size.
+ const I& input,
+ J& output)
{
if (input.domain() == output.domain())
impl::paste_fastest(input, output);
else
impl::paste_lines(input, output);
}
- else
+
+ template <typename I, typename J>
+ inline // Direct access and no extension.
+ void paste_direct_noext_dispatch(metal::false_, // Different value size.
+ const I& input,
+ J& output)
+ {
impl::paste_fast(input, output);
}
+ template <typename I, typename J>
+ inline
+ void paste_dispatch(trait::image::value_access::direct,
+ trait::image::value_access::direct,
+ trait::image::ext_domain::none,
+ trait::image::ext_domain::none,
+ const Image<I>& input,
+ Image<J>& output)
+ {
+ enum { same_size = sizeof(mln_value(I)) == sizeof(mln_value(J)) };
+ paste_direct_noext_dispatch(metal::bool_<same_size>(),
+ exact(input), exact(output));
+ }
template <typename I, typename J>
inline
- void paste_(mln::trait::image::value_access::any,
- mln::trait::image::value_access::any,
- mln::trait::image::ext_domain::any,
- mln::trait::image::ext_domain::any,
+ void paste_dispatch(trait::image::value_access::any,
+ trait::image::value_access::any,
+ trait::image::ext_domain::any,
+ trait::image::ext_domain::any,
const Image<I>& input,
Image<J>& output)
{
impl::generic::paste(input, output);
}
+
+ // Dispatch w.r.t. "value storage".
+
template <typename I, typename J>
inline
- void paste_(trait::image::value_storage::any,
+ void paste_dispatch(trait::image::value_storage::any,
trait::image::value_storage::any,
const Image<I>& input,
Image<J>& output)
@@ -227,7 +254,7 @@
template <typename I, typename J>
inline
- void paste_(trait::image::value_storage::singleton,
+ void paste_dispatch(trait::image::value_storage::singleton,
trait::image::value_storage::any,
const Image<I>& input,
Image<J>& output)
@@ -238,38 +265,49 @@
template <typename I, typename J>
inline
- void paste_(mln::trait::image::value_storage::one_block,
- mln::trait::image::value_storage::one_block,
- const Image<I>& input_,
- Image<J>& output_)
- {
- const I& input = exact(input_);
- J& output = exact(output_);
-
-
- /// Check basic properties
- if (mlc_is(mln_trait_image_value_alignement(I),
- trait::image::value_alignement::with_grid)::value &&
- mlc_is(mln_trait_image_value_alignement(J),
- trait::image::value_alignement::with_grid)::value)
+ void paste_one_block_dispatch(metal::true_, // One-block values and
"grid-aligned".
+ const Image<I>& input,
+ Image<J>& output)
{
- paste_(mln_trait_image_value_access(I)(),
+ paste_dispatch(mln_trait_image_value_access(I)(),
mln_trait_image_value_access(J)(),
mln_trait_image_ext_domain(I)(),
mln_trait_image_ext_domain(J)(),
input, output);
}
- else
+
+ template <typename I, typename J>
+ inline
+ void paste_one_block_dispatch(metal::false_, // One-block values but not
"grid-aligned".
+ const Image<I>& input,
+ Image<J>& output)
+ {
impl::generic::paste(input, output);
}
+ template <typename I, typename J>
+ inline
+ void paste_dispatch(trait::image::value_storage::one_block,
+ trait::image::value_storage::one_block,
+ const Image<I>& input,
+ Image<J>& output)
+ {
+ enum { alignments = mlc_is(mln_trait_image_value_alignement(I),
+ trait::image::value_alignement::with_grid)::value
+ && mlc_is(mln_trait_image_value_alignement(J),
+ trait::image::value_alignement::with_grid)::value };
+ paste_one_block_dispatch(metal::bool_<alignments>(), input, output);
+ }
+
+
+ // Dispatch entry.
template <typename I, typename J>
inline
- void paste_(const Image<I>& input, Image<J>& output)
+ void paste_dispatch(const Image<I>& input, Image<J>& output)
{
- paste_(mln_trait_image_value_storage(I)(),
+ paste_dispatch(mln_trait_image_value_storage(I)(),
mln_trait_image_value_storage(J)(),
input, output);
}
@@ -283,4 +321,4 @@
# endif // ! MLN_INCLUDE_ONLY
-#endif // ! MLN_DATA_PASTE_HH
+#endif // ! MLN_DATA_PASTE_SPE_HH
Index: mln/data/paste.hh
--- mln/data/paste.hh (revision 3126)
+++ mln/data/paste.hh (working copy)
@@ -130,7 +130,7 @@
trace::entering("data::paste");
internal::paste_tests(input, output);
- internal::paste_(input, output);
+ internal::paste_dispatch(input, output);
trace::exiting("data::paste");
}