2006-09-25 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add morpher capabilities to topology classes.
* oln/automatic/topology_having_bbox.hh: New.
* oln/automatic/topology_being_random_accessible.hh: New.
* oln/automatic/topology_having_neighborhood.hh: New.
* oln/core/abstract/topology_having_neighborhood.hh: New.
* oln/core/gen/topo_add_nbh.hh: New.
* oln/core/internal/topology_morpher.hh: New.
* oln/automatic/image_having_neighborhood.hh: Fix typo in guards.
Fix comment.
Fix delegation code.
* oln/core/topology_entry.hh (neighborhood_type, morpher_type):
New.
* oln/core/abstract/topology_hierarchies.hh
(topology_hierarchy_wrt_neighborhood): New.
Update include.
* oln/core/abstract/topology_having_bbox.hh: Inherit from
automatic::impl.
* oln/core/abstract/topology_being_random_accessible.hh: Likewise.
* oln/core/abstract/topology.hh (neighborhood): New vtype.
Index: oln/automatic/topology_having_bbox.hh
===================================================================
--- oln/automatic/topology_having_bbox.hh (revision 0)
+++ oln/automatic/topology_having_bbox.hh (revision 0)
@@ -0,0 +1,74 @@
+// 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_AUTOMATIC_TOPOLOGY_HAVING_BBOX_HH
+# define OLENA_AUTOMATIC_TOPOLOGY_HAVING_BBOX_HH
+
+# include <oln/core/typedefs.hh>
+# include <oln/morpher/tags.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ namespace abstract
+ {
+ template <typename E> class topology_having_bbox;
+
+ } // end of namespace oln::abstract
+
+
+ namespace automatic
+ {
+
+ /// Implementation corresponding to the interface
+ /// oln::abstract::topology_having_bbox for an identity morpher.
+
+ template <typename E>
+ class impl< abstract::topology_having_bbox,
+ morpher::tag::identity,
+ E> :
+ public virtual stc::any__simple<E>
+ {
+ private:
+ typedef oln_type_of(E, bbox) bbox_t;
+
+ public:
+
+ const bbox_t& impl_bbox() const
+ {
+ return this->exact().delegate().bbox();
+ }
+
+ };
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+#endif // ! OLENA_AUTOMATIC_TOPOLOGY_HAVING_BBOX_HH
Index: oln/automatic/image_having_neighborhood.hh
===================================================================
--- oln/automatic/image_having_neighborhood.hh (revision 563)
+++ oln/automatic/image_having_neighborhood.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLENA_AUTOMATIC_IMAGE_HAVING_NEIGHBORDHOOD_HH
-# define OLENA_AUTOMATIC_IMAGE_HAVING_NEIGHBORDHOOD_HH
+#ifndef OLENA_AUTOMATIC_IMAGE_HAVING_NEIGHBORHOOD_HH
+# define OLENA_AUTOMATIC_IMAGE_HAVING_NEIGHBORHOOD_HH
# include <oln/core/typedefs.hh>
# include <oln/morpher/tags.hh>
@@ -45,7 +45,7 @@
namespace automatic
{
/// Implementation corresponding to the interface
- /// oln::abstract::image1d for an identity morpher.
+ /// oln::abstract::image_having_neighborhood for an identity morpher.
template <typename E>
class impl< abstract::image_having_neighborhood,
morpher::tag::identity,
@@ -59,7 +59,7 @@
/// Accessor delegation.
neighborhood_t impl_neighborhood() const
{
- return this->exact().delegate().impl_neighborhood();
+ return this->exact().delegate().neighborhood();
}
};
@@ -67,4 +67,4 @@
} // end of namespace oln
-#endif // ! OLENA_AUTOMATIC_IMAGE_HAVING_NEIGHBORDHOOD_HH
+#endif // ! OLENA_AUTOMATIC_IMAGE_HAVING_NEIGHBORHOOD_HH
Index: oln/automatic/topology_being_random_accessible.hh
===================================================================
--- oln/automatic/topology_being_random_accessible.hh (revision 0)
+++ oln/automatic/topology_being_random_accessible.hh (revision 0)
@@ -0,0 +1,79 @@
+// 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_AUTOMATIC_TOPOLOGY_BEING_RANDOM_ACCESSIBLE_HH
+# define OLENA_AUTOMATIC_TOPOLOGY_BEING_RANDOM_ACCESSIBLE_HH
+
+# include <oln/core/typedefs.hh>
+# include <oln/morpher/tags.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ namespace abstract
+ {
+ template <typename E> class topology_being_random_accessible;
+
+ } // end of namespace oln::abstract
+
+
+ namespace automatic
+ {
+
+ /// Implementation corresponding to the interface
+ /// oln::abstract::topology_being_random_accessible for an identity morpher.
+
+ template <typename E>
+ class impl< abstract::topology_being_random_accessible,
+ morpher::tag::identity,
+ E> :
+ public virtual stc::any__simple<E>
+ {
+ private:
+ typedef oln_type_of(E, point) point_t;
+
+ public:
+
+ bool impl_has(const point_t& p) const
+ {
+ return this->exact().delegate().has(p);
+ }
+
+ bool impl_has_large(const point_t& p) const
+ {
+ return this->exact().delegate().has_large(p);
+ }
+
+ };
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+#endif // ! OLENA_AUTOMATIC_TOPOLOGY_BEING_RANDOM_ACCESSIBLE_HH
Index: oln/automatic/topology_having_neighborhood.hh
===================================================================
--- oln/automatic/topology_having_neighborhood.hh (revision 0)
+++ oln/automatic/topology_having_neighborhood.hh (revision 0)
@@ -0,0 +1,74 @@
+// 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_AUTOMATIC_TOPOLOGY_HAVING_NEIGHBORHOOD_HH
+# define OLENA_AUTOMATIC_TOPOLOGY_HAVING_NEIGHBORHOOD_HH
+
+# include <oln/core/typedefs.hh>
+# include <oln/morpher/tags.hh>
+
+
+namespace oln
+{
+
+ // Forward declaration.
+ namespace abstract
+ {
+ template <typename E> class topology_having_neighborhood;
+
+ } // end of namespace oln::abstract
+
+
+ namespace automatic
+ {
+
+ /// Implementation corresponding to the interface
+ /// oln::abstract::topology_having_neighborhood for an identity morpher.
+
+ template <typename E>
+ class impl< abstract::topology_having_neighborhood,
+ morpher::tag::identity,
+ E> :
+ public virtual stc::any__simple<E>
+ {
+ private:
+ typedef oln_type_of(E, neighborhood) neighborhood_t;
+
+ public:
+
+ const neighborhood_t& impl_neighborhood() const
+ {
+ return this->exact().delegate().neighborhood();
+ }
+
+ };
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+#endif // ! OLENA_AUTOMATIC_TOPOLOGY_HAVING_NEIGHBORHOOD_HH
Index: oln/core/topology_entry.hh
===================================================================
--- oln/core/topology_entry.hh (revision 563)
+++ oln/core/topology_entry.hh (working copy)
@@ -55,11 +55,17 @@
{
typedef mlc::undefined point_type;
typedef mlc::undefined bbox_type;
-
+ typedef mlc::none neighborhood_type;
typedef mlc::undefined is_random_accessible_type;
};
+ template <typename E>
+ struct single_vtype< topology_entry<E>, typedef_::morpher_type >
+ {
+ typedef mlc::none ret;
+ };
+
} // end of namespace oln
Index: oln/core/abstract/topology_hierarchies.hh
===================================================================
--- oln/core/abstract/topology_hierarchies.hh (revision 563)
+++ oln/core/abstract/topology_hierarchies.hh (working copy)
@@ -36,6 +36,7 @@
typedef hierarchy< abstract::topology, 1 >
topology_hierarchy_wrt_accessibility;
typedef hierarchy< abstract::topology, 2 > topology_hierarchy_wrt_bbox;
+ typedef hierarchy< abstract::topology, 3 >
topology_hierarchy_wrt_neighborhood;
} // end of namespace oln
@@ -43,10 +44,13 @@
// Hierarchy 1: topology w.r.t. accessibility.
# include <oln/core/abstract/topology_being_random_accessible.hh>
-// Hierarchy 2: topology w.r.t. bbox.
+// Hierarchy 2: topology w.r.t. bounding box.
# include <oln/core/abstract/topology_having_bbox.hh>
+// Hierarchy 2: topology w.r.t. neighborhood.
+# include <oln/core/abstract/topology_having_neighborhood.hh>
+
#endif // ! OLENA_CORE_ABSTRACT_TOPOLOGY_HIERARCHIES_HH
Index: oln/core/abstract/topology_having_bbox.hh
===================================================================
--- oln/core/abstract/topology_having_bbox.hh (revision 563)
+++ oln/core/abstract/topology_having_bbox.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_CORE_ABSTRACT_TOPOLOGY_HAVING_BBOX_HH
# include <oln/core/abstract/topology.hh>
+# include <oln/automatic/topology_having_bbox.hh>
namespace oln
@@ -39,7 +40,11 @@
template <typename E>
- class topology_having_bbox : public virtual topology<E>
+ class topology_having_bbox
+ : public virtual topology<E>,
+ public automatic::impl< topology_having_bbox,
+ oln_type_of(E, morpher),
+ E >
{
typedef oln_type_of(E, bbox) bbox_t;
Index: oln/core/abstract/topology_being_random_accessible.hh
===================================================================
--- oln/core/abstract/topology_being_random_accessible.hh (revision 563)
+++ oln/core/abstract/topology_being_random_accessible.hh (working copy)
@@ -29,6 +29,7 @@
# define OLENA_CORE_ABSTRACT_TOPOLOGY_BEING_RANDOM_ACCESSIBLE_HH
# include <oln/core/abstract/topology.hh>
+# include <oln/automatic/topology_being_random_accessible.hh>
@@ -40,7 +41,11 @@
template <typename E>
- class topology_being_random_accessible : public virtual topology<E>
+ class topology_being_random_accessible
+ : public virtual topology<E>,
+ public automatic::impl< topology_being_random_accessible,
+ oln_type_of(E, morpher),
+ E >
{
typedef oln_type_of(E, point) point_t;
@@ -51,6 +56,11 @@
return this->exact().impl_has(p);
}
+ bool has_large(const point_t& p) const
+ {
+ return this->exact().impl_has_large(p);
+ }
+
protected:
topology_being_random_accessible()
Index: oln/core/abstract/topology_having_neighborhood.hh
===================================================================
--- oln/core/abstract/topology_having_neighborhood.hh (revision 0)
+++ oln/core/abstract/topology_having_neighborhood.hh (revision 0)
@@ -0,0 +1,86 @@
+// 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_ABSTRACT_TOPOLOGY_HAVING_NEIGHBORHOOD_HH
+# define OLENA_CORE_ABSTRACT_TOPOLOGY_HAVING_NEIGHBORHOOD_HH
+
+# include <oln/core/abstract/topology.hh>
+# include <oln/automatic/topology_having_neighborhood.hh>
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+
+ template <typename E>
+ class topology_having_neighborhood
+ : public virtual topology<E>,
+ public automatic::impl< topology_having_neighborhood,
+ oln_type_of(E, morpher),
+ E >
+ {
+ typedef oln_type_of(E, neighborhood) neighborhood_t;
+
+ public:
+
+ // abstract
+ const neighborhood_t& neighborhood() const
+ {
+ return this->exact().impl_neighborhood();
+ }
+
+ // concrete
+ operator neighborhood_t() const
+ {
+ return this->neighborhood();
+ }
+
+ protected:
+
+ topology_having_neighborhood()
+ {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+ template <typename E>
+ struct case_ < topology_hierarchy_wrt_neighborhood, E, 1 >
+ : where_< mlc::neq_< oln_type_of(E, neighborhood), mlc::none > >
+ {
+ typedef abstract::topology_having_neighborhood<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_TOPOLOGY_HAVING_NEIGHBORHOOD_HH
Index: oln/core/abstract/topology.hh
===================================================================
--- oln/core/abstract/topology.hh (revision 563)
+++ oln/core/abstract/topology.hh (working copy)
@@ -55,7 +55,10 @@
// provides .has(p) and .has_large(p)
stc_virtual_typedef(point);
+ stc_virtual_typedef(neighborhood);
+ stc_virtual_typedef(morpher);
+
decl() {
// constraint:
// mlc::assert_< mlc::implies_< mlc::neq_< bbox, mlc::none >,
Index: oln/core/gen/topo_add_nbh.hh
===================================================================
--- oln/core/gen/topo_add_nbh.hh (revision 0)
+++ oln/core/gen/topo_add_nbh.hh (revision 0)
@@ -0,0 +1,102 @@
+// 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_GEN_TOPO_ADD_NBH_HH
+# define OLENA_CORE_GEN_TOPO_ADD_NBH_HH
+
+# include <oln/core/internal/topology_morpher.hh>
+
+
+
+namespace oln
+{
+
+
+ // Forward declarations.
+ template <typename topo, typename nbh> class topo_add_nbh;
+
+
+ // Super type declaration.
+ template <typename topo, typename nbh>
+ struct set_super_type< topo_add_nbh<topo, nbh> >
+ {
+ typedef topo_add_nbh<topo, nbh> self_t;
+ typedef internal::topology_morpher<topo, self_t> ret;
+ };
+
+
+ /// Virtual types associated to oln::bbox_<point>.
+ template <typename topo, typename nbh>
+ struct vtypes< topo_add_nbh<topo, nbh> >
+ {
+ typedef nbh neighborhood_type;
+ };
+
+ template <typename topo, typename nbh>
+ struct single_vtype< topo_add_nbh<topo, nbh>, typedef_::delegated_type >
+ {
+ typedef topo ret;
+ };
+
+
+ /// Bounding box topology based on a point class.
+ template <typename topo_t, typename nbh_t>
+ class topo_add_nbh : public internal::topology_morpher<topo_t,
topo_add_nbh<topo_t, nbh_t> >
+ {
+ public:
+
+ topo_add_nbh()
+ {
+ }
+
+ topo_add_nbh(const topo_t& topo, const nbh_t& nbh)
+ : topo_(topo),
+ nbh_(nbh)
+ {
+ }
+
+ const nbh_t& impl_neighborhood() const
+ {
+ return nbh_;
+ }
+
+ const topo_t& delegate() const
+ {
+ return topo_;
+ }
+
+ protected:
+
+ topo_t topo_;
+ nbh_t nbh_;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_GEN_TOPO_ADD_NBH_HH
Index: oln/core/internal/topology_morpher.hh
===================================================================
--- oln/core/internal/topology_morpher.hh (revision 0)
+++ oln/core/internal/topology_morpher.hh (revision 0)
@@ -0,0 +1,77 @@
+// 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_INTERNAL_TOPOLOGY_MORPHER_HH
+# define OLENA_CORE_INTERNAL_TOPOLOGY_MORPHER_HH
+
+# include <oln/core/topology_entry.hh>
+
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+ template <typename Topo, typename E>
+ struct topology_morpher;
+
+ } // end of namespace oln::internal
+
+ template <typename Topo, typename E>
+ struct set_pseudosuper_type< internal::topology_morpher<Topo, E> >
+ {
+ typedef Topo ret;
+ };
+
+ template <typename Topo, typename E>
+ struct single_vtype< internal::topology_morpher<Topo, E>,
typedef_::morpher_type >
+ {
+ typedef morpher::tag::identity ret;
+ };
+
+
+ namespace internal
+ {
+
+ /// Base internal class for morphers on topology.
+
+ template <typename Topo, typename E>
+ struct topology_morpher : public topology_entry<E>
+ {
+ protected:
+ topology_morpher() {}
+ };
+
+ } // end of namespace oln::internal
+
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_INTERNAL_TOPOLOGY_MORPHER_HH