* tests/core/other/category.cc,
* mln/core/macros.hh: update doc.
* mln/core/var.hh: add new macros here.
* tests/core/image/graph_image.cc,
* tests/core/image/line_graph_image.cc: rename variables and fix
coding style.
* tests/core/other/Makefile.am,
* tests/core/other/var.cc: new test to check macros.
---
milena/ChangeLog | 12 ++
milena/mln/core/macros.hh | 7 +-
milena/mln/core/var.hh | 195 ++++++++++++++++++++++++++++++++++-
milena/tests/core/other/Makefile.am | 2 +
milena/tests/core/other/category.cc | 10 +-
milena/tests/core/other/var.cc | 139 +++++++++++++++++++++++++
6 files changed, 351 insertions(+), 14 deletions(-)
create mode 100644 milena/tests/core/other/var.cc
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0748651..60a03d4 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,15 @@
+2008-12-12 Guillaume Lazzara <z(a)lrde.epita.fr>
+
+ Add new macros mln_*ITER() to declare iterators.
+
+ * tests/core/other/category.cc,
+ * mln/core/macros.hh: update doc.
+
+ * mln/core/var.hh: add new macros here.
+
+ * tests/core/other/Makefile.am,
+ * tests/core/other/var.cc: new test to check macros.
+
2008-12-11 Guillaume Lazzara <z(a)lrde.epita.fr>
Fix many various tests.
diff --git a/milena/mln/core/macros.hh b/milena/mln/core/macros.hh
index 16ce3fe..ba5702e 100644
--- a/milena/mln/core/macros.hh
+++ b/milena/mln/core/macros.hh
@@ -29,10 +29,9 @@
#ifndef MLN_CORE_MACROS_HH
# define MLN_CORE_MACROS_HH
-/*! \file mln/core/macros.hh
- *
- * \brief Definition of the set of Milena macros.
- */
+/// \file mln/core/macros.hh
+///
+/// Definition of the set of Milena macros.
# define mln_deduce(T, A1, A2) typename T::A1::A2
diff --git a/milena/mln/core/var.hh b/milena/mln/core/var.hh
index dfec471..0b40216 100644
--- a/milena/mln/core/var.hh
+++ b/milena/mln/core/var.hh
@@ -28,13 +28,18 @@
#ifndef MLN_CORE_VAR_HH
# define MLN_CORE_VAR_HH
-/*! \file mln/core/var.hh
- *
- * \brief Definition of the macro mln_VAR. Warning: that macro relies
- * on an extention of g++ (typeof) so it is NOT standard C++.
- */
+/// \file mln/core/var.hh
+///
+/// This file contains various macros to declare variables.
+///
+/// Warning: that macro relies on an extention of g++ (typeof) so it is
+/// NOT standard C++.
+# include <mln/core/macros.hh>
+/// Definition of the macro mln_VAR.
+/// Deduce the type of Expr, create a variable of that type and assign the
+/// result to it.
#define mln_VAR(Var, Expr) \
\
typeof(Expr) Var = Expr; \
@@ -46,4 +51,184 @@
typedef const typeof(Expr) Var##_t
+// mln_PITER
+
+/// Shortcuts to declare site iterators
+/// \{
+#define mln_PITER(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_piter(p##__obj_type) p(obj)
+
+#define mln_PITER_(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_piter_(p##__obj_type) p(obj)
+/// \}
+
+/// Shortcuts to declare site forward iterators
+/// \{
+#define mln_FWD_PITER(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_fwd_piter(p##__obj_type) p(obj)
+
+#define mln_FWD_PITER_(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_fwd_piter_(p##__obj_type) p(obj)
+/// \}
+
+/// Shortcuts to declare site backward iterators
+/// \{
+#define mln_BKD_PITER(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_bkd_piter(p##__obj_type) p(obj)
+
+#define mln_BKD_PITER_(p, obj) \
+ typedef typeof(obj) p##__obj_type; \
+ mln_bkd_piter_(p##__obj_type) p(obj)
+/// \}
+
+
+// mln_NITER
+
+/// Shortcuts to declare neighbor iterators
+/// \{
+#define mln_NITER(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_niter(n##__obj_type) n(obj, p)
+
+#define mln_NITER_(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_niter_(n##__obj_type) n(obj, p)
+/// \}
+
+/// Shortcuts to declare neighbor forward iterators
+/// \{
+#define mln_FWD_NITER(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_fwd_niter(n##__obj_type) n(obj, p)
+
+#define mln_FWD_NITER_(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_fwd_niter_(n##__obj_type) n(obj, p)
+/// \}
+
+/// Shortcuts to declare neighbor backward iterators
+/// \{
+#define mln_BKD_NITER(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_bkd_niter(n##__obj_type) n(obj, p)
+
+#define mln_BKD_NITER_(n, obj, p) \
+ typedef typeof(obj) n##__obj_type; \
+ mln_bkd_niter_(n##__obj_type) n(obj, p)
+/// \}
+
+
+// mln_QITER
+
+/// Shortcuts to declare neighbor iterators on windows
+/// \{
+#define mln_QITER(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_qiter(q##__obj_type) q(obj, p)
+
+#define mln_QITER_(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_qiter_(q##__obj_type) q(obj, p)
+/// \}
+
+/// Shortcuts to declare neighbor forward iterators on windows
+/// \{
+#define mln_FWD_QITER(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_fwd_qiter(q##__obj_type) q(obj, p)
+
+#define mln_FWD_QITER_(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_fwd_qiter_(q##__obj_type) q(obj, p)
+/// \}
+
+/// Shortcuts to declare neighbor backward iterators on windows
+/// \{
+#define mln_BKD_QITER(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_bkd_qiter(q##__obj_type) q(obj, p)
+
+#define mln_BKD_QITER_(q, obj, p) \
+ typedef typeof(obj) q##__obj_type; \
+ mln_bkd_qiter_(q##__obj_type) q(obj, p)
+/// \}
+
+
+// mln_EITER
+
+/// Shortcuts to declare element iterators
+/// \{
+#define mln_EITER(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_eiter(e##__obj_type) e(obj)
+
+#define mln_EITER_(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_eiter_(e##__obj_type) e(obj)
+/// \}
+
+/// Shortcuts to declare element forward iterators
+/// \{
+#define mln_FWD_EITER(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_fwd_eiter(e##__obj_type) e(obj)
+
+#define mln_FWD_EITER_(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_fwd_eiter_(e##__obj_type) e(obj)
+/// \}
+
+/// Shortcuts to declare element backward iterators
+/// \{
+#define mln_BKD_EITER(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_bkd_eiter(e##__obj_type) e(obj)
+
+#define mln_BKD_EITER_(e, obj) \
+ typedef typeof(obj) e##__obj_type; \
+ mln_bkd_eiter_(e##__obj_type) e(obj)
+/// \}
+
+
+// mln_VITER
+
+/// Shortcuts to declare value iterators
+/// \{
+#define mln_VITER(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_viter(v##__obj_type) v(obj)
+
+#define mln_VITER_(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_viter_(v##__obj_type) v(obj)
+/// \}
+
+/// Shortcuts to declare value forward iterators
+/// \{
+#define mln_FWD_VITER(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_fwd_viter(v##__obj_type) v(obj)
+
+#define mln_FWD_VITER_(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_fwd_viter_(v##__obj_type) v(obj)
+/// \}
+
+/// Shortcuts to declare value backward iterators
+/// \{
+#define mln_BKD_VITER(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_bkd_viter(v##__obj_type) v(obj)
+
+#define mln_BKD_VITER_(v, obj) \
+ typedef typeof(obj) v##__obj_type; \
+ mln_bkd_viter_(v##__obj_type) v(obj)
+/// \}
+
+
#endif // ! MLN_CORE_VAR_HH
diff --git a/milena/tests/core/other/Makefile.am b/milena/tests/core/other/Makefile.am
index e6f3633..018f1e6 100644
--- a/milena/tests/core/other/Makefile.am
+++ b/milena/tests/core/other/Makefile.am
@@ -22,6 +22,7 @@ check_PROGRAMS = \
pixter3d \
pixter3d_more \
point_set_compatibility \
+ var \
w_window
box_runstart_piter_SOURCES = box_runstart_piter.cc
@@ -42,6 +43,7 @@ pixter2d_more_SOURCES = pixter2d_more.cc
pixter3d_SOURCES = pixter3d.cc
pixter3d_more_SOURCES = pixter3d_more.cc
point_set_compatibility_SOURCES = point_set_compatibility.cc
+var_SOURCES = var.cc
w_window_SOURCES = w_window.cc
TESTS = $(check_PROGRAMS)
diff --git a/milena/tests/core/other/category.cc b/milena/tests/core/other/category.cc
index 12d2ac0..3edf612 100644
--- a/milena/tests/core/other/category.cc
+++ b/milena/tests/core/other/category.cc
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,10 +26,9 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-/*! \file tests/core/other/category.cc
- *
- * \brief Tests on mln::category.
- */
+/// \file tests/core/other/category.cc
+///
+/// Tests on mln::category.
#include <mln/core/category.hh>
diff --git a/milena/tests/core/other/var.cc b/milena/tests/core/other/var.cc
new file mode 100644
index 0000000..6079142
--- /dev/null
+++ b/milena/tests/core/other/var.cc
@@ -0,0 +1,139 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory
+// (LRDE)
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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/other/var.cc
+///
+/// Tests all macros located in mln/core/var.hh
+
+#include <mln/core/image/image2d.hh>
+#include <mln/core/alias/window2d.hh>
+#include <mln/core/alias/neighb2d.hh>
+#include <mln/histo/data.hh>
+#include <mln/util/array.hh>
+
+#include <mln/core/var.hh>
+
+template <typename T>
+void test_template()
+{
+ using namespace mln;
+
+ image2d<T> ima(1,1);
+ neighb2d neighb;
+ window2d win;
+ {
+ mln_PITER(p, ima.domain());
+ mln_NITER(n, neighb, p);
+ mln_QITER(q, win, p);
+ }
+ {
+ mln_FWD_PITER(p, ima.domain());
+ mln_FWD_NITER(n, neighb, p);
+ mln_FWD_QITER(q, win, p);
+ }
+ {
+ mln_BKD_PITER(p, ima.domain());
+ mln_BKD_NITER(n, neighb, p);
+ mln_BKD_QITER(q, win, p);
+ }
+
+ util::array<point2d> arr;
+ {
+ mln_EITER(e, arr);
+ }
+ {
+ mln_FWD_EITER(e, arr);
+ }
+ {
+ mln_BKD_EITER(e, arr);
+ }
+
+ histo::data<bool> d;
+ {
+ mln_VITER(v, d.vset());
+ }
+ {
+ mln_FWD_VITER(v, d.vset());
+ }
+ {
+ mln_BKD_VITER(v, d.vset());
+ }
+
+}
+
+void test()
+{
+ using namespace mln;
+
+ image2d<int> ima(1,1);
+ neighb2d neighb;
+ window2d win;
+ {
+ mln_PITER_(p, ima.domain());
+ mln_NITER_(n, neighb, p);
+ mln_QITER_(q, win, p);
+ }
+ {
+ mln_FWD_PITER_(p, ima.domain());
+ mln_FWD_NITER_(n, neighb, p);
+ mln_FWD_QITER_(q, win, p);
+ }
+ {
+ mln_BKD_PITER_(p, ima.domain());
+ mln_BKD_NITER_(n, neighb, p);
+ mln_BKD_QITER_(q, win, p);
+ }
+
+ util::array<point2d> arr;
+ {
+ mln_EITER_(e, arr);
+ }
+ {
+ mln_FWD_EITER_(e, arr);
+ }
+ {
+ mln_BKD_EITER_(e, arr);
+ }
+
+ histo::data<bool> d;
+ {
+ mln_VITER_(v, d.vset());
+ }
+ {
+ mln_FWD_VITER_(v, d.vset());
+ }
+ {
+ mln_BKD_VITER_(v, d.vset());
+ }
+}
+
+int main()
+{
+ test();
+ test_template<int>();
+}
--
1.5.6.5