2006-09-07 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add image2d and fix topo-related classes.
* olena/tests/npoints.cc: New.
* olena/tests/Makefile.am: Update.
* olena/oln/core/image_entry.hh: New.
* olena/oln/core/2d/image2d.hh: New.
* olena/oln/basics2d.hh: Force instantiation and include
oln/core/2d/image2d.hh.
* olena/oln/core/typedefs.hh: Include mlc/assert.hh and
mlc/to_string.hh.
(piter_type): Uncomment.
(rvalue_type): New.
(psite_type): New.
(concrete_type): Uncomment.
(size_type): Add comment.
(topo_type): New.
* olena/oln/core/abstract/topo.hh (bbox): Remove this method which
is redundant with the one of topo_with_bbox.
* olena/oln/core/abstract/topo_with_bbox.hh (bbox): Fix typo.
* olena/oln/core/abstract/entry.hh (next_entry_node): New
specialization to handle the specific and rare case of having no
sub-hierarchy.
* olena/oln/core/abstract/topo_ra.hh: Fix cut n paste errors.
* olena/oln/core/abstract/pset.hh (piter): New vtype decl.
* olena/oln/core/gen/fwd_piter.hh (fwd_piter_): Add commented
forthcoming ctors.
* olena/oln/core/gen/bbox_topo.hh: Cosmetics.
* olena/oln/core/pset_entry.hh (piter_type): New.
* olena/oln/core/abstract/image.hh: Update.
Index: tests/Makefile.am
===================================================================
--- tests/Makefile.am (revision 526)
+++ tests/Makefile.am (working copy)
@@ -11,9 +11,11 @@
check_PROGRAMS = \
grid \
- image_entry
+ image_entry \
+ npoints
+grid_SOURCES = grid.cc
image_entry_SOURCES = image_entry.cc
-grid_SOURCES = grid.cc
+npoints_SOURCES = npoints.cc
TESTS = $(check_PROGRAMS)
Index: tests/npoints.cc
===================================================================
--- tests/npoints.cc (revision 0)
+++ tests/npoints.cc (revision 0)
@@ -0,0 +1,50 @@
+// Copyright (C) 2006 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.
+
+/// Test image2d.
+
+#include <cassert>
+#include <oln/basics2d.hh>
+
+
+template <typename I>
+unsigned npoints(const oln::abstract::image<I>& input)
+{
+ oln_type_of(I, piter) p(input.topo());
+ unsigned count = 0;
+ for_all(p)
+ ++count;
+ return count;
+}
+
+
+int
+main()
+{
+ oln::image2d<int> ima(3, 17);
+ assert(npoints(ima) == 51);
+}
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 526)
+++ oln/core/typedefs.hh (working copy)
@@ -30,12 +30,14 @@
# include <iostream>
+# include <mlc/assert.hh>
# include <mlc/contract.hh>
# include <mlc/flags.hh>
# include <mlc/is_a.hh>
# include <mlc/cmp.hh>
# include <mlc/typedef.hh>
# include <mlc/value.hh>
+# include <mlc/to_string.hh>
# include <stc/any.hh>
# include <stc/exact.hh>
@@ -95,7 +97,7 @@
// mlc_decl_typedef(fwd_iter_type);
// mlc_decl_typedef(bkd_iter_type);
-// mlc_decl_typedef(piter_type);
+ mlc_decl_typedef(piter_type);
mlc_decl_typedef(fwd_piter_type);
mlc_decl_typedef(bkd_piter_type);
@@ -128,6 +130,7 @@
// mlc_decl_typedef(data_type);
// --------------------------------------------------------------------
mlc_decl_typedef(value_type);
+ mlc_decl_typedef(rvalue_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
@@ -135,17 +138,19 @@
// mlc_decl_typedef(value_storage_type);
// mlc_decl_typedef(storage_type);
// --------------------------------------------------------------------
+ mlc_decl_typedef(psite_type);
mlc_decl_typedef(point_type);
mlc_decl_typedef(dpoint_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(image_type);
-// mlc_decl_typedef(concrete_type);
// --------------------------------------------------------------------
+ mlc_decl_typedef(concrete_type);
mlc_decl_typedef(delegated_type);
- mlc_decl_typedef(size_type);
+ mlc_decl_typedef(size_type); // FIXME: To be removed.
+ mlc_decl_typedef(topo_type);
mlc_decl_typedef(bbox_type);
// --------------------------------------------------------------------
// FIXME: To be enabled later.
Index: oln/core/image_entry.hh
===================================================================
--- oln/core/image_entry.hh (revision 0)
+++ oln/core/image_entry.hh (revision 0)
@@ -0,0 +1,97 @@
+// Copyright (C) 2006 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 OLENA_CORE_IMAGE_ENTRY_HH
+# define OLENA_CORE_IMAGE_ENTRY_HH
+
+# include <oln/core/abstract/entry.hh>
+# include <oln/core/abstract/image.hh>
+
+
+
+namespace oln
+{
+
+
+ /// Entry class for point sets: image_entry<E> is an alias for
+ /// entry< abstract::image, E>.
+
+ template <typename E>
+ struct image_entry : public entry< abstract::image, E>
+ {
+ protected:
+ image_entry() {}
+ };
+
+
+ /// Virtual types associated to image_entry<E>.
+
+ template <typename E>
+ struct vtypes< image_entry<E> >
+ {
+ typedef mlc::undefined topo_type;
+ typedef mlc::undefined grid_type;
+
+ // psite_type: see below
+ typedef mlc::undefined point_type;
+
+ // piter_type: see below
+ typedef mlc::undefined fwd_piter_type;
+ typedef mlc::undefined bkd_piter_type;
+
+ typedef mlc::undefined value_type;
+ // rvalue_type: see below
+
+ typedef mlc::undefined concrete_type;
+ };
+
+
+ template <typename E>
+ struct single_vtype< image_entry<E>, typedef_::psite_type >
+ {
+ typedef oln_type_of(E, point) ret;
+ };
+
+
+ template <typename E>
+ struct single_vtype< image_entry<E>, typedef_::piter_type >
+ {
+ typedef oln_type_of(E, fwd_piter) ret;
+ };
+
+
+ template <typename E>
+ struct single_vtype< image_entry<E>, typedef_::rvalue_type >
+ {
+ typedef oln_type_of(E, value) ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_IMAGE_ENTRY_HH
Index: oln/core/abstract/topo.hh
===================================================================
--- oln/core/abstract/topo.hh (revision 526)
+++ oln/core/abstract/topo.hh (working copy)
@@ -54,16 +54,11 @@
decl() {
// constraint:
- mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >,
- mlc_is_a(bbox, abstract::bbox) > >::check();
+// mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >,
+// mlc_is_a(bbox, abstract::bbox) > >::check();
}
};
- const oln_type_of(E, bbox)& bbox() const
- {
- return this->exact().impl_bbox();
- }
-
protected:
topo()
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 526)
+++ oln/core/abstract/image.hh (working copy)
@@ -29,216 +29,11 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_HH
# define OLENA_CORE_ABSTRACT_IMAGE_HH
-# include <mlc/assert.hh>
-# include <mlc/cmp.hh>
-# include <mlc/to_string.hh>
-# include <oln/core/abstract/internal/image_impl.hh>
+# include <oln/core/typedefs.hh>
+// # include <oln/core/abstract/internal/image_impl.hh>
-namespace oln {
- // Forward declaration.
- template <typename I>
- class value_box;
-
- // Forward declarations.
- namespace abstract
- {
- template <typename I> class image;
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// template <typename I> class image_without_nbh;
-// template <typename I> class readonly_image;
-// template <typename I> class raw_image;
-// template <typename P> class point;
-// --------------------------------------------------------------------
- }
-
- /// Virtual types associated to oln::abstract::image.
- template <typename I>
- struct vtypes_in_category< category::image, abstract::image<I> >
- {
- typedef I exact_type;
-
- typedef mlc::undefined grid_type;
-
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// typedef mlc::undefined concrete_type;
-// --------------------------------------------------------------------
- typedef mlc::undefined value_type;
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// typedef mlc::undefined point_type;
-// typedef mlc::undefined size_type;
-
-// typedef mlc::undefined piter_type;
-// typedef mlc::undefined fwd_piter_type;
-// typedef mlc::undefined bkd_piter_type;
-
-// typedef mlc::none value_storage_type;
-// typedef mlc::none storage_type;
-// --------------------------------------------------------------------
- typedef mlc::none delegated_type;
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// typedef mlc::none neighb_type;
-
-// typedef is_a<abstract::image_without_nbh> image_neighbness_type;
-// typedef is_a<abstract::readonly_image> image_constness_type;
-// typedef mlc::undefined image_rawness_type;
-// --------------------------------------------------------------------
- };
-
- /// Packing of the virtual types of any image class.
- template <typename I>
- struct packed_vtypes_in_category<category::image, I>
- {
- /// Virtual types defined internally.
- /// \{
- typedef oln_type_of(I, exact) exact_type;
-
- typedef oln_type_of(I, grid) grid_type;
-
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// typedef oln_type_of(I, concrete) concrete_type;
-// --------------------------------------------------------------------
- typedef oln_type_of(I, value) value_type;
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// typedef oln_type_of(I, point) point_type;
-// typedef oln_type_of(I, size) size_type;
-
-// typedef oln_type_of(I, piter) piter_type;
-// typedef oln_type_of(I, fwd_piter) fwd_piter_type;
-// typedef oln_type_of(I, bkd_piter) bkd_piter_type;
-
-// typedef oln_type_of(I, value_storage) value_storage_type;
-// typedef oln_type_of(I, storage) storage_type;
-// --------------------------------------------------------------------
- typedef oln_type_of(I, delegated) delegated_type;
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// typedef oln_type_of(I, neighb) neighb_type;
-
-
-// typedef oln_type_of(I, image_neighbness) image_neighbness_type;
-// typedef oln_type_of(I, image_constness) image_constness_type;
-// typedef oln_type_of(I, image_rawness) image_rawness_type;
-// --------------------------------------------------------------------
- /// \}
-
- /// Virtual types defined as extensions.
- /// \{
- typedef oln_type_of(I, image_dimension) image_dimension_type;
- typedef oln_type_of(I, image_typeness) image_typeness_type;
- /// \}
-
- /// Pretty-printing.
- static void echo(std::ostream& ostr)
- {
- ostr
- << "vtypes_in_category(oln::category::image, "
- << mlc_to_string(I) << ") ="
- << std::endl
- << "{" << std::endl
- << " exact_type = " << mlc_to_string(exact_type) <<
std::endl
-
- << " grid_type = " << mlc_to_string(grid_type) <<
std::endl
-
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// << " concrete_type = " << mlc_to_string(concrete_type)
<< std::endl
-// --------------------------------------------------------------------
- << " value_type = " << mlc_to_string(value_type) <<
std::endl
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// << " point_type = " << mlc_to_string(point_type) <<
std::endl
-// << " size_type = " << mlc_to_string(size_type) <<
std::endl
-
-// << " piter_type = " << mlc_to_string(piter_type) <<
std::endl
-// << " fwd_piter_type = " << mlc_to_string(fwd_piter_type)
<< std::endl
-// << " bkd_piter_type = " << mlc_to_string(bkd_piter_type)
<< std::endl
-
-// << " value_storage_type = " <<
mlc_to_string(value_storage_type) << std::endl
-// << " storage_type = " << mlc_to_string(storage_type) <<
std::endl
-// ---------------------------------------------------------------------
- << " delegated_type = " << mlc_to_string(delegated_type) <<
std::endl
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// << " neighb_type = " << mlc_to_string(neighb_type) <<
std::endl
-
-// << " image_neighbness_type = " <<
mlc_to_string(image_neighbness_type) << std::endl
-// << " image_constness_type = " <<
mlc_to_string(image_constness_type) << std::endl
-// << " image_rawness_type = " <<
mlc_to_string(image_rawness_type) << std::endl
-// --------------------------------------------------------------------
- << " image_dimension_type = " <<
mlc_to_string(image_dimension_type)
- << std::endl
- << " image_typeness_type = " <<
mlc_to_string(image_typeness_type)
- << std::endl
- << "}" << std::endl;
- }
-
- static void ensure()
- {
- mlc::assert_< mlc_is_ok(exact_type) >::check();
-
- mlc::assert_< mlc_is_ok(grid_type) >::check();
-
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// mlc::assert_< mlc_is_ok(concrete_type) >::check();
-// --------------------------------------------------------------------
- mlc::assert_< mlc_is_ok(value_type) >::check();
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// mlc::assert_< mlc_is_ok(point_type) >::check();
-// mlc::assert_< mlc_is_ok(size_type) >::check();
-// mlc::assert_< mlc_is_ok(piter_type) >::check();
-// mlc::assert_< mlc_is_ok(fwd_piter_type) >::check();
-// mlc::assert_< mlc_is_ok(bkd_piter_type) >::check();
-
-// mlc::assert_< mlc_is_ok(value_storage_type) >::check();
-// mlc::assert_< mlc_is_ok(storage_type) >::check();
-// --------------------------------------------------------------------
- mlc::assert_< mlc_is_ok(delegated_type) >::check();
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// mlc::assert_< mlc_is_ok(neighb_type) >::check();
-
-// mlc::assert_< mlc_is_ok(image_neighbness_type) >::check();
-// mlc::assert_< mlc_is_ok(image_constness_type) >::check();
-// mlc::assert_< mlc_is_ok(image_rawness_type) >::check();
-// --------------------------------------------------------------------
- mlc::assert_< mlc_is_ok(image_dimension_type) >::check();
- mlc::assert_< mlc_is_ok(image_typeness_type) >::check();
- }
- };
-
-} // end of namespace oln
-
-
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// # include <oln/core/gen/internal/value_box.hh>
-// --------------------------------------------------------------------
-
-
namespace oln
{
@@ -259,359 +54,106 @@
template <typename E>
- struct image : public internal::get_image_impl < image<E>, E >
+ struct image : public virtual stc::any__simple<E>,
+ public virtual oln::type
+ // , public internal::get_image_impl < image<E>, E >
{
- /// Typedefs.
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// typedef oln_type_of(E, size) size_type;
-// --------------------------------------------------------------------
- typedef oln_type_of(E, value) value_type;
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// typedef oln_type_of(E, point) point_type;
-// --------------------------------------------------------------------
+ public:
- /*------------------*
- ! abstract methods !
- *------------------*/
+ struct decl {
+ stc_virtual_typedef(topo);
+ stc_virtual_typedef(grid);
- /*! \brief Return the size of the current image. Nota bene:
- ** this method is abstract-like.it is a pseudo-abstract method.
- **
- ** \return An object deriving from abstract::size. Ex: if the
- ** image is an image2d<something>, the returned object is a
- ** size2d.
- */
+ stc_virtual_typedef(psite);
+ stc_virtual_typedef(point);
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// const size_type& size() const
-// {
-// return this->exact().impl_size();
-// }
-// --------------------------------------------------------------------
+ stc_virtual_typedef(piter);
+ stc_virtual_typedef(fwd_piter);
+ stc_virtual_typedef(bkd_piter);
+ stc_virtual_typedef(value);
+ stc_virtual_typedef(rvalue);
- /*! \brief Return the number of points of the current image.
- ** Nota bene: this method is abstract-like.
- **
- ** FIXME: this method should be deferred in an abstract subclass
- ** since its complexity can vary from a concrete image to another...
- **
- ** \return A positive value. It can be 0 when the image size is
- ** not yet defined; ex: image2d<int> ima; cout << ima.npoints();
- */
+ stc_virtual_typedef(concrete);
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// unsigned long npoints() const
-// {
-// return this->exact().impl_npoints();
-// }
-// --------------------------------------------------------------------
+ decl() {
+ // FIXME: ...
+ }
+ };
- /*! \brief Test if the point \a p belongs to the current image.
- ** Please note that a point of the outer boundary of an image
- ** does NOT belong to the image. Nota bene: this method is
- ** abstract-like.
- **
- ** \return True if p belongs to the current image, false otherwise.
- **
- ** \see hold_large
- */
+ private:
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// bool hold(const point_type& p) const; // impl is in box.hh
-// --------------------------------------------------------------------
+ /// Typedefs.
+ typedef oln_type_of(E, topo) topo_t;
+ typedef oln_type_of(E, psite) psite_t;
+ typedef oln_type_of(E, rvalue) rvalue_t;
- /*! \brief Test if \a p is a proper point to access a value of
- ** the current image. When an image has an outer boundary, the
- ** points of this boundary have values and these values can be
- ** accessed. Nota bene: this method is polymorphic so it can be
- ** overriden in derived classes; by default, hold_large behaves
- ** like hold.
- **
- ** FIXME: hold_large should come only for images WITH a border!
- **
- ** \return True if (*this)[p] is ok, false otherwise.
- **
- ** \see hold
- */
+ public:
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// bool hold_large(const point_type& p) const
-// {
-// precondition(this->npoints() != 0);
-// return this->exact().impl_hold_large(p);
-// }
-// --------------------------------------------------------------------
-
-
- /*! \brief Default implementation for hold_large. If not
- ** overriden in derived class, it just calls hold(p).
- **
- ** FIXME: hold_large should come only for images WITH a border!
- **
- ** \return True if (*this)[p] is ok, false otherwise.
- **
- ** \see hold_large
- */
-
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// bool impl_hold_large(const point_type& p) const
-// {
-// // it relies on 'impl_hold' to avoid counting one call to
-// // 'hold' when the effective call is 'hold_large'
-// return this->exact().impl_hold(p);
-// }
-// --------------------------------------------------------------------
-
-
-
/*------------------*
- ! concrete methods !
+ ! abstract methods !
*------------------*/
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// template <typename P>
-// void operator()(const oln::abstract::point<P>&) const
-// {
-// // FIXME: provide an explicit err msg, e.g., "(p) should not be used on an
ima"
-// }
-// --------------------------------------------------------------------
-
- /*! \brief Give access to the value stored at \a p in the
- ** current image. Precisely it returns a box that encloses this
- ** value. FIXME: say more about that box!
+ /*! \brief Return the topological information about the current
+ ** image. Nota bene: this method is abstract-like.it is a
+ ** pseudo-abstract method.
**
- ** \precondition this->hold_large(p)
- **
- ** \see value_box
+ ** \return An object deriving from abstract::topo. Ex: if the
+ ** image is an image2d<something>, the returned object is a
+ ** topo2d.
*/
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// value_box<const E> operator[](const point_type& p) const
-// {
-// precondition(this->npoints() != 0);
-// precondition(this->hold_large(p));
-// value_box<const E> tmp(this->exact(), p);
-// return tmp;
-// }
-// --------------------------------------------------------------------
+ const topo_t& topo() const
+ {
+ return this->exact().impl_topo();
+ }
/*! \brief Gives access to the value stored at \a p in the
- ** current image. Precisely it returns a box that encloses this
- ** value.
- **
- ** \precondition this->hold_large(p)
- **
- ** \see value_box
+ ** current image.
*/
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// value_box<E> operator[](const point_type& p)
-// {
-// precondition(this->npoints() != 0);
-// precondition(this->hold_large(p));
-// value_box<E> tmp(this->exact(), p);
-// return tmp;
-// }
-// --------------------------------------------------------------------
-
-
- /*! \brief Destructor.
- */
-
- virtual ~image()
+ rvalue_t operator()(const psite_t& p) const
{
- packed_vtypes_in_category<category::image, E>::ensure();
- // FIXME: static check fails because "pointer to member conversion via virtual
base"...
-// mlc_check_method_impl(E, const size_type&, size, ,
const);
-// mlc_check_method_impl(E, unsigned long, npoints, , const);
-// mlc_check_method_impl(E, bool, hold, const point_type&,
const);
-// mlc_check_method_impl(E, bool, hold_large, const point_type&,
const);
-// mlc_check_method_impl(E, const value_type, get, const point_type&,
const);
-// mlc_check_method_impl_2(E, void, resize_border, size_t, bool, const);
+ return this->exact().impl_op_read(p);
}
-
- // explanation:
- // ------------
- // though it works (uncommented) with g++-3.3, it is commented
- // for bwd compatibility purpose because of g++-2.95 that does not accept
- // "partial specialization declared friend"...
- /*
- friend class oln::value_box<E>;
- friend class oln::value_box<const E>;
- private:
- */
-
- /*! \brief Read-only access to the value stored at \a p in the
- ** current image. This method is used in value_box<I>. Client
- ** should not use this method but
- ** abstract::image<I>::operator[](point) instead.
+ /*! \brief Test if the point \a p belongs to the current image.
+ ** Please note that a point of the outer boundary of an image
+ ** does NOT belong to the image.
**
- ** \return The value stored at \a p.
+ ** \return True if p belongs to the current image, false otherwise.
**
- ** \see value_box, abstract::image<I>::operator[](point)
+ ** \see hold_large
*/
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// const value_type get(const point_type& p) const; // impl is in box.hh
-// --------------------------------------------------------------------
+ bool has(const psite_t& p) const
+ {
+ return this->exact().impl_has(p);
+ }
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-
- // FIXME: patch!
-// void resize_border(size_t new_border, bool copy_border = false) const
-// {
-// this->exact().impl_resize_border(new_border, copy_border);
-// }
-// --------------------------------------------------------------------
-
protected:
/*! \brief Constructor (protected, empty).
*/
image() {}
- /*! \brief Cpy constructor (protected, empty).
+ /*! \brief Destructor.
*/
- image(const image&) {}
+ virtual ~image() { decl(); }
- /*! \brief Op= (protected, empty).
- */
- void operator=(const image&) {}
};
-
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// /*! \namespace oln::abstract::internal
-// ** \brief oln::abstract::internal namespace.
-// */
-// namespace internal {
-
-// template <typename E>
-// struct set_image_impl < image<E>, E > : public virtual
image_impl<E>
-// {
-
-// /// typedefs
-
-// typedef typename image_impl<E>::D D;
-
-// typedef oln_type_of(D, size) size_type;
-// typedef oln_type_of(D, point) point_type;
-// typedef oln_type_of(D, value) value_type;
-
-// // delegations are "template methods" (Cf. the GOF's book)
-
-// const size_type& impl_size() const
-// {
-// const size_type& s = this->delegate().size();
-// this->exact().impl_size_extra(s);
-// return s;
-// }
-
-// unsigned long impl_npoints() const
-// {
-// unsigned long n = this->delegate().npoints();
-// this->exact().impl_npoints_extra(n);
-// return n;
-// }
-
-// bool impl_hold(const point_type& p) const
-// {
-// this->exact().impl_hold_extra(p);
-// return this->delegate().hold(p);
-// }
-
-// bool impl_hold_large(const point_type& p) const
-// {
-// this->exact().impl_hold_large_extra(p);
-// return this->delegate().hold_large(p);
-// }
-
-// value_box<const D> operator[](const point_type& p) const
-// {
-// precondition(this->hold_large(p));
-// return this->delegate().operator[](p);
-// }
-
-// value_box<D> operator[](const point_type& p)
-// {
-// precondition(this->hold_large(p));
-// return this->delegate().operator[](p);
-// }
-
-// const value_type impl_get(const point_type& p) const
-// {
-// this->exact().impl_get_extra(p);
-// return this->delegate().get(p);
-// }
-
-// // FIXME: patch
-
-// void impl_resize_border(size_t new_border, bool copy_border) const
-// {
-// this->delegate().impl_resize_border(new_border, copy_border);
-// }
-
-// // extra code; default is "do nothing"
-
-// void impl_size_extra(const size_type& s) const {}
-// void impl_npoints_extra(unsigned long n) const {}
-
-// void impl_hold_extra(const point_type& p) const {}
-// void impl_hold_large_extra(const point_type& p) const {}
-
-// void impl_get_extra(const point_type&) const {}
-// };
-
-// } // end of namespace oln::abstract::internal
-// --------------------------------------------------------------------
-
} // end of namespace oln::abstract
} // end of namespace oln
-// --------------------------------------------------------------------
-// FIXME: To be enabled later.
-// --------------------------------------------------------------------
-// # include <oln/core/abstract/piter.hh>
-// --------------------------------------------------------------------
-// this allows for browsing points in file
-// where oln/core/abstract/image.hh is included
-
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_HH
Index: oln/core/abstract/topo_with_bbox.hh
===================================================================
--- oln/core/abstract/topo_with_bbox.hh (revision 526)
+++ oln/core/abstract/topo_with_bbox.hh (working copy)
@@ -48,7 +48,7 @@
// abstract
const bbox_t& bbox() const
{
- return this->exact().impl_box();
+ return this->exact().impl_bbox();
}
// concrete
Index: oln/core/abstract/entry.hh
===================================================================
--- oln/core/abstract/entry.hh (revision 526)
+++ oln/core/abstract/entry.hh (working copy)
@@ -57,7 +57,16 @@
// here: no other hierarchy
};
+
template < template <class> class abstraction,
+ typename E >
+ struct next_entry_node < abstraction, E, 1, mlc::false_ >
+ : public abstraction<E>
+ {
+ };
+
+
+ template < template <class> class abstraction,
typename E,
unsigned num >
struct next_entry_node < abstraction,
Index: oln/core/abstract/topo_ra.hh
===================================================================
--- oln/core/abstract/topo_ra.hh (revision 526)
+++ oln/core/abstract/topo_ra.hh (working copy)
@@ -25,10 +25,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_CORE_ABSTRACT_PSET_RA_HH
-# define OLENA_CORE_ABSTRACT_PSET_RA_HH
+#ifndef OLENA_CORE_ABSTRACT_TOPO_RA_HH
+# define OLENA_CORE_ABSTRACT_TOPO_RA_HH
-# include <oln/core/abstract/pset.hh>
+# include <oln/core/abstract/topo.hh>
@@ -40,7 +40,7 @@
template <typename E>
- class ra_pset : public virtual pset<E>
+ class ra_topo : public virtual topo<E>
{
typedef oln_type_of(E, point) point_t;
@@ -52,7 +52,7 @@
}
protected:
- ra_pset()
+ ra_topo()
{}
};
@@ -61,14 +61,14 @@
template <typename E>
- struct case_ < pset_ra_hierarchy, E, 1 >
+ struct case_ < topo_ra_hierarchy, E, 1 >
: where_< mlc::eq_< oln_type_of(E, ra), mlc::true_ > >
{
- typedef abstract::ra_pset<E> ret;
+ typedef abstract::ra_topo<E> ret;
};
} // end of namespace oln
-#endif // ! OLENA_CORE_ABSTRACT_PSET_RA_HH
+#endif // ! OLENA_CORE_ABSTRACT_TOPO_RA_HH
Index: oln/core/abstract/pset.hh
===================================================================
--- oln/core/abstract/pset.hh (revision 526)
+++ oln/core/abstract/pset.hh (working copy)
@@ -53,6 +53,8 @@
struct decl
{
stc_virtual_typedef(point);
+
+ stc_virtual_typedef(piter);
stc_virtual_typedef(fwd_piter);
stc_virtual_typedef(bkd_piter);
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 0)
+++ oln/core/2d/image2d.hh (revision 0)
@@ -0,0 +1,107 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2006 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 OLENA_CORE_2D_IMAGE2D_HH
+# define OLENA_CORE_2D_IMAGE2D_HH
+
+# include <oln/core/image_entry.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ template <typename T> class image2d;
+
+
+ /// Virtual types associated to oln::image2d<T>.
+ template <typename T>
+ struct vtypes< image2d<T> >
+ {
+ typedef topo2d topo_type;
+ typedef grid2d grid_type;
+
+ typedef point2d point_type;
+
+ typedef fwd_piter2d fwd_piter_type;
+ typedef bkd_piter2d bkd_piter_type;
+
+ typedef T value_type;
+
+ typedef image2d<T> real_type;
+ };
+
+
+ /// Super type declaration.
+ template <typename T>
+ struct set_super_type< image2d<T> >
+ {
+ typedef image2d<T> self_t;
+ typedef image_entry<self_t> ret;
+ };
+
+
+ /// General 2D image class.
+ template <typename T>
+ class image2d : public image_entry< image2d<T> >
+ {
+ typedef image2d<T> self_t;
+
+ public:
+
+ /// Ctor.
+ image2d(unsigned nrows, unsigned ncols)
+ : topo_( bbox2d( point2d(0,0), point2d(nrows-1, ncols-1) ) )
+ {
+ }
+
+ const topo2d& impl_topo() const
+ {
+ return topo_;
+ }
+
+ T impl_op_read(const point2d& p) const
+ {
+ static T val_;
+ return ++val_;
+ }
+
+ bool impl_has(const point2d& p) const
+ {
+ return true;
+ }
+
+ private:
+
+ topo2d topo_;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_2D_IMAGE2D_HH
Index: oln/core/gen/fwd_piter.hh
===================================================================
--- oln/core/gen/fwd_piter.hh (revision 526)
+++ oln/core/gen/fwd_piter.hh (working copy)
@@ -80,6 +80,23 @@
++nop_[0];
}
+// template <typename T>
+// fwd_piter_(const abstract::topo<T>& t)
+// {
+// mlc::assert_< mlc_is_a(T, abstract::topo_with_bbox) >::check();
+// bb_ = t.exact().bbox();
+// nop_ = bb_.pmax();
+// ++nop_[0];
+// }
+
+// template <typename Data>
+// fwd_piter_(const Data& data)
+// : bb_(data.bbox())
+// {
+// nop_ = bb_.pmax();
+// ++nop_[0];
+// }
+
const bbox_<point>& bbox() const
{
return bb_;
Index: oln/core/gen/bbox_topo.hh
===================================================================
--- oln/core/gen/bbox_topo.hh (revision 526)
+++ oln/core/gen/bbox_topo.hh (working copy)
@@ -28,8 +28,8 @@
#ifndef OLENA_CORE_GEN_BBOX_TOPO_HH
# define OLENA_CORE_GEN_BBOX_TOPO_HH
+# include <oln/core/gen/bbox.hh>
# include <oln/core/topo_entry.hh>
-# include <oln/core/gen/bbox.hh>
Index: oln/core/pset_entry.hh
===================================================================
--- oln/core/pset_entry.hh (revision 526)
+++ oln/core/pset_entry.hh (working copy)
@@ -54,6 +54,8 @@
struct vtypes< pset_entry<E> >
{
typedef mlc::undefined point_type;
+
+ typedef mlc::undefined piter_type;
typedef mlc::undefined fwd_piter_type;
typedef mlc::undefined bkd_piter_type;
@@ -87,6 +89,13 @@
};
+ template <typename E>
+ struct single_vtype< pset_entry<E>, typedef_::piter_type >
+ {
+ typedef oln_type_of(E, fwd_piter) ret;
+ };
+
+
} // end of namespace oln
Index: oln/basics2d.hh
===================================================================
--- oln/basics2d.hh (revision 526)
+++ oln/basics2d.hh (working copy)
@@ -32,13 +32,25 @@
# include <oln/core/2d/aliases.hh>
# include <oln/core/2d/point2d.hh>
+namespace oln { template class point2d_<int>; }
+
# include <oln/core/2d/dpoint2d.hh>
+namespace oln { template class dpoint2d_<int>; }
# include <oln/core/gen/bbox.hh>
+namespace oln { template class bbox_<point2d>; }
+
# include <oln/core/gen/fwd_piter.hh>
+namespace oln { template class fwd_piter_<point2d>; }
+
# include <oln/core/gen/bkd_piter.hh>
+namespace oln { template class bkd_piter_<point2d>; }
# include <oln/core/gen/bbox_topo.hh>
+namespace oln { template class bbox_topo_<point2d>; }
+# include <oln/core/2d/image2d.hh>
+
+
#endif // ! OLENA_BASICS2D_HH