Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
add point implementation for Iterator_On_Points.
* olena/tests/core/iter_point1d.cc, olena/tests/core/iter_point2d.cc: New.
* olena/tests/core/iter_point3d.cc: New test file.
* olena/tests/core/Makefile.am: Add new tests in make check.
* olena/oln/core/internal/iterator_on_points_impl.hh: New, implementations for
Iterator_On_Points.
* olena/oln/core/internal/iterator_on_points_base.hh: Now derive from
itertor_on_points_impl
oln/core/internal/iterator_on_points_base.hh | 10 +
oln/core/internal/iterator_on_points_impl.hh | 141 +++++++++++++++++++++++++++
tests/core/Makefile.am | 6 +
tests/core/iter_point1d.cc | 48 +++++++++
tests/core/iter_point2d.cc | 50 +++++++++
tests/core/iter_point3d.cc | 52 +++++++++
6 files changed, 305 insertions(+), 2 deletions(-)
Index: olena/tests/core/iter_point1d.cc
--- olena/tests/core/iter_point1d.cc (revision 0)
+++ olena/tests/core/iter_point1d.cc (revision 0)
@@ -0,0 +1,48 @@
+// 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.
+
+#include <cassert>
+
+#include <oln/core/1d/image1d.hh>
+#include <oln/core/internal/iterator_on_points_base.hh>
+
+
+
+int
+main()
+{
+
+ oln::image1d<int> ima1(40);
+ oln::image1d<int>::piter p (ima1.points());
+ oln::point1d p1;
+
+ for (p.start(); p.is_valid(); p.next())
+ p1.ind() = p.ind();
+
+ assert(p1.ind() == 39);
+ return 0;
+}
Index: olena/tests/core/iter_point2d.cc
--- olena/tests/core/iter_point2d.cc (revision 0)
+++ olena/tests/core/iter_point2d.cc (revision 0)
@@ -0,0 +1,50 @@
+// 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.
+
+#include <cassert>
+
+#include <oln/core/2d/image2d.hh>
+
+int
+main()
+{
+
+ oln::image2d<int> ima1(40, 30);
+ oln::image2d<int>::piter p (ima1.points());
+ oln::point2d p1;
+
+ for (p.start(); p.is_valid(); p.next())
+ {
+ p1.row() = p.row();
+ p1.col() = p.col();
+ }
+
+ assert(p1.row() == 39);
+ assert(p1.col() == 29);
+
+ return 0;
+}
Index: olena/tests/core/iter_point3d.cc
--- olena/tests/core/iter_point3d.cc (revision 0)
+++ olena/tests/core/iter_point3d.cc (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.
+
+#include <cassert>
+
+#include <oln/core/3d/image3d.hh>
+
+int
+main()
+{
+
+ oln::image3d<int> ima1(40, 30, 20);
+ oln::image3d<int>::piter p (ima1.points());
+ oln::point3d p1;
+
+ for (p.start(); p.is_valid(); p.next())
+ {
+ p1.row() = p.row();
+ p1.col() = p.col();
+ p1.slice() = p.slice();
+ }
+
+ assert(p1.row() == 39);
+ assert(p1.col() == 29);
+ assert(p1.slice() == 19);
+
+ return 0;
+}
Index: olena/tests/core/Makefile.am
--- olena/tests/core/Makefile.am (revision 923)
+++ olena/tests/core/Makefile.am (working copy)
@@ -25,6 +25,9 @@
grid \
image1d \
image2d \
+ iter_point1d \
+ iter_point2d \
+ iter_point3d \
neighb2d \
npoints \
point2d \
@@ -40,6 +43,9 @@
grid_SOURCES = grid.cc
image1d_SOURCES = image1d.cc
image2d_SOURCES = image2d.cc
+iter_point1d_SOURCES = iter_point1d.cc
+iter_point2d_SOURCES = iter_point2d.cc
+iter_point3d_SOURCES = iter_point3d.cc
neighb2d_SOURCES = neighb2d.cc
npoints_SOURCES = npoints.cc
point2d_SOURCES = point2d.cc
Index: olena/oln/core/internal/iterator_on_points_impl.hh
--- olena/oln/core/internal/iterator_on_points_impl.hh (revision 0)
+++ olena/oln/core/internal/iterator_on_points_impl.hh (revision 0)
@@ -0,0 +1,141 @@
+// 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 OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_IMPL_HH
+# define OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_IMPL_HH
+
+
+namespace oln
+{
+
+ // Forward declarations
+ namespace impl
+ {
+ template <unsigned n, typename Exact, typename P>
+ struct iterator_on_points_impl;
+ }
+
+
+ template <unsigned n, typename Exact, typename P>
+ struct super_trait_< impl::iterator_on_points_impl<n, Exact, P> >
+ {
+ typedef Any<P> ret;
+ };
+
+ template <unsigned n, typename Exact, typename P>
+ struct vtypes< impl::iterator_on_points_impl<n, Exact, P> >
+ {
+ };
+
+
+ namespace impl
+ {
+ template <unsigned n, typename Exact, typename P>
+ struct iterator_on_points_impl : public virtual Any<Exact>
+ {
+ };
+
+ /// point1d interface
+ template <typename Exact, typename P>
+ struct iterator_on_points_impl<1, Exact, P> : public virtual Any< Exact
>
+ {
+ typename P::coord ind() const;
+ };
+
+ /// point2d interface
+ template <typename Exact, typename P>
+ struct iterator_on_points_impl<2, Exact, P>: public virtual Any< Exact >
+ {
+ typename P::coord row() const;
+ typename P::coord col() const;
+ };
+
+ /// point3d interface
+ template <typename Exact, typename P>
+ struct iterator_on_points_impl<3, Exact, P>: public virtual Any< Exact >
+ {
+ typename P::coord row() const;
+ typename P::coord col() const;
+ typename P::coord slice() const;
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // point1d
+ template <typename Exact, typename P>
+ typename P::coord
+ iterator_on_points_impl<1, Exact, P>::ind() const
+ {
+ return exact(this)->to_point().ind();
+ }
+
+ // point2d
+ template <typename Exact, typename P>
+ typename P::coord
+ iterator_on_points_impl<2, Exact, P>::row() const
+ {
+ return exact(this)->to_point().row();
+ }
+
+
+ template <typename Exact, typename P>
+ typename P::coord
+ iterator_on_points_impl<2, Exact, P>::col() const
+ {
+ return exact(this)->to_point().col();
+ }
+
+ // point3d
+ template <typename Exact, typename P>
+ typename P::coord
+ iterator_on_points_impl<3, Exact, P>::row() const
+ {
+ return exact(this)->to_point().row();
+ }
+
+ template <typename Exact, typename P>
+ typename P::coord
+ iterator_on_points_impl<3, Exact, P>::col() const
+ {
+ return exact(this)->to_point().col();
+ }
+
+ template <typename Exact, typename P>
+ typename P::coord
+ iterator_on_points_impl<3, Exact, P>::slice() const
+ {
+ return exact(this)->to_point().slice();
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+ } // end of namespace oln
+
+} // end of namespace oln
+
+#endif // ! OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_IMPL_HH
Index: olena/oln/core/internal/iterator_on_points_base.hh
--- olena/oln/core/internal/iterator_on_points_base.hh (revision 923)
+++ olena/oln/core/internal/iterator_on_points_base.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_CORE_INTERNAL_ITERATOR_ON_POINTS_BASE_HH
# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/internal/iterator_on_points_impl.hh>
namespace oln
@@ -57,15 +58,20 @@
typedef stc::final< oln_coord(point__) > coord;
typedef stc::final< oln_dim(point__) > dim;
typedef stc::final< oln_dpoint(point__) > dpoint;
- };
+ // for getting point implementation
+ typedef stc_deferred(dim) dim__;
+ };
namespace internal
{
template <typename Exact>
- class iterator_on_points_base_ : public Iterator_on_Points<Exact>
+ class iterator_on_points_base_ : public Iterator_on_Points<Exact>,
+ public impl::iterator_on_points_impl
+ <mlc_value(typename vtypes< internal::iterator_on_points_base_<Exact>
>::dim__),
+ Exact, typename vtypes< internal::iterator_on_points_base_<Exact>
>::point__>
{
protected:
iterator_on_points_base_();