https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
A lot of cleaning works.
Make the exact routines work with any data.
* mln/core/concept/object.hh (exact_t): New typedef.
* mln/core/internal/exact.hh: New.
* mln/core/exact.hh (exact): Update.
(exact): Remove overloads with const; useless.
* tests/core_exact.cc: New.
Rename init as initialize.
* mln/core/concept/image.hh (init): Rename as...
(initialize): ...this.
* tests/core_init.cc: Rename as...
* tests/core_initialize.cc: ...this.
Update.
* tests/image_if.cc,
* mln/core/clone.hh,
* mln/canvas/morpho/algebraic_union_find.hh,
* mln/canvas/labeling.hh: Update.
Augment and clean mln/metal.
* mln/metal/is_const.hh: New.
* mln/core/internal/image_morpher.hh: New include.
* mln/metal/goes_to.hh: New.
* mln/metal/converts_to.hh: New.
* mln/metal/is.hh: New.
* mln/metal/is_unqualif.hh: New.
* tests/metal_converts_to.cc: New.
* tests/metal_is.cc: New.
* tests/metal_unconst.cc: New.
* mln/metal/unqualif.hh: Add FIXME.
* mln/metal/unconst.hh: New overload.
Add FIXME.
* mln/metal/bool.hh (true_, false_): New aliases.
(eval, check): New in bool_<true>.
(eval, check_not): New in bool_<false>.
(to_bool): Remove.
* mln/metal/bexpr.hh (true_, false_): Remove; obsolete.
(mlc_not, mlc_and, mlc_or, mlc_xor): New.
* mln/metal/if.hh,
* mln/metal/all.hh,
* mln/metal/is_a.hh: Update.
* mln/fun/internal/selector.hh (tag_): Update.
* mln/value/props.hh (mln_is_lowq): Update.
* mln/metal/vec.hh: Fix missing inheritance.
Fix warning about missing cpy ctor.
* mln/metal/binary_arith_trait.hh: Add FIXME.
* tests/metal_vec.cc,
* tests/metal_mat.cc: Fix doc.
Start factoring the conversion op.
* mln/accu/internal: New directory.
* mln/accu/internal/base.hh: New.
* mln/core/concept/accumulator.hh: Augment todo entry.
* mln/accu/median.hh: Update inheritance.
* mln/level/fast_median.hh (to_result): Remove; useless.
Start trace mechanism.
* mln/trace: New directory.
* mln/trace/exiting.hh: New.
* mln/trace/quiet.hh: New.
* mln/trace/all.hh: New.
* mln/trace/entering.hh: New.
* tests/level_paste.cc: Add tracing calls.
Better browsing materials.
* mln/core/concept/browsing.hh: New.
* mln/canvas/browsing/fwd.hh: New.
* mln/canvas/browsing/snake_fwd.hh: Update.
* mln/fun/p2v/iota.hh: New.
* tests/canvas_browsing_fwd.cc: New.
Better and update image traits.
* mln/trait/images.hh: New bunch of macros.
(category): New.
(io): Add new flag types.
(default_image_, default_image_morpher_): Clean.
Fix comments.
* mln/core/image2d_b.hh (image_): Move at bof.
* mln/core/image1d_b.hh,
* mln/core/image3d_b.hh,
* mln/core/image_if.hh,
* mln/pw/image.hh (image_): New traits.
* mln/core/sub_image.hh: Update traits.
* mln/level/fill.hh (todo): Augment.
(fill): Check input writability.
* mln/level/paste.hh,
* mln/morpho/plus.hh,
* mln/morpho/min.hh,
* mln/morpho/minus.hh,
* mln/morpho/complementation.hh,
* mln/morpho/dilation.hh,
* mln/morpho/erosion.hh,
* mln/morpho/hit_or_miss.hh: Update with trait flags.
* tests/level_fill.cc: Add into comments an anti-test.
* tests/trait_images.cc: Update.
Introduce the notion of interval of values.
* mln/value/interval.hh: New.
* mln/value/all.hh: Update.
* mln/core/image_if.hh: New overload using interval.
Misc.
* mln/border/get.hh: Fix warning.
* mln/core/macros.hh (mln_result_): New.
* mln/core/ops.hh: New todo entry.
* mln/fun/ops.hh: Shorter names.
* mln/util/nil.hh: New.
* mln/util/ignore.hh,
* mln/util/eat.hh: Fix missing inheritance.
* TODO: Augment.
TODO | 18 ++
mln/accu/internal/base.hh | 93 ++++++++++++
mln/accu/median.hh | 4
mln/border/get.hh | 2
mln/canvas/browsing/fwd.hh | 103 ++++++++++++++
mln/canvas/browsing/snake_fwd.hh | 12 +
mln/canvas/labeling.hh | 8 -
mln/canvas/morpho/algebraic_union_find.hh | 10 -
mln/core/clone.hh | 2
mln/core/concept/accumulator.hh | 2
mln/core/concept/browsing.hh | 79 ++++++++++
mln/core/concept/image.hh | 4
mln/core/concept/object.hh | 8 -
mln/core/exact.hh | 48 ++----
mln/core/image1d_b.hh | 23 +++
mln/core/image2d_b.hh | 41 +++--
mln/core/image3d_b.hh | 23 +++
mln/core/image_if.hh | 88 +++++++++++-
mln/core/internal/exact.hh | 124 +++++++++++++++++
mln/core/internal/image_morpher.hh | 1
mln/core/macros.hh | 1
mln/core/ops.hh | 2
mln/core/sub_image.hh | 47 +++---
mln/fun/internal/selector.hh | 2
mln/fun/ops.hh | 16 +-
mln/fun/p2v/iota.hh | 102 ++++++++++++++
mln/level/fast_median.hh | 6
mln/level/fill.hh | 3
mln/level/paste.hh | 42 +++--
mln/metal/all.hh | 26 +++
mln/metal/bexpr.hh | 40 +----
mln/metal/binary_arith_trait.hh | 3
mln/metal/bool.hh | 36 +++--
mln/metal/converts_to.hh | 79 ++++++++++
mln/metal/goes_to.hh | 64 ++++++++
mln/metal/if.hh | 2
mln/metal/is.hh | 90 ++++++++++++
mln/metal/is_a.hh | 2
mln/metal/is_const.hh | 62 ++++++++
mln/metal/is_unqualif.hh | 53 +++++++
mln/metal/unconst.hh | 9 +
mln/metal/unqualif.hh | 3
mln/metal/vec.hh | 23 ++-
mln/morpho/complementation.hh | 2
mln/morpho/dilation.hh | 2
mln/morpho/erosion.hh | 2
mln/morpho/hit_or_miss.hh | 2
mln/morpho/min.hh | 4
mln/morpho/minus.hh | 2
mln/morpho/plus.hh | 2
mln/pw/image.hh | 25 +++
mln/trace/all.hh | 52 +++++++
mln/trace/entering.hh | 67 +++++++++
mln/trace/exiting.hh | 67 +++++++++
mln/trace/quiet.hh | 51 +++++++
mln/trait/images.hh | 216 +++++++++++++++++++-----------
mln/util/eat.hh | 2
mln/util/ignore.hh | 2
mln/util/nil.hh | 97 +++++++++++++
mln/value/all.hh | 2
mln/value/interval.hh | 101 ++++++++++++++
mln/value/props.hh | 2
tests/canvas_browsing_fwd.cc | 100 +++++++++++++
tests/core_exact.cc | 54 +++++++
tests/core_initialize.cc | 12 -
tests/image_if.cc | 2
tests/level_fill.cc | 7
tests/level_paste.cc | 2
tests/metal_converts_to.cc | 84 +++++++++++
tests/metal_is.cc | 82 +++++++++++
tests/metal_mat.cc | 4
tests/metal_unconst.cc | 93 ++++++++++++
tests/metal_vec.cc | 4
tests/trait_images.cc | 7
74 files changed, 2280 insertions(+), 277 deletions(-)
Index: tests/metal_mat.cc
--- tests/metal_mat.cc (revision 1201)
+++ tests/metal_mat.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/level_median.cc
+/*! \file tests/metal_mat.cc
*
- * \brief Test on mln::median::median_dir.
+ * \brief Test on mln::metal::mat.
*/
#include <mln/metal/mat.hh>
Index: tests/core_initialize.cc
--- tests/core_initialize.cc (revision 1199)
+++ tests/core_initialize.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core_init.cc
+/*! \file tests/core_initialize.cc
*
- * \brief Tests on mln::init.
+ * \brief Tests on mln::initialize.
*/
#include <mln/core/image2d_b.hh>
@@ -47,7 +47,7 @@
{
I ima;
- init(ima, ref);
+ initialize(ima, ref);
debug::println(ima);
mln_assertion(ima.border() = ref.border());
}
@@ -55,19 +55,19 @@
{
I ima_; // to init'd
sub_image<I, box2d> ima = ref | b;
- init(ima_, ima);
+ initialize(ima_, ima);
debug::println(ima);
}
{
sub_image<I, box2d> ima;
- init(ima, ref);
+ initialize(ima, ref);
debug::println(ima);
}
{
sub_image<I, box2d> ima;
- init(ima, ref | b);
+ initialize(ima, ref | b);
debug::println(ima);
}
Index: tests/core_exact.cc
--- tests/core_exact.cc (revision 0)
+++ tests/core_exact.cc (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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.
+
+/*! \file tests/core_exact.cc
+ *
+ * \brief Tests on mln::exact.
+ */
+
+#include <typeinfo>
+#include <mln/core/exact.hh>
+
+
+struct test : mln::Object< test >
+{
+};
+
+
+int main()
+{
+ using namespace mln;
+
+ test t;
+ std::cout << typeid(exact(t)).name() << std::endl;;
+
+ Object<test>& t_ = t;
+ std::cout << typeid(exact(t_)).name() << std::endl;;
+
+ int i;
+ std::cout << typeid(exact(i)).name() << std::endl;;
+}
Index: tests/level_fill.cc
--- tests/level_fill.cc (revision 1201)
+++ tests/level_fill.cc (working copy)
@@ -31,6 +31,7 @@
*/
#include <mln/core/image2d_b.hh>
+#include <mln/core/sub_image.hh>
#include <mln/level/fill.hh>
#include <mln/debug/println.hh>
@@ -60,4 +61,10 @@
level::fill(ima, uc);
}
+// {
+// // do *not* compile so that's great since ima is not mutable
+// sub_image< const image2d_b<int>, box2d > ima;
+// level::fill(ima, 0);
+// }
+
}
Index: tests/metal_vec.cc
--- tests/metal_vec.cc (revision 1201)
+++ tests/metal_vec.cc (working copy)
@@ -25,9 +25,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/level_median.cc
+/*! \file tests/metal_vec.cc
*
- * \brief Test on mln::median::median_dir.
+ * \brief Test on mln::metal::vec.
*/
#include <mln/metal/vec.hh>
Index: tests/metal_converts_to.cc
--- tests/metal_converts_to.cc (revision 0)
+++ tests/metal_converts_to.cc (revision 0)
@@ -0,0 +1,84 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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.
+
+/*! \file tests/metal_converts_to.cc
+ *
+ * \brief Test on mln::metal::converts_to.
+ */
+
+#include <mln/metal/converts_to.hh>
+
+
+
+struct from_1
+{
+};
+
+struct dest
+{
+ dest(const from_1&) {}
+};
+
+struct from_2
+{
+ operator dest() const { dest* tmp; return *tmp; }
+};
+
+
+struct base
+{
+};
+
+struct base_
+{
+protected:
+ base_(int) {}
+ base_(const base_&) {}
+};
+
+struct derived : base, base_
+{
+ derived() : base(), base_(0) {}
+};
+
+
+int main()
+{
+ using namespace mln;
+
+ metal::converts_to<int, float>::check();
+
+ metal::converts_to<from_1, dest>::check();
+ metal::converts_to<from_2, dest>::check();
+
+ metal::converts_to<derived*, base*>::check();
+ metal::converts_to<derived, base>::check();
+ metal::converts_to<derived, const base>::check();
+
+// metal::converts_to<derived, base_>::check_not();
+// metal::converts_to<derived, const base_>::check_not();
+}
Index: tests/metal_is.cc
--- tests/metal_is.cc (revision 0)
+++ tests/metal_is.cc (revision 0)
@@ -0,0 +1,82 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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.
+
+/*! \file tests/metal_is.cc
+ *
+ * \brief Test on mln::metal::is.
+ */
+
+#include <mln/metal/is.hh>
+
+
+
+struct from_1
+{
+};
+
+struct dest
+{
+ dest(const from_1&) {}
+};
+
+struct from_2
+{
+ operator dest() const { dest* tmp; return *tmp; }
+};
+
+
+struct base
+{
+protected: base() {}
+};
+
+struct derived : base
+{
+};
+
+
+struct only
+{
+};
+
+
+int main()
+{
+ using namespace mln;
+
+ metal::is<only, only>::check();
+
+ metal::is<derived, base>::check();
+ metal::is<derived, const base>::check();
+ metal::is<derived*, const base*>::check();
+ metal::is<derived&, base&>::check();
+ metal::is<derived&, const base&>::check();
+
+ metal::is<int, float>::check_not();
+ metal::is<from_1, dest>::check_not();
+ metal::is<from_2, dest>::check_not();
+}
Index: tests/image_if.cc
--- tests/image_if.cc (revision 1201)
+++ tests/image_if.cc (working copy)
@@ -56,7 +56,7 @@
}
{
II ima_;
- init(ima_, ima_ref);
+ initialize(ima_, ima_ref);
debug::println(ima_);
}
}
Index: tests/level_paste.cc
--- tests/level_paste.cc (revision 1201)
+++ tests/level_paste.cc (working copy)
@@ -53,6 +53,8 @@
debug::iota(ima2);
debug::println(ima2);
+ trace::quiet = false;
+
level::paste(ima, ima2); // Fast version.
debug::println(ima2);
Index: tests/trait_images.cc
--- tests/trait_images.cc (revision 1201)
+++ tests/trait_images.cc (working copy)
@@ -31,7 +31,10 @@
*/
#include <mln/core/image2d_b.hh>
+
#include <mln/core/sub_image.hh>
+#include <mln/core/image_if.hh>
+#include <mln/fun/p2b/chess.hh>
int main()
@@ -46,4 +49,8 @@
std::cout << std::endl
<< "sub_image< image2d_b >: ";
mln::trait::print< sub_image<I, box2d> >(std::cout);
+
+ std::cout << std::endl
+ << "image_if< image2d_b >: ";
+ mln::trait::print< image_if<I, fun::p2b::chess_t> >(std::cout);
}
Index: tests/metal_unconst.cc
--- tests/metal_unconst.cc (revision 0)
+++ tests/metal_unconst.cc (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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.
+
+/*! \file tests/metal_unconst.cc
+ *
+ * \brief Test on mln::metal::unconst.
+ */
+
+#include <typeinfo>
+#include <string>
+
+#include <mln/metal/unconst.hh>
+#include <mln/core/exact.hh>
+
+
+
+int main()
+{
+ using namespace mln;
+
+ {
+ mlc_unconst_(int) var; // int
+ var = 0;
+ // void* v = var;
+ }
+ {
+ mlc_unconst_(const int) var; // int
+ var = 0;
+ // void* v = var;
+ }
+
+ {
+ mlc_unconst_(int*) var; // int*
+ var = 0;
+ // void v = var;
+ }
+ {
+ mlc_unconst_(const int*) var; // const int*
+ var = 0;
+ // void v = var;
+ }
+ {
+ mlc_unconst_(int *const) var; // int*
+ var = 0;
+ // void v = var;
+ }
+ {
+ mlc_unconst_(const int *const) var; // const int*
+ var = 0;
+ // void v = var;
+ }
+
+
+ {
+ int tmp = 0;
+ mlc_unconst_(int&) var = tmp; // int&
+ tmp = 51;
+ mln_assertion(var = 51);
+ // void* v = var;
+ }
+ {
+ int tmp = 0;
+ mlc_unconst_(const int&) var = tmp; // int&
+ tmp = 51;
+ mln_assertion(var = 51);
+ // void* v = var;
+ }
+
+}
Index: tests/canvas_browsing_fwd.cc
--- tests/canvas_browsing_fwd.cc (revision 0)
+++ tests/canvas_browsing_fwd.cc (revision 0)
@@ -0,0 +1,100 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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.
+
+/*! \file tests/canvas_browsing_fwd.cc
+ *
+ * \brief Tests on mln::canvas::browsing::fwd.
+ */
+
+#include <mln/core/image2d_b.hh>
+#include <mln/canvas/browsing/fwd.hh>
+#include <mln/canvas/browsing/snake_fwd.hh>
+#include <mln/fun/p2v/iota.hh>
+#include <mln/pw/image.hh>
+#include <mln/debug/println.hh>
+
+
+
+// FIXME: Move code below into mln/canvas/browsing/iota.hh.
+
+
+template <typename I_, typename F>
+struct assign_browsing_functor
+{
+ typedef I_ I;
+
+ I input;
+ F f;
+
+ assign_browsing_functor(I& input, F f = F())
+ : input(input),
+ f(f)
+ {}
+
+ mln_psite(I) p;
+
+ void init() {}
+ void final() {}
+ void next()
+ {
+ input(p) = f(p);
+ }
+ void fwd() { next(); }
+ void bkd() { next(); }
+ void down() { next(); }
+};
+
+namespace mln
+{
+
+ template <typename I, typename F, typename B>
+ void my_test(Image<I>& ima_,
+ const Function_p2v<F>& f_,
+ const Browsing<B>& browse_)
+ {
+ I& ima = exact(ima_);
+ const F& f = exact(f_);
+ const B& browse = exact(browse_);
+
+ assign_browsing_functor<I, F> fun(ima, f);
+ browse(fun);
+ }
+
+}
+
+
+int main()
+{
+ using namespace mln;
+ image2d_b<unsigned> ima(3, 3);
+
+ my_test(ima, fun::p2v::iota, canvas::browsing::fwd);
+ debug::println(ima);
+
+ my_test(ima, fun::p2v::iota, canvas::browsing::snake_fwd);
+ debug::println(ima);
+}
Index: TODO
--- TODO (revision 1201)
+++ TODO (working copy)
@@ -1,6 +1,24 @@
-*- outline -*-
+* URGENT
+
+** accu
+
+*** héritage
+toutes les classes d'accu dérivent de base_ ; Cf. accu/median.hh
+virer l'op de convertion dans median_alt.hh
+ajouter le test de présence de l'op de convertion dans Accumulator
+m-a-j de la doc
+est-ce les tests tournent ?
+
+*** value -> argument
+m-a-j
+tests ?
+
+
+
+
* large changes
introduce grids
Index: mln/trait/images.hh
--- mln/trait/images.hh (revision 1201)
+++ mln/trait/images.hh (working copy)
@@ -31,18 +31,46 @@
/*! \file mln/core/trait/images.hh
*
* \brief Forward declarations of all image types.
+ *
+ * \todo Split this file into many.
*/
# include <iostream>
# include <string>
# include <mln/value/props.hh>
-# include <mln/metal/if.hh>
-# include <mln/metal/bool.hh>
+# include <mln/metal/all.hh>
+
+
+# define mln_trait_image_category(I) typename mln::trait::image_< I >::category
+# define mln_trait_image_kind(I) typename mln::trait::image_< I >::kind
+# define mln_trait_image_quant(I) typename mln::trait::image_< I >::quant
+# define mln_trait_image_value(I) typename mln::trait::image_< I >::value
+# define mln_trait_image_access(I) typename mln::trait::image_< I >::access
+# define mln_trait_image_space(I) typename mln::trait::image_< I >::space
+# define mln_trait_image_size(I) typename mln::trait::image_< I >::size
+# define mln_trait_image_support(I) typename mln::trait::image_< I >::support
+# define mln_trait_image_border(I) typename mln::trait::image_< I >::border
# define mln_trait_image_data(I) typename mln::trait::image_< I >::data
+# define mln_trait_image_io(I) typename mln::trait::image_< I >::io
+# define mln_trait_image_speed(I) typename mln::trait::image_< I >::speed
+
+
+// for io: I const => read_only, otherwise like I
+# define mln_trait_image_io_from_(I) \
+mlc_if( mlc_is_const(I), mln::trait::io::read_only, mln_trait_image_io(I) )
+
+// for data: if raw or linear => stored, otherwise like I (i.e., either stored or
computed)
+#define mln_trait_image_data_from_(I) typename \
+mln::metal::if_< mln::metal::or_< mlc_equal( mln_trait_image_data(I), \
+ mln::trait::data::raw), \
+ mlc_equal( mln_trait_image_data(I), \
+ mln::trait::data::linear) >, \
+ mln::trait::data::stored, \
+ mln_trait_image_data(I) >::ret
namespace mln
@@ -76,21 +104,25 @@
template <typename I>
struct undefined_image_
{
+ typedef undef category; // primary, domain_morpher, value_morpher,
+ // or identity_morpher < morpher
+
// related to I::value
- typedef undef kind; // color, gray, binary < label, data
+ typedef undef kind; // color, gray, binary < logic < label, data
typedef undef quant; // low or high
- typedef undef value; // scalar, vectorial, structed
+ typedef undef value; // scalar, vectorial, structed, pointer
+ // FIXME: Make the difference between homogeneous and heterogeneous vectors...
// related to I::pset
- typedef undef access; // random, browse
+ typedef undef access; // random, browsing
typedef undef space; // one_d, two_d, three_d
typedef undef size; // huge or regular
typedef undef support; // irregular, aligned < regular
// global
typedef undef border; // none, stored, computed
- typedef undef data; // linear < stored, computed
- typedef undef io; // read_only < read_write
+ typedef undef data; // raw < linear < stored, computed
+ typedef undef io; // read_only < read, write_only < write, read_write
< both read'n write
typedef undef speed; // slow, fast, or fastest
};
@@ -101,133 +133,171 @@
};
- template <typename I>
- void print(std::ostream& ostr)
- {
- typedef image_<I> the;
- ostr << "{ "
- << the::data().str() << ", "
- << the::kind().str() << ", "
- << the::quant().str() << ", "
- << the::value().str() << ", "
- << the::access().str() << ", "
- << the::space().str() << ", "
- << the::size().str() << ", "
- << the::support().str() << ", "
- << the::border().str() << ", "
- << the::io().str() << ", "
- << the::speed().str() << " }" << std::endl;
- }
+ struct category
+ {
+ struct any {};
+ struct primary : any { std::string str() const { return
"category::primary"; } };
+ struct morpher : any {};
+ struct domain_morpher
+ : morpher { std::string str() const { return "category::domain_morpher"; } };
+ struct value_morpher
+ : morpher { std::string str() const { return "category::value_morpher"; } };
+ struct identity_morpher
+ : morpher { std::string str() const { return "category::identity_morpher"; }
};
+ };
struct data
{
- struct computed { std::string str() const { return
"data::computed"; } };
- struct stored { std::string str() const { return "data::stored";
} };
- struct linear : stored { std::string str() const { return "data::linear";
} };
+ struct any {};
+ struct computed : any { std::string str() const { return
"data::computed"; } };
+ struct stored : any { std::string str() const { return "data::stored";
} };
+ struct linear
+ : stored { std::string str() const { return "data::linear"; } };
+ struct raw
+ : linear { std::string str() const { return "data::raw"; } };
};
struct quant
{
- struct low { std::string str() const { return "quant::low"; } };
- struct high { std::string str() const { return "quant::high"; } };
+ struct any {};
+ struct low : any { std::string str() const { return "quant::low"; } };
+ struct high : any { std::string str() const { return "quant::high"; } };
};
struct value
{
- struct scalar { std::string str() const { return "value::scalar"; }
};
- struct vectorial { std::string str() const { return "value::vectorial"; }
};
- struct structed { std::string str() const { return "value::structed"; }
};
+ struct any {};
+ struct scalar : any { std::string str() const { return
"value::scalar"; } };
+ struct vectorial : any { std::string str() const { return
"value::vectorial"; } };
+ struct structed : any { std::string str() const { return
"value::structed"; } };
+ struct pointer : any { std::string str() const { return
"value::pointer"; } };
};
struct access
{
- struct random { std::string str() const { return "access::random"; }
};
- struct iterative { std::string str() const { return "access::iterative";
} };
+ struct any {};
+ struct random : any { std::string str() const { return
"access::random"; } };
+ struct browsing : any { std::string str() const { return
"access::browsing"; } };
};
struct space
{
- struct one_d { std::string str() const { return "space::one_d"; } };
- struct two_d { std::string str() const { return "space::two_d"; } };
- struct three_d { std::string str() const { return "space::three_d"; } };
+ struct any {};
+ struct one_d : any { std::string str() const { return "space::one_d";
} };
+ struct two_d : any { std::string str() const { return "space::two_d";
} };
+ struct three_d : any { std::string str() const { return
"space::three_d"; } };
+
+ struct fixme // So FIXME!
+ : any { std::string str() const { return "space::fixme"; } };
};
struct size
{
- struct huge { std::string str() const { return "size::huge"; } };
- struct regular { std::string str() const { return "size::regular"; } };
+ struct any {};
+ struct huge : any { std::string str() const { return "size::huge"; }
};
+ struct regular : any { std::string str() const { return "size::regular";
} };
};
struct support
{
- struct irregular { std::string str() const { return
"support::irregular"; } };
- struct regular { std::string str() const { return
"support::regular"; } };
- struct aligned : regular { std::string str() const { return
"support::aligned"; } };
+ struct any {};
+ struct irregular : any { std::string str() const { return
"support::irregular"; } };
+ struct regular : any { std::string str() const { return
"support::regular"; } };
+ struct aligned
+ : regular { std::string str() const { return "support::aligned"; } };
+
+ struct fixme // So FIXME!
+ : any { std::string str() const { return "support::fixme"; } };
};
struct border
{
- struct none { std::string str() const { return "border::none"; } };
- struct stored { std::string str() const { return "border::stored"; }
};
- struct computed { std::string str() const { return "border::computed"; }
};
+ struct any {};
+ struct none : any { std::string str() const { return "border::none";
} };
+ struct stored : any { std::string str() const { return
"border::stored"; } };
+ struct computed : any { std::string str() const { return
"border::computed"; } };
};
struct io
{
- struct read_only { std::string str() const { return "io::read_only"; }
};
- struct read_write { std::string str() const { return "io::read_write"; }
};
+ struct any {};
+ struct read : virtual any {};
+ struct write : virtual any {};
+ struct read_only
+ : read { std::string str() const { return "io::read_only"; } };
+ struct write_only
+ : write { std::string str() const { return "io::write_only"; } };
+ struct read_write
+ : read, write { std::string str() const { return "io::read_write"; } };
};
struct speed
{
- struct slow { std::string str() const { return "speed::slow"; } };
- struct fast { std::string str() const { return "speed::fast"; } };
- struct fastest { std::string str() const { return "speed::fastest"; } };
+ struct any {};
+ struct slow : any { std::string str() const { return "speed::slow"; } };
+ struct fast : any { std::string str() const { return "speed::fast"; } };
+ struct fastest
+ : fast { std::string str() const { return "speed::fastest"; } };
};
-
template <typename I>
+ void print(std::ostream& ostr)
+ {
+ typedef image_<I> the;
+ ostr << "{ "
+ << typename the::category().str() << ", "
+ << typename the::data().str() << ", "
+ << typename the::kind().str() << ", "
+ << typename the::quant().str() << ", "
+ << typename the::value().str() << ", "
+ << typename the::access().str() << ", "
+ << typename the::space().str() << ", "
+ << typename the::size().str() << ", "
+ << typename the::support().str() << ", "
+ << typename the::border().str() << ", "
+ << typename the::io().str() << ", "
+ << typename the::speed().str() << " }" << std::endl;
+ }
+
+
+
+ template <typename T, typename I>
struct default_image_ : undefined_image_<I>
{
private:
- typedef mln_value(I) T_;
- typedef metal::bool_<( mln_value_card_(T_) != 0 )> is_high_quant_;
+ typedef metal::bool_<( mln_value_card_(T) = 0 )> is_high_quant_;
public:
- typedef mln_value_kind(T_) kind;
+ typedef mln_value_kind(T) kind;
typedef mlc_if( is_high_quant_, trait::quant::high, trait::quant::low ) quant;
// FIXME: typedef undef value; // scalar, vectorial, structed
+
+ // speed is fast by default (neither "fastest" nor "slow")
+ typedef trait::speed::fast speed;
};
- template <typename I>
- struct default_image_morpher_ : default_image_<I>
+ template <typename D, typename T, typename I>
+ struct default_image_morpher_ : default_image_<T, I>
{
- private:
- typedef typename I::delegatee D_;
- public:
-
// value-related => delegation
- typedef typename image_<D_>::kind kind;
- typedef typename image_<D_>::quant quant;
- typedef typename image_<D_>::value value;
+ typedef typename image_<D>::kind kind;
+ typedef typename image_<D>::quant quant;
+ typedef typename image_<D>::value value;
// domain-related => delegation
- typedef typename image_<D_>::access access;
- typedef typename image_<D_>::space space;
- typedef typename image_<D_>::size size;
- typedef typename image_<D_>::support support;
+ typedef typename image_<D>::access access;
+ typedef typename image_<D>::space space;
+ typedef typename image_<D>::size size;
+ typedef typename image_<D>::support support;
// mostly global-related => delegation
- typedef typename image_<D_>::border border;
- typedef typename image_<D_>::data data;
- typedef typename image_<D_>::io io;
-
- // *but* speed is fast by default (not fastest!)
- typedef trait::speed::fast speed;
+ typedef typename image_<D>::border border;
+ typedef typename image_<D>::data data;
+ typedef typename image_<D>::io io;
};
Index: mln/core/macros.hh
--- mln/core/macros.hh (revision 1201)
+++ mln/core/macros.hh (working copy)
@@ -149,6 +149,7 @@
/// Shortcut to access the result type associated to T.
# define mln_result(T) typename T::result
+# define mln_result_(T) T::result
/// Shortcut to access the rvalue type associated to T.
# define mln_rvalue(T) typename T::rvalue
Index: mln/core/image_if.hh
--- mln/core/image_if.hh (revision 1201)
+++ mln/core/image_if.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/core/internal/image_domain_morpher.hh>
# include <mln/core/pset_if.hh>
# include <mln/pw/all.hh>
+# include <mln/value/interval.hh>
namespace mln
@@ -60,7 +61,36 @@
} // end of namespace mln::internal
- /*! \brief A base class for image adaptors.
+
+ namespace trait
+ {
+
+ template <typename I, typename F>
+ struct image_< image_if<I,F> > : default_image_morpher_< I,
mln_value(I),
+ image_if<I,F> >
+ {
+ private:
+ typedef mln_trait_image_data(I) I_data_;
+ typedef mlc_equal(I_data_, trait::data::linear) I_data_are_linear_;
+ public:
+
+ typedef trait::category::domain_morpher category;
+
+ typedef mlc_if( mlc_is_const(I),
+ trait::io::read_only, // I const => read_only
+ mln_trait_image_io(I) ) io; // otherwise like I
+
+ typedef mlc_if( I_data_are_linear_,
+ trait::data::stored, // if linear then just stored
+ I_data_ ) data; // otherwise like I
+ };
+
+ } // end of namespace mln::trait
+
+
+
+
+ /*! \brief An image class FIXME.
*
*/
template <typename I, typename F>
@@ -95,8 +125,11 @@
+
// Operators.
+ // Image | Function_p2b.
+
template <typename I, typename F>
image_if<I, F>
operator | (Image<I>& ima, const Function_p2b<F>& f);
@@ -105,20 +138,37 @@
image_if<const I, F>
operator | (const Image<I>& ima, const Function_p2b<F>& f);
+ // Image | value.
+
template <typename I>
image_if< I,
- fun::equal_p2b_expr_< pw::value_<I>,
+ fun::eq_p2b_expr_< pw::value_<I>,
pw::cst_<mln_value(I)> > >
operator | (Image<I>& ima, const mln_value(I)& v);
template <typename I>
image_if< const I,
- fun::equal_p2b_expr_< pw::value_<I>,
+ fun::eq_p2b_expr_< pw::value_<I>,
pw::cst_<mln_value(I)> > >
operator | (const Image<I>& ima, const mln_value(I)& v);
- // FIXME: Add the notion of "interval of values"...
- // FIXME: so we can write: ima | from_to(v1, v2)
+ // Image | [from, to].
+
+ template <typename I>
+ image_if< I,
+ fun::and_p2b_expr_< fun::geq_p2b_expr_< pw::value_<I>,
+ pw::cst_<mln_value(I)> >,
+ fun::leq_p2b_expr_< pw::value_<I>,
+ pw::cst_<mln_value(I)> > > >
+ operator | (Image<I>& ima, const value::interval_<mln_value(I)>&
vv);
+
+ template <typename I>
+ image_if< const I,
+ fun::and_p2b_expr_< fun::geq_p2b_expr_< pw::value_<I>,
+ pw::cst_<mln_value(I)> >,
+ fun::leq_p2b_expr_< pw::value_<I>,
+ pw::cst_<mln_value(I)> > > >
+ operator | (const Image<I>& ima, const
value::interval_<mln_value(I)>& vv);
@@ -239,7 +289,7 @@
template <typename I>
image_if< I,
- fun::equal_p2b_expr_< pw::value_<I>,
+ fun::eq_p2b_expr_< pw::value_<I>,
pw::cst_<mln_value(I)> > >
operator | (Image<I>& ima, const mln_value(I)& v)
{
@@ -248,13 +298,37 @@
template <typename I>
image_if< const I,
- fun::equal_p2b_expr_< pw::value_<I>,
+ fun::eq_p2b_expr_< pw::value_<I>,
pw::cst_<mln_value(I)> > >
operator | (const Image<I>& ima, const mln_value(I)& v)
{
return ima | (pw::value(ima) = pw::cst(v));
}
+ template <typename I>
+ image_if< I,
+ fun::and_p2b_expr_< fun::geq_p2b_expr_< pw::value_<I>,
+ pw::cst_<mln_value(I)> >,
+ fun::leq_p2b_expr_< pw::value_<I>,
+ pw::cst_<mln_value(I)> > > >
+ operator | (Image<I>& ima, const value::interval_<mln_value(I)>&
vv)
+ {
+ return ima | ( (pw::value(ima) >= pw::cst(vv.from)) &&
+ (pw::value(ima) <= pw::cst(vv.to)) );
+ }
+
+ template <typename I>
+ image_if< const I,
+ fun::and_p2b_expr_< fun::geq_p2b_expr_< pw::value_<I>,
+ pw::cst_<mln_value(I)> >,
+ fun::leq_p2b_expr_< pw::value_<I>,
+ pw::cst_<mln_value(I)> > > >
+ operator | (const Image<I>& ima, const
value::interval_<mln_value(I)>& vv)
+ {
+ return ima | ( (pw::value(ima) >= pw::cst(vv.from)) &&
+ (pw::value(ima) <= pw::cst(vv.to)) );
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/exact.hh
--- mln/core/exact.hh (revision 1201)
+++ mln/core/exact.hh (working copy)
@@ -32,7 +32,7 @@
* \brief Definition of the mln::exact downcast routines.
*/
-# include <mln/core/concept/object.hh>
+# include <mln/core/internal/exact.hh>
namespace mln
@@ -51,49 +51,33 @@
*/
/// \{
- template <typename E>
- E* exact(Object<E>* ptr);
-
- template <typename E>
- const E* exact(const Object<E>* ptr);
-
- template <typename E>
- E& exact(Object<E>& ref);
-
- template <typename E>
- const E& exact(const Object<E>& ref);
+ template <typename T>
+ typename internal::exact_<T>::ret*
+ exact(T* ptr);
+
+ template <typename T>
+ typename internal::exact_<T>::ret&
+ exact(T& ref);
/// \}
-
-
# ifndef MLN_INCLUDE_ONLY
// exact
- template <typename E>
- E* exact(Object<E>* ptr)
- {
- return (E*)(void*)ptr;
- }
-
- template <typename E>
- const E* exact(const Object<E>* ptr)
- {
- return (const E*)(const void*)ptr;
- }
-
- template <typename E>
- E& exact(Object<E>& ref)
+ template <typename T>
+ typename internal::exact_<T>::ret*
+ exact(T* ptr)
{
- return *(E*)(void*)(&ref);
+ return internal::exact_<T>::run(ptr);
}
- template <typename E>
- const E& exact(const Object<E>& ref)
+ template <typename T>
+ typename internal::exact_<T>::ret&
+ exact(T& ref)
{
- return *(const E*)(const void*)(&ref);
+ return *exact(&ref);
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/internal/exact.hh
--- mln/core/internal/exact.hh (revision 0)
+++ mln/core/internal/exact.hh (revision 0)
@@ -0,0 +1,124 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_INTERNAL_EXACT_HH
+# define MLN_CORE_INTERNAL_EXACT_HH
+
+/*! \file mln/core/internal/exact.hh
+ * \brief Meta-code for the mln::exact downcast routines.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+ namespace internal
+ {
+
+ typedef char yes_;
+ struct no_ { char dummy[2]; };
+
+ template <typename T>
+ struct make_
+ {
+ static T* ptr();
+ };
+
+ template <unsigned id, typename T>
+ struct exact_ret_;
+
+ template <typename T>
+ struct exact_ret_< 1, T >
+ {
+ typedef typename T::exact_t ret;
+ };
+
+ template <typename T>
+ struct exact_ret_< 2, T >
+ {
+ typedef T ret;
+ };
+
+ template <typename E, typename T>
+ yes_ exact_selector_(Object<E>*, T*);
+
+ template <typename T>
+ no_ exact_selector_(void*, T* t);
+
+ template <typename E, typename T>
+ E* exact_run_(Object<E>* t, T*);
+
+ template <typename T>
+ T* exact_run_(void*, T* t);
+
+ template <typename T>
+ struct exact_
+ {
+ enum { id = sizeof(exact_selector_(make_<T>::ptr(),make_<T>::ptr()))
};
+ typedef typename exact_ret_<id, T>::ret ret;
+ static ret* run(T* t)
+ {
+ return exact_run_(t, t);
+ }
+ };
+
+ template <typename T>
+ struct exact_<const T>
+ {
+ enum { id = sizeof(exact_selector_(make_<T>::ptr(),make_<T>::ptr()))
};
+ typedef const typename exact_ret_<id, T>::ret ret;
+ static ret* run(const T* t)
+ {
+ return exact_run_((T*)t, (T*)t);
+ }
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E, typename T>
+ E* exact_run_(Object<E>* t, T*)
+ {
+ return (E*)(void*)t;
+ }
+
+ template <typename T>
+ T* exact_run_(void*, T* t)
+ {
+ return t;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::internal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INTERNAL_EXACT_HH
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 1201)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -35,6 +35,7 @@
# include <mln/core/internal/image_base.hh>
# include <mln/metal/const.hh>
+# include <mln/metal/is_const.hh>
namespace mln
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1201)
+++ mln/core/image2d_b.hh (working copy)
@@ -80,6 +80,28 @@
} // end of namespace mln::internal
+ namespace trait
+ {
+
+ template <typename T>
+ struct image_< image2d_b<T> > : default_image_< T, image2d_b<T>
>
+ {
+ typedef trait::category::primary category;
+
+ typedef trait::access::random access;
+ typedef trait::space::two_d space;
+ typedef trait::size::regular size;
+ typedef trait::support::aligned support;
+
+ typedef trait::border::stored border;
+ typedef trait::data::raw data;
+ typedef trait::io::read_write io;
+ typedef trait::speed::fastest speed;
+ };
+
+ } // end of namespace mln::trait
+
+
namespace trait
{
@@ -208,25 +230,6 @@
void init_(tag::image_t, mln::image2d_b<T>& target, const J& model);
- namespace trait
- {
-
- template <typename T>
- struct image_< image2d_b<T> > : default_image_< image2d_b<T>
>
- {
- typedef trait::access::random access;
- typedef trait::space::two_d space;
- typedef trait::size::regular size;
- typedef trait::support::aligned support;
-
- typedef trait::border::stored border;
- typedef trait::data::linear data;
- typedef trait::io::read_write io;
- typedef trait::speed::fastest speed;
- };
-
- } // end of namespace mln::trait
-
# ifndef MLN_INCLUDE_ONLY
Index: mln/core/ops.hh
--- mln/core/ops.hh (revision 1201)
+++ mln/core/ops.hh (working copy)
@@ -30,6 +30,8 @@
/*! \file mln/core/ops.hh
* \brief Definitions of some operators.
+ *
+ * \todo Traits are in mln/trait/ not in mln/metal/!
*/
# include <mln/core/concept/object.hh>
Index: mln/core/sub_image.hh
--- mln/core/sub_image.hh (revision 1201)
+++ mln/core/sub_image.hh (working copy)
@@ -55,6 +55,33 @@
+ namespace trait
+ {
+
+ template <typename I, typename S>
+ struct image_< sub_image<I,S> > : default_image_morpher_< I,
mln_value(I),
+ sub_image<I,S> >
+ {
+// private:
+// typedef mln_trait_image_data(I) I_data_;
+// typedef mlc_equal(I_data_, trait::data::linear) I_data_are_linear_;
+// public:
+
+ typedef trait::category::domain_morpher category;
+
+ typedef trait::border::none border; // no more accessible border
+
+ typedef mln_trait_image_io_from_(I) io; // un-write when I const
+
+ typedef mln_trait_image_data_from_(I) data;
+// typedef mlc_if( I_data_are_linear_,
+// trait::data::stored, // if linear then just stored
+// I_data_ ) data; // otherwise like I
+ };
+
+ } // end of namespace mln::trait
+
+
// FIXME: Doc!
@@ -95,26 +122,6 @@
void init_(tag::image_t, sub_image<I,S>& target, const J& model);
- namespace trait
- {
-
- template <typename I, typename S>
- struct image_< sub_image<I,S> > : default_image_morpher_<
sub_image<I,S> >
- {
- private:
- typedef mln_trait_image_data(I) I_data_;
- typedef mlc_equal(I_data_, trait::data::linear) I_data_are_linear_;
- public:
-
- typedef trait::border::none border; // no more accessible border
-
- typedef mlc_if( I_data_are_linear_,
- trait::data::stored, // if linear then just stored
- I_data_ ) data; // otherwise like I
- };
-
- } // end of namespace mln::trait
-
# ifndef MLN_INCLUDE_ONLY
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 1201)
+++ mln/core/concept/image.hh (working copy)
@@ -110,7 +110,7 @@
* \pre (not target.has_data) and model.has_data
*/
template <typename I, typename J>
- void init(Image<I>& target, const Image<J>& model);
+ void initialize(Image<I>& target, const Image<J>& model);
@@ -165,7 +165,7 @@
}
template <typename I, typename J>
- void init(Image<I>& target, const Image<J>& model)
+ void initialize(Image<I>& target, const Image<J>& model)
{
mln_precondition(! exact(target).has_data());
mln_precondition(exact(model).has_data());
Index: mln/core/concept/browsing.hh
--- mln/core/concept/browsing.hh (revision 0)
+++ mln/core/concept/browsing.hh (revision 0)
@@ -0,0 +1,79 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_BROWSING_HH
+# define MLN_CORE_CONCEPT_BROWSING_HH
+
+/*! \file mln/core/concept/browsing.hh
+ * \brief Definition of the concept of mln::Browsing.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+ /*! \brief Base class for implementation classes that are browsings.
+ *
+ * \see mln::doc::Browsing for a complete documentation of this
+ * class contents.
+ */
+ template <typename E>
+ struct Browsing : public Object<E>
+ {
+ void init();
+ void final();
+
+ protected:
+ Browsing();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename E>
+ Browsing<E>::Browsing()
+ {
+ }
+
+ template <typename E>
+ void Browsing<E>::init()
+ {
+ }
+
+ template <typename E>
+ void Browsing<E>::final()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_CONCEPT_BROWSING_HH
Index: mln/core/concept/object.hh
--- mln/core/concept/object.hh (revision 1201)
+++ mln/core/concept/object.hh (working copy)
@@ -39,12 +39,15 @@
# include <mln/core/macros.hh>
# include <mln/core/contract.hh>
# include <mln/core/internal/fixme.hh>
+# include <mln/trace/all.hh>
# include <mln/metal/is_a.hh>
/*! \namespace mln
* \brief The namespace mln corresponds to the Milena (mini-Olena) project.
*
+ * FIXME: Re-write this description.
+ *
* The contents of mln mimics the contents of the olena project but
* in a simplified way. Some classes have the same name in both
* projects and roughly have the same behavior.
@@ -63,6 +66,7 @@
template <typename E>
struct Object
{
+ typedef E exact_t;
protected:
Object();
};
@@ -81,8 +85,8 @@
# include <mln/core/exact.hh>
-# include <mln/core/ops.hh>
-# include <mln/trait/ch_value.hh>
+# include <mln/metal/all.hh>
+# include <mln/core/ops.hh> // FIXME: Read FIXME in
mln/metal/binary_arith_trait.hh!
#endif // ! MLN_CORE_CONCEPT_OBJECT_HH
Index: mln/core/concept/accumulator.hh
--- mln/core/concept/accumulator.hh (revision 1201)
+++ mln/core/concept/accumulator.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Definition of the concept of mln::Accumulator.
*
- * \todo Rename value as argument.
+ * \todo Rename value as argument + Add a conversion op.
*/
# include <mln/core/concept/object.hh>
Index: mln/core/clone.hh
--- mln/core/clone.hh (revision 1201)
+++ mln/core/clone.hh (working copy)
@@ -59,7 +59,7 @@
{
// FIXME: Add a static check that mln_concrete(I) actually *is* concrete...
mln_concrete(I) tmp;
- init(tmp, model);
+ initialize(tmp, model);
level::fill(tmp, model);
return tmp;
}
Index: mln/core/image1d_b.hh
--- mln/core/image1d_b.hh (revision 1201)
+++ mln/core/image1d_b.hh (working copy)
@@ -94,6 +94,29 @@
+ namespace trait
+ {
+
+ template <typename T>
+ struct image_< image1d_b<T> > : default_image_< T, image1d_b<T>
>
+ {
+ typedef trait::category::primary category;
+
+ typedef trait::access::random access;
+ typedef trait::space::one_d space;
+ typedef trait::size::regular size;
+ typedef trait::support::aligned support;
+
+ typedef trait::border::stored border;
+ typedef trait::data::raw data;
+ typedef trait::io::read_write io;
+ typedef trait::speed::fastest speed;
+ };
+
+ } // end of namespace mln::trait
+
+
+
/*! \brief Basic 1D image class.
*
* The parameter \c T is the type of pixel values. This image class
Index: mln/core/image3d_b.hh
--- mln/core/image3d_b.hh (revision 1201)
+++ mln/core/image3d_b.hh (working copy)
@@ -93,6 +93,29 @@
+ namespace trait
+ {
+
+ template <typename T>
+ struct image_< image3d_b<T> > : default_image_< T, image3d_b<T>
>
+ {
+ typedef trait::category::primary category;
+
+ typedef trait::access::random access;
+ typedef trait::space::three_d space;
+ typedef trait::size::regular size;
+ typedef trait::support::aligned support;
+
+ typedef trait::border::stored border;
+ typedef trait::data::raw data;
+ typedef trait::io::read_write io;
+ typedef trait::speed::fastest speed;
+ };
+
+ } // end of namespace mln::trait
+
+
+
/*! \brief Basic 3D image class.
*
* The parameter \c T is the type of pixel values. This image class
Index: mln/metal/is_const.hh
--- mln/metal/is_const.hh (revision 0)
+++ mln/metal/is_const.hh (revision 0)
@@ -0,0 +1,62 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_METAL_IS_CONST_HH
+# define MLN_METAL_IS_CONST_HH
+
+# include <mln/metal/bool.hh>
+
+
+# define mlc_is_const(T) mln::metal::is_const< T >
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct is_const : false_
+ {};
+
+ template <typename T>
+ struct is_const< const T > : true_
+ {};
+
+ template <typename T>
+ struct is_const< const T& > : true_
+ {};
+
+ // FIXME: What about "T*const" and "const T*"?
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_IS_CONST_HH
Index: mln/metal/unqualif.hh
--- mln/metal/unqualif.hh (revision 1201)
+++ mln/metal/unqualif.hh (working copy)
@@ -34,6 +34,7 @@
# define mlc_unqualif(T) typename mln::metal::unqualif< T >::ret
+# define mlc_unqualif_(T) mln::metal::unqualif< T >::ret
namespace mln
@@ -42,6 +43,8 @@
namespace metal
{
+ // FIXME: May be recursive!
+
template <typename T>
struct unqualif
{
Index: mln/metal/unconst.hh
--- mln/metal/unconst.hh (revision 1201)
+++ mln/metal/unconst.hh (working copy)
@@ -30,6 +30,7 @@
# define mlc_unconst(T) typename mln::metal::unconst< T >::ret
+# define mlc_unconst_(T) mln::metal::unconst< T >::ret
namespace mln
@@ -38,6 +39,8 @@
namespace metal
{
+ // FIXME: What about "const T *const"?
+
template <typename T>
struct unconst
{
@@ -50,6 +53,12 @@
typedef T ret;
};
+ template <typename T>
+ struct unconst< const T& >
+ {
+ typedef T& ret;
+ };
+
} // end of namespace mln::metal
} // end of namespace mln
Index: mln/metal/bool.hh
--- mln/metal/bool.hh (revision 1201)
+++ mln/metal/bool.hh (working copy)
@@ -40,32 +40,44 @@
namespace metal
{
- // Fwd decls.
- struct true_;
- struct false_;
-
-
-
- // FIXME: Doc!
-
+ // Fwd decl.
template <bool b> struct bool_;
+ /// "true" type.
template <>
struct bool_< true >
{
- typedef true_ type;
static const bool value = true;
- enum { to_bool = true };
+ typedef bool_<true> eval;
+ static void check();
};
+ typedef bool_<true> true_;
+
+
+ /// "false" type.
template <>
struct bool_< false >
{
- typedef false_ type;
static const bool value = false;
- enum { to_bool = false };
+ typedef bool_<false> eval;
+ static void check_not();
};
+ typedef bool_<false> false_;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ void true_::check()
+ {
+ }
+
+ void false_::check_not()
+ {
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::metal
Index: mln/metal/if.hh
--- mln/metal/if.hh (revision 1201)
+++ mln/metal/if.hh (working copy)
@@ -71,7 +71,7 @@
* FIXME: Doc!
*/
template <typename Cond, typename Then, typename Else>
- struct if_ : internal::helper_if_< Cond::to_bool, Then, Else >
+ struct if_ : internal::helper_if_< Cond::value, Then, Else >
{
// ret is inherited.
};
Index: mln/metal/goes_to.hh
--- mln/metal/goes_to.hh (revision 0)
+++ mln/metal/goes_to.hh (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_METAL_GOES_TO_HH
+# define MLN_CORE_METAL_GOES_TO_HH
+
+/*! \file mln/metal/goes_to.hh
+ *
+ * \brief Definition of a type that means "goes to".
+ */
+
+# include <mln/metal/converts_to.hh>
+# include <mln/metal/is.hh>
+
+
+# define mlc_goes_to(T, U) mln::metal::goes_to< T, U >
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ /*! \brief "goes-to" check.
+ *
+ * FIXME: Doc!
+ */
+ template <typename T, typename U>
+ struct goes_to : or_< mlc_converts_to(T,U), mlc_is(T,U) >::eval
+ {};
+
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_METAL_GOES_TO_HH
Index: mln/metal/converts_to.hh
--- mln/metal/converts_to.hh (revision 0)
+++ mln/metal/converts_to.hh (revision 0)
@@ -0,0 +1,79 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_METAL_CONVERTS_TO_HH
+# define MLN_CORE_METAL_CONVERTS_TO_HH
+
+/*! \file mln/metal/converts_to.hh
+ *
+ * \brief Definition of a type that means "converts to".
+ */
+
+# include <mln/metal/is_a.hh>
+# include <mln/metal/const.hh>
+
+
+# define mlc_converts_to(T, U) mln::metal::converts_to< T, U >
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ namespace internal
+ {
+
+ template <typename T, typename U>
+ struct helper_converts_to_
+ {
+ static yes_ selector(U);
+ static no_ selector(...);
+ };
+
+ } // end of namespace mln::metal::internal
+
+
+
+ /*! \brief "converts-to" check.
+ *
+ * FIXME: Doc!
+ */
+ template <typename T, typename U>
+ struct converts_to : bool_<( sizeof(internal::helper_converts_to_<T,
U>::selector(*internal::make_<mlc_const(T)>::ptr()) )
+ =
+ sizeof(internal::yes_) )>
+ {};
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_METAL_CONVERTS_TO_HH
Index: mln/metal/all.hh
--- mln/metal/all.hh (revision 1201)
+++ mln/metal/all.hh (working copy)
@@ -42,15 +42,35 @@
} // end of namespace mln
-# include <mln/metal/bexpr.hh> // <- bool.hh
+# include <mln/metal/none.hh>
+
+# include <mln/metal/abort.hh>
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/bool.hh>
# include <mln/metal/equal.hh>
# include <mln/metal/if.hh>
+
+# include <mln/metal/converts_to.hh>
+# include <mln/metal/is.hh>
# include <mln/metal/is_a.hh>
+# include <mln/metal/goes_to.hh>
+
# include <mln/metal/math.hh>
-# include <mln/metal/none.hh>
-# include <mln/metal/unqualif.hh> // <- unconst.hh, unptr.hh, unref.hh
+
+# include <mln/metal/const.hh>
+# include <mln/metal/unconst.hh>
+# include <mln/metal/is_const.hh>
+
+# include <mln/metal/unptr.hh>
+# include <mln/metal/unref.hh>
+
+# include <mln/metal/unqualif.hh>
+# include <mln/metal/is_unqualif.hh>
+
# include <mln/metal/vec.hh>
+# include <mln/metal/mat.hh>
+// FIXME: Remove the following includes below!
# include <mln/metal/same_coord.hh>
# include <mln/metal/same_point.hh>
Index: mln/metal/is_a.hh
--- mln/metal/is_a.hh (revision 1201)
+++ mln/metal/is_a.hh (working copy)
@@ -78,7 +78,7 @@
template <typename T, template <class> class U>
struct is_a : bool_<( sizeof( internal::helper_is_a_< T, U
>::selector(internal::make_< T >::ptr()) )
=
- sizeof( internal::yes_ ) )>::type
+ sizeof( internal::yes_ ) )>
{};
Index: mln/metal/is.hh
--- mln/metal/is.hh (revision 0)
+++ mln/metal/is.hh (revision 0)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_METAL_IS_HH
+# define MLN_CORE_METAL_IS_HH
+
+/*! \file mln/metal/is.hh
+ *
+ * \brief Definition of a type that means "converts to".
+ */
+
+# include <mln/metal/is_a.hh>
+
+
+# define mlc_is(T, U) mln::metal::is< T, U >
+
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ namespace internal
+ {
+
+ template <typename T, typename U>
+ struct helper_is_
+ {
+ static yes_ selector(U&);
+ static no_ selector(...);
+ };
+
+ } // end of namespace mln::metal::internal
+
+
+
+ /*! \brief "is" check.
+ *
+ * FIXME: Doc!
+ */
+ template <typename T, typename U>
+ struct is : bool_<( sizeof(internal::helper_is_<T,
U>::selector(*internal::make_<T>::ptr()))
+ =
+ sizeof(internal::yes_) )>
+ {};
+
+ template <typename T, typename U>
+ struct is< T*, U* > : is<T, U>::eval
+ {};
+
+ template <typename T, typename U>
+ struct is< T&, U& > : is<T, U>::eval
+ {};
+
+ template <typename T, typename U>
+ struct is< T**, U** > : false_
+ {};
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_METAL_IS_HH
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1201)
+++ mln/metal/vec.hh (working copy)
@@ -31,7 +31,7 @@
# include <iostream>
# include <cmath>
-# include <mln/core/contract.hh>
+# include <mln/core/concept/object.hh>
# include <mln/metal/binary_arith_trait.hh>
// FIXME: Document.
@@ -43,18 +43,22 @@
namespace metal
{
+ // Fwd decl.
+ template <unsigned n, typename T> class vec;
+
+
namespace internal
{
template <unsigned n, typename T>
- class vec_base_
+ class vec_base_ : public Object< vec<n,T> >
{
protected:
T data_[n];
};
template <typename T>
- class vec_base_ <1, T>
+ class vec_base_ <1, T> : public Object< vec<1,T> >
{
public:
void set(const T& val0)
@@ -66,7 +70,7 @@
};
template <typename T>
- class vec_base_ <2, T>
+ class vec_base_ <2, T> : public Object< vec<2,T> >
{
public:
void set(const T& val0, const T& val1)
@@ -79,7 +83,7 @@
};
template <typename T>
- class vec_base_ <3, T>
+ class vec_base_ <3, T> : public Object< vec<3,T> >
{
public:
void set(const T& val0, const T& val1, const T& val2)
@@ -93,7 +97,7 @@
};
template <typename T>
- class vec_base_ <4, T>
+ class vec_base_ <4, T> : public Object< vec<4,T> >
{
public:
void set(const T& val0, const T& val1, const T& val2, const T& val3)
@@ -115,10 +119,10 @@
template <unsigned n, typename T>
class vec : public internal::vec_base_<n, T>
{
- typedef internal::vec_base_<n, T> super;
+ typedef internal::vec_base_<n, T> super_;
protected:
- using super::data_;
+ using super_::data_;
public:
@@ -222,10 +226,12 @@
vec<3, typename binary_arith_trait<T, U>::ret>
vprod(const vec<3, T>& lhs, const vec<3, U>& rhs);
+
# ifndef MLN_INCLUDE_ONLY
template <unsigned n, typename T>
vec<n,T>::vec(const vec<n,T>& rhs)
+ : super_()
{
for (unsigned i = 0; i < n; ++i)
data_[i] = rhs[i];
@@ -234,6 +240,7 @@
template <unsigned n, typename T>
template <typename U>
vec<n,T>::vec(const vec<n, U>& rhs)
+ : super_()
{
for (unsigned i = 0; i < n; ++i)
data_[i] = rhs[i];
Index: mln/metal/binary_arith_trait.hh
--- mln/metal/binary_arith_trait.hh (revision 1201)
+++ mln/metal/binary_arith_trait.hh (working copy)
@@ -32,6 +32,9 @@
# define mlc_bin_arith(T, U) typename mln::metal::binary_arith_trait< T , U >::ret
+// FIXME: Move in mln/trait/!
+
+
namespace mln
{
Index: mln/metal/is_unqualif.hh
--- mln/metal/is_unqualif.hh (revision 0)
+++ mln/metal/is_unqualif.hh (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_METAL_IS_UNQUALIF_HH
+# define MLN_METAL_IS_UNQUALIF_HH
+
+# include <mln/metal/equal.hh>
+# include <mln/metal/unqualif.hh>
+
+# define mlc_is_unqualif(T) mln::metal::is_unqualif< T >
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ template <typename T>
+ struct is_unqualif : equal<T, mlc_unqualif(T)>::eval
+ {
+ };
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_IS_UNQUALIF_HH
Index: mln/metal/bexpr.hh
--- mln/metal/bexpr.hh (revision 1201)
+++ mln/metal/bexpr.hh (working copy)
@@ -36,6 +36,11 @@
# include <mln/metal/bool.hh>
+# define mlc_not( B ) mln::metal::not_< B >
+# define mlc_and( B1, B2 ) mln::metal::and_< B1, B2 >
+# define mlc_or( B1, B2 ) mln::metal::or_ < B1, B2 >
+# define mlc_xor( B1, B2 ) mln::metal::xor_< B1, B2 >
+
namespace mln
{
@@ -43,57 +48,30 @@
namespace metal
{
-
- /// "true" type.
- struct true_
- {
- static void check();
- typedef true_ eval;
- enum { to_bool = true };
- };
-
-
- /// "false" type.
- struct false_
- {
- typedef false_ eval;
- enum { to_bool = false };
- };
-
-
/// Negate type.
template <typename B>
- struct not_ : bool_<( ! B::to_bool )>::type
+ struct not_ : bool_<( ! B::value )>
{};
/// And type.
template <typename L, typename R>
- struct and_ : bool_<( L::to_bool && R::to_bool )>::type
+ struct and_ : bool_<( L::value && R::value )>
{};
/// Or type.
template <typename L, typename R>
- struct or_ : bool_<( L::to_bool || R::to_bool )>::type
+ struct or_ : bool_<( L::value || R::value )>
{};
/// Xor type.
template <typename L, typename R>
- struct xor_ : bool_<( L::to_bool ^ R::to_bool )>::type
+ struct xor_ : bool_<( L::value ^ R::value )>
{};
-
-# ifndef MLN_INCLUDE_ONLY
-
- void true_::check()
- {
- }
-
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::metal
} // end of namespace mln
Index: mln/level/fill.hh
--- mln/level/fill.hh (revision 1201)
+++ mln/level/fill.hh (working copy)
@@ -32,7 +32,7 @@
*
* \brief Fill an image, that is, set pixel values.
*
- * \todo Overload for fast images.
+ * \todo Re-organize this file contents + Overload for fast images.
*/
# include <cstring>
@@ -157,6 +157,7 @@
template <typename I>
void fill(Image<I>& ima, const mln_value(I)& value)
{
+ mlc_is(mln_trait_image_io(I), trait::io::write)::check(); // FIXME: Only the
upcoming general facade!!!
mln_precondition(exact(ima).has_data());
impl::fill_with_value(exact(ima), value);
}
Index: mln/level/fast_median.hh
--- mln/level/fast_median.hh (revision 1201)
+++ mln/level/fast_median.hh (working copy)
@@ -121,7 +121,7 @@
for_all(q_bot)
med.take(q_bot.val());
- output(p) = med.to_result();
+ output(p) = med;
if (fwd)
// browse line fwd
@@ -132,7 +132,7 @@
med.untake(q_fm.val());
for_all(q_fp)
med.take(q_fp.val());
- output(p) = med.to_result();
+ output(p) = med;
}
else
// browse line bkd
@@ -143,7 +143,7 @@
med.untake(q_bm.val());
for_all(q_bp)
med.take(q_bp.val());
- output(p) = med.to_result();
+ output(p) = med;
}
// change browsing
fwd = ! fwd;
Index: mln/level/paste.hh
--- mln/level/paste.hh (revision 1201)
+++ mln/level/paste.hh (working copy)
@@ -70,45 +70,47 @@
{
template <typename I, typename J>
- void paste_generic_(const Image<I>& data_, Image<J>&
destination_)
+ void paste_generic_(const I& data, J& destination)
{
- const I& data = exact(data_);
- J& destination = exact(destination_);
-
+ trace::entering("level::impl::paste_generic_");
mln_piter(I) p(data.domain());
for_all(p)
destination(p) = data(p);
+ trace::exiting("level::impl::paste_generic_");
}
template <typename I, typename J>
- void paste_fast_(const Fast_Image<I>& data_, Fast_Image<J>&
destination_)
+ void paste_lines_(const I& data, J& destination)
{
- const I& data = exact(data_);
- J& destination = exact(destination_);
-
+ trace::entering("level::impl::paste_lines_");
typedef mln_point(I) P;
std::size_t n = data.bbox().len(P::dim - 1);
+ // FIXME: Works only for raw data images
+ // FIXME: For linear data images, we should get the len for each line...
- typename I::line_piter p(data.domain());
+ typename I::line_piter p(data.domain()); // FIXME: Alias mln_line_piter!
for_all(p)
memcpy_(inplace(make::pixel(destination, p)),
make::pixel(data, p),
n);
+ trace::exiting("level::impl::paste_lines_");
}
// Disjunction.
template <typename I, typename J>
- void paste_(const Image<I>& data, Image<J>& destination)
+ void paste_(mln::trait::data::any, const I& data,
+ mln::trait::data::any, J& destination)
{
paste_generic_(data, destination);
}
template <typename I, typename J>
- void paste_(const Fast_Image<I>& data, Fast_Image<J>&
destination)
+ void paste_(mln::trait::data::raw, const I& data,
+ mln::trait::data::raw, J& destination)
{
if (sizeof(mln_value(I)) = sizeof(mln_value(J)))
- paste_fast_(data, destination);
+ paste_lines_(data, destination);
else
paste_generic_(data, destination);
}
@@ -119,10 +121,20 @@
// Facade.
template <typename I, typename J>
- void paste(const Image<I>& data, Image<J>& destination)
+ void paste(const Image<I>& data_, Image<J>& destination_)
{
- mln_precondition(exact(data).domain() <= exact(destination).domain());
- impl::paste_(exact(data), exact(destination));
+ trace::entering("level::paste");
+ mlc_is(mln_trait_image_io(J), trait::io::write)::check();
+ mlc_converts_to(mln_value(I), mln_value(J))::check();
+
+ const I& data = exact(data_);
+ J& destination = exact(destination_);
+ mln_precondition(data.domain() <= destination.domain());
+
+ // Remember: raw < linear < stored, computed.
+ impl::paste_(mln_trait_image_data(I)(), data,
+ mln_trait_image_data(J)(), destination);
+ trace::exiting("level::paste");
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/accu/median.hh
--- mln/accu/median.hh (revision 1201)
+++ mln/accu/median.hh (working copy)
@@ -33,7 +33,7 @@
* \brief Define a generic median accumulator class.
*/
-# include <mln/core/concept/accumulator.hh>
+# include <mln/accu/internal/base.hh>
# include <mln/accu/histo.hh>
@@ -48,7 +48,7 @@
* with type \c S.
*/
template <typename S>
- struct median : public Accumulator< median<S> >
+ struct median : public mln::accu::internal::base_< mln_value(S), median<S>
>
{
typedef mln_value(S) value;
typedef value result;
Index: mln/accu/internal/base.hh
--- mln/accu/internal/base.hh (revision 0)
+++ mln/accu/internal/base.hh (revision 0)
@@ -0,0 +1,93 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_ACCU_INTERNAL_BASE_HH
+# define MLN_ACCU_INTERNAL_BASE_HH
+
+/*! \file mln/accu/internal/base.hh
+ *
+ * \brief Define a base class for implementation of accumulator
+ * classes.
+ */
+
+# include <mln/core/concept/accumulator.hh>
+# include <mln/metal/unconst.hh>
+# include <mln/metal/unref.hh>
+
+
+namespace mln
+{
+
+ namespace accu
+ {
+
+ namespace internal
+ {
+
+ /*! Generic min accumulator class.
+ *
+ * Base class for implementation of accumulator classes.
+ */
+ template <typename R, typename E>
+ struct base_ : public Accumulator<E>
+ {
+ typedef mlc_unconst(R) tmp_;
+ typedef mlc_unref(tmp_) result_;
+ public:
+
+ typedef R result;
+
+ operator result_() const;
+
+ protected:
+ base_();
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename R, typename E>
+ base_<R,E>::base_()
+ {
+ }
+
+ template <typename R, typename E>
+ base_<R,E>::operator typename base_<R,E>::result_ () const
+ {
+ return exact(this)->to_result();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::accu::internal
+
+ } // end of namespace mln::accu
+
+} // end of namespace mln
+
+
+#endif // ! MLN_ACCU_INTERNAL_BASE_HH
Index: mln/value/interval.hh
--- mln/value/interval.hh (revision 0)
+++ mln/value/interval.hh (revision 0)
@@ -0,0 +1,101 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_VALUE_INTERVAL_HH
+# define MLN_VALUE_INTERVAL_HH
+
+/*! \file mln/value/interval.hh
+ *
+ * \brief Define an interval between two values.
+ *
+ * \todo Likewise, code value::not_equal(t), less_than, etc.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+ namespace value
+ {
+
+ /// FIXME: Doc!
+
+ template <typename T>
+ struct interval_ : public Object< interval_<T> >
+ {
+ interval_(const T& from, const T& to);
+ T from, to;
+
+ template <typename U>
+ operator interval_<U>() const;
+ };
+
+
+ template <typename T>
+ interval_<T>
+ interval(const T& from, const T& to);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ interval_<T>::interval_(const T& from, const T& to)
+ : from(from),
+ to(to)
+ {
+ mln_precondition(from <= to);
+ }
+
+ template <typename T>
+ template <typename U>
+ interval_<T>::operator interval_<U>() const
+ {
+ mln_invariant(from <= to);
+ interval_<U> tmp(from, to);
+ mln_postcondition(tmp.from <= tmp.to);
+ return tmp;
+ }
+
+ template <typename T>
+ interval_<T>
+ interval(const T& from, const T& to)
+ {
+ mln_precondition(from <= to);
+ interval_<T> tmp(from, to);
+ return tmp;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::value
+
+} // end of namespace mln
+
+
+#endif // ! MLN_VALUE_INTERVAL_HH
Index: mln/value/props.hh
--- mln/value/props.hh (revision 1201)
+++ mln/value/props.hh (working copy)
@@ -66,7 +66,7 @@
/// Test is the value type \c T is low quantized.
-# define mln_is_lowq(T) typename metal::bool_<( mln_card_(T) != 0 )>::type
+# define mln_is_lowq(T) typename metal::bool_<( mln_card_(T) != 0 )>
/// Give the summation type for values of type \c T.
Index: mln/value/all.hh
--- mln/value/all.hh (revision 1201)
+++ mln/value/all.hh (working copy)
@@ -49,6 +49,8 @@
# include <mln/value/props.hh>
# include <mln/value/proxy.hh>
+# include <mln/value/interval.hh>
+
// FIXME: that includes concept/image.hh!
Index: mln/border/get.hh
--- mln/border/get.hh (revision 1201)
+++ mln/border/get.hh (working copy)
@@ -63,7 +63,7 @@
}
template <typename S, typename E>
- unsigned get__(const mln::internal::image_base_<S,E>& ima)
+ unsigned get__(const mln::internal::image_base_<S,E>&)
{
return 0;
}
Index: mln/pw/image.hh
--- mln/pw/image.hh (revision 1201)
+++ mln/pw/image.hh (working copy)
@@ -36,6 +36,7 @@
# include <mln/core/internal/image_primary.hh>
# include <mln/core/concept/function.hh>
# include <mln/value/set.hh>
+# include <mln/metal/unqualif.hh>
namespace mln
@@ -71,6 +72,30 @@
+ namespace trait
+ {
+
+ // FIXME: the result type should *not* be qualified
+
+ template <typename F, typename S>
+ struct image_< pw::image<F,S> > : default_image_<
mlc_unqualif(mln_result(F)),
+ pw::image<F,S> >
+ {
+ typedef trait::category::primary category;
+
+ typedef trait::access::browsing access;
+ typedef trait::space::fixme space;
+ typedef trait::size::regular size;
+ typedef trait::support::fixme support;
+
+ typedef trait::border::none border;
+ typedef trait::data::computed data;
+ typedef trait::io::read_only io;
+ };
+
+ } // end of namespace mln::trait
+
+
namespace pw
{
Index: mln/fun/ops.hh
--- mln/fun/ops.hh (revision 1201)
+++ mln/fun/ops.hh (working copy)
@@ -122,12 +122,12 @@
{
// -> p2v
- mln_decl_binary_expr_(p2v, p2b, equal, =);
- mln_decl_binary_expr_(p2v, p2b, not_equal, !=);
+ mln_decl_binary_expr_(p2v, p2b, eq, =);
+ mln_decl_binary_expr_(p2v, p2b, neq, !=);
mln_decl_binary_expr_(p2v, p2b, less, <);
- mln_decl_binary_expr_(p2v, p2b, less_or_equal, <=);
- mln_decl_binary_expr_(p2v, p2b, greater_or_equal, >=);
+ mln_decl_binary_expr_(p2v, p2b, leq , <=);
+ mln_decl_binary_expr_(p2v, p2b, geq, >=);
mln_decl_binary_expr_(p2v, p2b, greater, >);
mln_decl_binary_expr_(p2b, p2b, and, &&);
@@ -147,12 +147,12 @@
// -> v2b
- mln_decl_binary_expr_(v2v, v2b, equal, =);
- mln_decl_binary_expr_(v2v, v2b, not_equal, !=);
+ mln_decl_binary_expr_(v2v, v2b, eq, =);
+ mln_decl_binary_expr_(v2v, v2b, neq, !=);
mln_decl_binary_expr_(v2v, v2b, less, <);
- mln_decl_binary_expr_(v2v, v2b, less_or_equal, <=);
- mln_decl_binary_expr_(v2v, v2b, greater_or_equal, >=);
+ mln_decl_binary_expr_(v2v, v2b, leq, <=);
+ mln_decl_binary_expr_(v2v, v2b, geq, >=);
mln_decl_binary_expr_(v2v, v2b, greater, >);
mln_decl_binary_expr_(v2b, v2b, and, &&);
Index: mln/fun/p2v/iota.hh
--- mln/fun/p2v/iota.hh (revision 0)
+++ mln/fun/p2v/iota.hh (revision 0)
@@ -0,0 +1,102 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_P2V_IOTA_HH
+# define MLN_FUN_P2V_IOTA_HH
+
+/*! \file mln/fun/p2v/iota.hh
+ *
+ * \brief Iota function.
+ */
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace p2v
+ {
+
+ struct iota_t : public Function_p2v< iota_t >
+ {
+ typedef unsigned result;
+
+ iota_t();
+
+ template <typename P>
+ unsigned operator()(const P&) const;
+
+ unsigned value() const;
+ void reset() const;
+
+ protected:
+ mutable unsigned i_;
+ }
+
+ iota;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ iota_t::iota_t()
+ {
+ reset();
+ }
+
+ template <typename P>
+ unsigned
+ iota_t::operator()(const P&) const
+ {
+ return ++i_;
+ }
+
+ unsigned
+ iota_t::value() const
+ {
+ return i_;
+ }
+
+ void
+ iota_t::reset() const
+ {
+ i_ = 0;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::p2v
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_P2V_IOTA_HH
Index: mln/fun/internal/selector.hh
--- mln/fun/internal/selector.hh (revision 1201)
+++ mln/fun/internal/selector.hh (working copy)
@@ -160,7 +160,7 @@
template <typename T>
struct tag_
{
- enum { value = mlc_is_a(T, Point_Site)::to_bool
+ enum { value = mlc_is_a(T, Point_Site)::value
? p_
: v_ };
};
Index: mln/trace/exiting.hh
--- mln/trace/exiting.hh (revision 0)
+++ mln/trace/exiting.hh (revision 0)
@@ -0,0 +1,67 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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. Specificenteringy, 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_TRACE_EXITING_HH
+# define MLN_TRACE_EXITING_HH
+
+/*! \file mln/trace/exiting.hh
+ *
+ * \brief Definition of the trace exiting procedure.
+ */
+
+# include <string>
+# include <mln/trace/quiet.hh>
+
+
+namespace mln
+{
+
+ namespace trace
+ {
+
+ void exiting(const std::string& scope);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ void exiting(const std::string&)
+ {
+ if (quiet)
+ return;
+ --tab;
+ for (unsigned i = 0; i < tab; ++i)
+ std::cout << " ";
+ std::cout << "}" << std::endl;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::trace
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRACE_EXITING_HH
Index: mln/trace/quiet.hh
--- mln/trace/quiet.hh (revision 0)
+++ mln/trace/quiet.hh (revision 0)
@@ -0,0 +1,51 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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. Specificenteringy, 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_TRACE_QUIET_HH
+# define MLN_TRACE_QUIET_HH
+
+/*! \file mln/trace/quiet.hh
+ *
+ * \brief Definition of the trace quiet Boolean value.
+ */
+
+
+namespace mln
+{
+
+ namespace trace
+ {
+
+ static bool quiet = true;
+ static unsigned tab = 0;
+
+ } // end of namespace mln::trace
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRACE_QUIET_HH
Index: mln/trace/all.hh
--- mln/trace/all.hh (revision 0)
+++ mln/trace/all.hh (revision 0)
@@ -0,0 +1,52 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_TRACE_ALL_HH
+# define MLN_TRACE_ALL_HH
+
+/*! \file mln/trace/all.hh
+ *
+ * \brief File that includes all trace-related routines.
+ */
+
+
+namespace mln
+{
+
+ /*! Namespace of routines related to the trace mechanism.
+ */
+ namespace trace {}
+
+} // end of namespace mln
+
+
+# include <mln/trace/quiet.hh>
+# include <mln/trace/entering.hh>
+# include <mln/trace/exiting.hh>
+
+
+#endif // ! MLN_TRACE_ALL_HH
Index: mln/trace/entering.hh
--- mln/trace/entering.hh (revision 0)
+++ mln/trace/entering.hh (revision 0)
@@ -0,0 +1,67 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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. Specificenteringy, 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_TRACE_ENTERING_HH
+# define MLN_TRACE_ENTERING_HH
+
+/*! \file mln/trace/entering.hh
+ *
+ * \brief Definition of the trace entering procedure.
+ */
+
+# include <string>
+# include <mln/trace/quiet.hh>
+
+
+namespace mln
+{
+
+ namespace trace
+ {
+
+ void entering(const std::string& scope);
+
+# ifndef MLN_INCLUDE_ONLY
+
+ void entering(const std::string& scope)
+ {
+ if (quiet)
+ return;
+ for (unsigned i = 0; i < tab; ++i)
+ std::cout << " ";
+ std::cout << scope << " {" << std::endl;
+ ++tab;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::trace
+
+} // end of namespace mln
+
+
+#endif // ! MLN_TRACE_ENTERING_HH
Index: mln/morpho/plus.hh
--- mln/morpho/plus.hh (revision 1201)
+++ mln/morpho/plus.hh (working copy)
@@ -85,7 +85,7 @@
{
mln_precondition(exact(rhs).domain() = exact(lhs).domain());
mln_precondition(exact(output).domain() = exact(lhs).domain());
- impl::plus_(mln_value_kind(mln_value(I))(), exact(lhs), exact(rhs), output);
+ impl::plus_(mln_trait_image_kind(I)(), exact(lhs), exact(rhs), output);
}
template <typename I, typename J>
Index: mln/morpho/min.hh
--- mln/morpho/min.hh (revision 1201)
+++ mln/morpho/min.hh (working copy)
@@ -101,14 +101,14 @@
{
mln_precondition(exact(rhs).domain() = exact(lhs).domain());
mln_precondition(exact(output).domain() = exact(lhs).domain());
- impl::min_(mln_value_kind(mln_value(I))(), exact(lhs), exact(rhs), output);
+ impl::min_(mln_trait_image_kind(I)(), exact(lhs), exact(rhs), output);
}
template <typename I, typename J>
void min_inplace(Image<I>& lhs, const Image<J>& rhs)
{
mln_precondition(exact(rhs).domain() = exact(lhs).domain());
- impl::min_inplace_(mln_value_kind(mln_value(I))(), exact(lhs), exact(rhs));
+ impl::min_inplace_(mln_trait_image_kind(I)(), exact(lhs), exact(rhs));
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/morpho/minus.hh
--- mln/morpho/minus.hh (revision 1201)
+++ mln/morpho/minus.hh (working copy)
@@ -85,7 +85,7 @@
{
mln_precondition(exact(rhs).domain() = exact(lhs).domain());
mln_precondition(exact(output).domain() = exact(lhs).domain());
- impl::minus_(mln_value_kind(mln_value(I))(), exact(lhs), exact(rhs), output);
+ impl::minus_(mln_trait_image_kind(I)(), exact(lhs), exact(rhs), output);
}
template <typename I, typename J>
Index: mln/morpho/complementation.hh
--- mln/morpho/complementation.hh (revision 1201)
+++ mln/morpho/complementation.hh (working copy)
@@ -85,7 +85,7 @@
void complementation(const Image<I>& input, Image<O>& output)
{
mln_precondition(exact(output).domain() = exact(input).domain());
- impl::complementation_(mln_value_kind(mln_value(I))(), exact(input), output);
+ impl::complementation_(mln_trait_image_kind(I)(), exact(input), output);
}
template <typename I>
Index: mln/morpho/dilation.hh
--- mln/morpho/dilation.hh (revision 1201)
+++ mln/morpho/dilation.hh (working copy)
@@ -134,7 +134,7 @@
template <typename I, typename W, typename O>
void dilation_wrt_win(const Image<I>& input, const Window<W>&
win, Image<O>& output)
{
- dilation_wrt_value(mln_value_kind(mln_value(I))(), exact(input), exact(win), output);
+ dilation_wrt_value(mln_trait_image_kind(I)(), exact(input), exact(win), output);
// |
// --> call stage 2: dispatch w.r.t. the value kind
}
Index: mln/morpho/erosion.hh
--- mln/morpho/erosion.hh (revision 1201)
+++ mln/morpho/erosion.hh (working copy)
@@ -137,7 +137,7 @@
template <typename I, typename W, typename O>
void erosion_wrt_win(const Image<I>& input, const Window<W>&
win, Image<O>& output)
{
- erosion_wrt_value(mln_value_kind(mln_value(I))(), exact(input), exact(win), output);
+ erosion_wrt_value(mln_trait_image_kind(I)(), exact(input), exact(win), output);
// |
// --> call stage 2: dispatch w.r.t. the value kind
}
Index: mln/morpho/hit_or_miss.hh
--- mln/morpho/hit_or_miss.hh (revision 1201)
+++ mln/morpho/hit_or_miss.hh (working copy)
@@ -190,7 +190,7 @@
Image<O>& output)
{
impl::hit_or_miss_preconditions_(input, win_hit, win_miss, output);
- impl::hit_or_miss_(mln_value_kind(mln_value(I))(), input, win_hit, win_miss,
output);
+ impl::hit_or_miss_(mln_trait_image_kind(I)(), input, win_hit, win_miss, output);
}
template <typename I, typename Wh, typename Wm, typename O>
Index: mln/canvas/morpho/algebraic_union_find.hh
--- mln/canvas/morpho/algebraic_union_find.hh (revision 1201)
+++ mln/canvas/morpho/algebraic_union_find.hh (working copy)
@@ -68,10 +68,7 @@
mln_ch_value(O, A) data;
algebraic_union_find(F& f)
- : f(f),
- deja_vu(f.output.domain()),
- parent(f.output.domain()),
- data(f.output.domain())
+ : f(f)
{
run();
}
@@ -80,7 +77,10 @@
{
// init
{
+ initialize(deja_vu, f.input);
mln::level::fill(deja_vu, false);
+ initialize(parent, f.input);
+ initialize(data, f.input);
f.init();
}
// first pass
@@ -119,7 +119,7 @@
void make_set(const point& p)
{
parent(p) = p;
- data(p).take_as_init(make::pix(f.input, p));
+ data(p).take_as_init(make::pix(f.input, p)); // FIXME: algebraic so p!
}
bool is_root(const point& p) const
Index: mln/canvas/browsing/snake_fwd.hh
--- mln/canvas/browsing/snake_fwd.hh (revision 1201)
+++ mln/canvas/browsing/snake_fwd.hh (working copy)
@@ -33,6 +33,7 @@
* \brief Browsing in a snake-way, forward.
*/
+# include <mln/core/concept/browsing.hh>
# include <mln/core/dpoint2d.hh> // for "up"
# include <mln/geom/size2d.hh>
@@ -62,14 +63,21 @@
* } \n
*
*/
+
+ struct snake_fwd_t : public Browsing< snake_fwd_t >
+ {
template <typename F>
- void snake_fwd(F& f);
+ void operator()(F& f) const;
+ }
+
+ snake_fwd;
# ifndef MLN_INCLUDE_ONLY
template <typename F>
- void snake_fwd(F& f)
+ void
+ snake_fwd_t::operator()(F& f) const
{
mln_precondition(f.input.has_data());
int
Index: mln/canvas/browsing/fwd.hh
--- mln/canvas/browsing/fwd.hh (revision 0)
+++ mln/canvas/browsing/fwd.hh (revision 0)
@@ -0,0 +1,103 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_CANVAS_BROWSING_FWD_HH
+# define MLN_CANVAS_BROWSING_FWD_HH
+
+/*! \file mln/canvas/browsing/fwd.hh
+ *
+ * \brief Canvas for browsing forward.
+ */
+
+# include <mln/core/concept/browsing.hh>
+# include <mln/core/concept/image.hh>
+
+
+namespace mln
+{
+
+ namespace canvas
+ {
+
+ namespace browsing
+ {
+
+ /*! FIXME: Doc!
+ *
+ *
+ * F shall feature: \n
+ * { \n
+ * --- as typedef: \n
+ * I; \n
+ * --as attributes: \n
+ * input; \n
+ * p; \n
+ * --- as method: \n
+ * void init(); \n
+ * void next(); \n
+ * void final(); \n
+ * } \n
+ *
+ */
+
+ struct fwd_t : public Browsing< fwd_t >
+ {
+ template <typename F>
+ void operator()(F& f) const;
+ }
+
+ fwd;
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename F>
+ void
+ fwd_t::operator()(F& f) const
+ {
+ mln_precondition(f.input.has_data());
+ typedef typename F::I I;
+ mln_fwd_piter(I) p(f.input.domain());
+ f.init();
+ for_all(p)
+ {
+ f.p = p;
+ f.next();
+ }
+ f.final();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::canvas::browsing
+
+ } // end of namespace mln::canvas
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CANVAS_BROWSING_FWD_HH
Index: mln/canvas/labeling.hh
--- mln/canvas/labeling.hh (revision 1201)
+++ mln/canvas/labeling.hh (working copy)
@@ -62,9 +62,7 @@
mln_ch_value(O, point) parent;
labeling(F& f)
- : f(f),
- deja_vu(f.output.domain()),
- parent(f.output.domain())
+ : f(f)
{
run();
}
@@ -73,8 +71,10 @@
{
// init
{
- f.nlabels = 0;
+ initialize(deja_vu, f.input);
mln::level::fill(deja_vu, false);
+ initialize(parent, f.input);
+ f.nlabels = 0;
f.init();
}
// first pass
Index: mln/util/nil.hh
--- mln/util/nil.hh (revision 0)
+++ mln/util/nil.hh (revision 0)
@@ -0,0 +1,97 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// 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_UTIL_NIL_HH
+# define MLN_UTIL_NIL_HH
+
+/*! \file mln/util/nil.hh
+ *
+ * \brief Definition of an "niler" object.
+ */
+
+# include <mln/core/concept/object.hh>
+
+
+namespace mln
+{
+
+ namespace util
+ {
+
+ /// Nil structure.
+ struct nil : public Object< nil >
+ {
+ nil();
+
+ // Just like util::eat:
+
+ template <typename T>
+ nil(const T&);
+
+ template <typename T>
+ nil& operator=(const T&);
+
+ // Just like util::ignore:
+
+ template <typename T>
+ operator T() const;
+ };
+
+# ifndef MLN_INCLUDE_ONLY
+
+ // nil
+
+ nil::nil()
+ {
+ }
+
+ template <typename T>
+ nil::nil(const T&)
+ {
+ }
+
+ template <typename T>
+ nil&
+ nil::operator=(const T&)
+ {
+ return *this;
+ }
+
+ template <typename T>
+ nil::operator T() const
+ {
+ return T();
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::util
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UTIL_NIL_HH
Index: mln/util/ignore.hh
--- mln/util/ignore.hh (revision 1201)
+++ mln/util/ignore.hh (working copy)
@@ -43,7 +43,7 @@
{
/// Ignore structure.
- struct ignore
+ struct ignore : public Object< ignore >
{
ignore();
Index: mln/util/eat.hh
--- mln/util/eat.hh (revision 1201)
+++ mln/util/eat.hh (working copy)
@@ -43,7 +43,7 @@
{
/// Eat structure.
- struct eat
+ struct eat : public Object< eat >
{
eat();