2006-09-06 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Update abstract::pset hierarchy to final SCOOP-2 design.
* oln/core/pset_entry.hh: New.
* oln/core/typedefs.hh: Include oln/core/abstract/entry.hh.
* oln/core/abstract/bbox.hh: Clean includes.
(set_super_type): Change from abstract::pset<E> to pset_entry<E>.
(bbox): Update.
* oln/core/abstract/entry.hh (set_super_type): New specialization.
* oln/core/abstract/pset.hh (Copyright): Fix years.
(vtypes, ext_vtype): Remove.
(fixed_pset, ra_pset, bboxed_pset): Move and dispatch to...
* oln/core/abstract/pset_fixed.hh: ...this new file.
* oln/core/abstract/pset_ra.hh: ...this new file.
* oln/core/abstract/pset_bboxed.hh: ...this new file.
* oln/core/abstract/pset.hh
(pset_fixed_hierarchy, pset_ra_hierarchy, pset_bboxed_hierarchy)
(case_): Move to...
* oln/core/abstract/pset_hierarchies.hh: ...this new file.
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 523)
+++ oln/core/typedefs.hh (working copy)
@@ -208,4 +208,7 @@
} // end of namespace oln
+# include <oln/core/abstract/entry.hh>
+
+
#endif // ! OLENA_CORE_TYPEDEFS_HH
Index: oln/core/abstract/pset_hierarchies.hh
===================================================================
--- oln/core/abstract/pset_hierarchies.hh (revision 0)
+++ oln/core/abstract/pset_hierarchies.hh (revision 0)
@@ -0,0 +1,51 @@
+// 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_PSET_HIERARCHIES_HH
+# define OLENA_CORE_ABSTRACT_PSET_HIERARCHIES_HH
+
+# include <oln/core/abstract/pset.hh>
+
+
+namespace oln
+{
+
+ typedef hierarchy< abstract::pset, 1 > pset_fixed_hierarchy;
+ typedef hierarchy< abstract::pset, 2 > pset_ra_hierarchy;
+ typedef hierarchy< abstract::pset, 3 > pset_bboxed_hierarchy;
+
+} // end of namespace oln
+
+
+# include <oln/core/abstract/pset_fixed.hh>
+# include <oln/core/abstract/pset_ra.hh>
+# include <oln/core/abstract/pset_bboxed.hh>
+
+
+
+#endif // ! OLENA_CORE_ABSTRACT_PSET_HIERARCHIES_HH
+
Index: oln/core/abstract/bbox.hh
===================================================================
--- oln/core/abstract/bbox.hh (revision 523)
+++ oln/core/abstract/bbox.hh (working copy)
@@ -29,10 +29,7 @@
#ifndef OLENA_CORE_ABSTRACT_BBOX_HH
# define OLENA_CORE_ABSTRACT_BBOX_HH
-# include <mlc/value.hh>
-# include <oln/core/type.hh>
-# include <oln/core/typedefs.hh>
-# include <oln/core/abstract/pset.hh>
+# include <oln/core/pset_entry.hh>
namespace oln
@@ -46,7 +43,7 @@
template <typename E>
struct set_super_type< abstract::bbox<E> >
{
- typedef abstract::pset<E> ret;
+ typedef pset_entry<E> ret;
};
@@ -65,7 +62,7 @@
/// Abstract bbox (bounding box) class.
template <typename E>
- class bbox : public entry< abstract::pset, E> // NEW! former was:
abstract::pset<E>
+ class bbox : public pset_entry<E>
{
typedef oln_type_of(E, point) point_t;
Index: oln/core/abstract/pset_fixed.hh
===================================================================
--- oln/core/abstract/pset_fixed.hh (revision 0)
+++ oln/core/abstract/pset_fixed.hh (revision 0)
@@ -0,0 +1,73 @@
+// 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_PSET_FIXED_HH
+# define OLENA_CORE_ABSTRACT_PSET_FIXED_HH
+
+# include <oln/core/abstract/pset.hh>
+
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+
+ template <typename E>
+ class fixed_pset : public virtual pset<E>
+ {
+ public:
+
+ unsigned npoints() const
+ {
+ return this->exact().impl_npoints();
+ }
+
+ protected:
+ fixed_pset()
+ {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+ template <typename E>
+ struct case_ < pset_fixed_hierarchy, E, 1 >
+ : where_< mlc::eq_< oln_type_of(E, fixed), mlc::true_ > >
+ {
+ typedef abstract::fixed_pset<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_PSET_FIXED_HH
+
Index: oln/core/abstract/pset_ra.hh
===================================================================
--- oln/core/abstract/pset_ra.hh (revision 0)
+++ oln/core/abstract/pset_ra.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_CORE_ABSTRACT_PSET_RA_HH
+# define OLENA_CORE_ABSTRACT_PSET_RA_HH
+
+# include <oln/core/abstract/pset.hh>
+
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+
+ template <typename E>
+ class ra_pset : public virtual pset<E>
+ {
+ typedef oln_type_of(E, point) point_t;
+
+ public:
+
+ bool has(const point_t& p) const
+ {
+ return this->exact().impl_has(p);
+ }
+
+ protected:
+ ra_pset()
+ {}
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+ template <typename E>
+ struct case_ < pset_ra_hierarchy, E, 1 >
+ : where_< mlc::eq_< oln_type_of(E, ra), mlc::true_ > >
+ {
+ typedef abstract::ra_pset<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_PSET_RA_HH
Index: oln/core/abstract/pset_bboxed.hh
===================================================================
--- oln/core/abstract/pset_bboxed.hh (revision 0)
+++ oln/core/abstract/pset_bboxed.hh (revision 0)
@@ -0,0 +1,118 @@
+// 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_PSET_BBOXED_HH
+# define OLENA_CORE_ABSTRACT_PSET_BBOXED_HH
+
+# include <oln/core/abstract/pset.hh>
+
+
+namespace oln
+{
+
+ namespace abstract
+ {
+
+
+ template <typename E>
+ class bboxed_pset : public virtual pset<E>
+ {
+ typedef oln_type_of(E, point) point_t;
+ typedef oln_type_of(E, bbox) bbox_t;
+
+ typedef oln_type_of(point_t, coord) coord_t;
+ typedef oln_type_of(point_t, dim) dim_t;
+ enum { n = mlc_value(dim_t) };
+
+ public:
+
+ const bbox_t& bbox() const
+ {
+ return this->exact().impl_box();
+ }
+
+ bool is_valid() const
+ {
+ return this->exact().impl_is_valid();
+ }
+
+ const point_t& pmin() const
+ {
+ precondition(this->is_valid());
+ return pmin_;
+ }
+
+ coord_t pmin(unsigned i) const
+ {
+ precondition(this->is_valid() and i < n);
+ return pmin_[i];
+ }
+
+ const point_t& pmax() const
+ {
+ precondition(this->is_valid());
+ return pmax_;
+ }
+
+ coord_t pmax(unsigned i) const
+ {
+ precondition(this->is_valid() and i < n);
+ return pmax_[i];
+ }
+
+ unsigned len(unsigned i) const
+ {
+ precondition(this->is_valid() and i < n);
+ return pmax_[i] - pmin_[i] + 1;
+ }
+
+ protected:
+
+ bboxed_pset()
+ {}
+
+ point_t pmin_, pmax_;
+ };
+
+
+ } // end of namespace oln::abstract
+
+
+
+ template <typename E>
+ struct case_ < pset_bboxed_hierarchy, E, 1 >
+ : where_< mlc::neq_< oln_type_of(E, bbox), mlc::none > >
+ {
+ typedef abstract::bboxed_pset<E> ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_PSET_BBOXED_HH
+
Index: oln/core/abstract/entry.hh
===================================================================
--- oln/core/abstract/entry.hh (revision 523)
+++ oln/core/abstract/entry.hh (working copy)
@@ -112,6 +112,15 @@
};
+ // Super type declaration.
+ template < template <class> class abstraction,
+ typename E >
+ struct set_super_type< entry<abstraction, E> >
+ {
+ typedef abstraction<E> ret;
+ };
+
+
} // end of namespace oln
Index: oln/core/abstract/pset.hh
===================================================================
--- oln/core/abstract/pset.hh (revision 523)
+++ oln/core/abstract/pset.hh (working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// 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
@@ -29,53 +28,16 @@
#ifndef OLENA_CORE_ABSTRACT_PSET_HH
# define OLENA_CORE_ABSTRACT_PSET_HH
-# include <stc/any.hh>
-# include <oln/core/type.hh>
# include <oln/core/typedefs.hh>
-# include <oln/core/abstract/entry.hh> // NEW!
-
namespace oln
{
- /// Forward declaration.
- namespace abstract { template <typename E> class pset; }
-
-
-
- /// Virtual types associated to oln::bbox_nd<point>.
- template <typename E>
- struct vtypes< abstract::pset<E> >
- {
- typedef mlc::undefined point_type;
- typedef mlc::undefined fwd_piter_type;
- typedef mlc::undefined bkd_piter_type;
-
- typedef mlc::none bbox_type;
- typedef mlc::undefined ra_type;
- typedef mlc::undefined fixed_type;
- };
-
-
- template <typename E>
- struct ext_vtype< abstract::pset<E>, typedef_::coord_type >
- {
- typedef oln_type_of(E, point) P;
- typedef oln_type_of(P, coord) ret;
- };
-
- template <typename E>
- struct ext_vtype< abstract::pset<E>, typedef_::grid_type >
- {
- typedef oln_type_of(E, point) P;
- typedef oln_type_of(P, grid) ret;
- };
-
-
namespace abstract
{
+
/// Abstract point class.
template <typename E>
class pset : public virtual stc::any__simple<E>,
@@ -85,163 +47,48 @@
// ...
- protected:
-
- pset()
- {}
-
- ~pset()
+ struct decl
{
- mlc::assert_defined_< oln_type_of(E, point) >::check();
- mlc::assert_defined_< oln_type_of(E, fwd_piter) >::check();
- mlc::assert_defined_< oln_type_of(E, bkd_piter) >::check();
+ stc_virtual_typedef(point);
+ stc_virtual_typedef(fwd_piter);
+ stc_virtual_typedef(bkd_piter);
- mlc::assert_defined_< oln_type_of(E, coord) >::check();
- mlc::assert_defined_< oln_type_of(E, grid) >::check();
+ stc_virtual_typedef(bbox);
+ stc_virtual_typedef(ra);
+ stc_virtual_typedef(fixed);
-// mlc::assert_< mlc::eq_< oln_type_of(fwd_piter_t, grid),
-// oln_type_of(point_t, grid) > >::check();
+ // derived from point:
+ stc_virtual_typedef(coord);
+ stc_virtual_typedef(grid);
-// mlc::assert_< mlc::eq_< oln_type_of(bkd_piter_t, grid),
-// oln_type_of(point_t, grid) > >::check();
- }
+ decl() {
+ // coherence check:
+ mlc::assert_equal_< oln_type_of(fwd_piter, grid),
+ oln_type_of(point, grid) >::check();
+ mlc::assert_equal_< oln_type_of(bkd_piter, grid),
+ oln_type_of(point, grid) >::check();
+ }
+ };
- }; // end of class oln::abstract::pset<E>
-
-
-
- template <typename E>
- class fixed_pset : public virtual pset<E>
- {
- public:
-
- unsigned npoints() const
- {
- return this->exact().impl_npoints();
- }
-
protected:
- fixed_pset()
- {}
- };
-
-
- template <typename E>
- class ra_pset : public virtual pset<E>
- {
- typedef oln_type_of(E, point) point_t;
-
- public:
-
- bool has(const point_t& p) const
- {
- return this->exact().impl_has(p);
- }
-
- protected:
- ra_pset()
+ pset()
{}
- };
+ ~pset() { decl(); }
+ }; // end of class oln::abstract::pset<E>
- template <typename E>
- class bboxed_pset : public virtual pset<E>
- {
- typedef oln_type_of(E, point) point_t;
- typedef oln_type_of(E, bbox) bbox_t;
- typedef oln_type_of(point_t, coord) coord_t;
- typedef oln_type_of(point_t, dim) dim_t;
- enum { n = mlc_value(dim_t) };
-
- public:
- const bbox_t& bbox() const
- {
- return this->exact().impl_box();
- }
-
- bool is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
- const point_t& pmin() const
- {
- precondition(this->is_valid());
- return pmin_;
- }
-
- coord_t pmin(unsigned i) const
- {
- precondition(this->is_valid() and i < n);
- return pmin_[i];
- }
-
- const point_t& pmax() const
- {
- precondition(this->is_valid());
- return pmax_;
- }
-
- coord_t pmax(unsigned i) const
- {
- precondition(this->is_valid() and i < n);
- return pmax_[i];
- }
-
- unsigned len(unsigned i) const
- {
- precondition(this->is_valid() and i < n);
- return pmax_[i] - pmin_[i] + 1;
- }
-
- protected:
-
- bboxed_pset()
- {}
-
- point_t pmin_, pmax_;
- };
-
-
} // end of namespace oln::abstract
+} // end of namespace oln
- typedef hierarchy<abstract::pset, 1> pset_fixed_hierarchy;
- typedef hierarchy<abstract::pset, 2> pset_ra_hierarchy;
- typedef hierarchy<abstract::pset, 3> pset_bboxed_hierarchy;
+# include <oln/core/abstract/pset_hierarchies.hh>
- template <typename E>
- struct case_ < pset_fixed_hierarchy, E, 1 >
- : where_< mlc::eq_< oln_type_of(E, fixed), mlc::true_ > >
- {
- typedef abstract::fixed_pset<E> ret;
- };
- template <typename E>
- struct case_ < pset_ra_hierarchy, E, 1 >
- : where_< mlc::eq_< oln_type_of(E, ra), mlc::true_ > >
- {
- typedef abstract::ra_pset<E> ret;
- };
-
-
- template <typename E>
- struct case_ < pset_bboxed_hierarchy, E, 1 >
- : where_< mlc::neq_< oln_type_of(E, bbox), mlc::none > >
- {
- typedef abstract::bboxed_pset<E> ret;
- };
-
-
-
-} // end of namespace oln
-
-
#endif // ! OLENA_CORE_ABSTRACT_PSET_HH
Index: oln/core/pset_entry.hh
===================================================================
--- oln/core/pset_entry.hh (revision 0)
+++ oln/core/pset_entry.hh (revision 0)
@@ -0,0 +1,85 @@
+// 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_PSET_ENTRY_HH
+# define OLENA_CORE_PSET_ENTRY_HH
+
+# include <oln/core/abstract/entry.hh>
+# include <oln/core/abstract/pset.hh>
+
+
+
+namespace oln
+{
+
+
+ /// Entry class for point sets: pset_entry<E> is an alias for
+ /// entry< abstract::pset, E>.
+
+ template <typename E>
+ struct pset_entry : public entry< abstract::pset, E>
+ {
+ protected:
+ pset_entry() {}
+ };
+
+
+ /// Virtual types associated to pset_entry<E>.
+
+ template <typename E>
+ struct vtypes< pset_entry<E> >
+ {
+ typedef mlc::undefined point_type;
+ typedef mlc::undefined fwd_piter_type;
+ typedef mlc::undefined bkd_piter_type;
+
+ typedef mlc::none bbox_type;
+ typedef mlc::undefined ra_type;
+ typedef mlc::undefined fixed_type;
+ };
+
+
+ template <typename E>
+ struct single_vtype< pset_entry<E>, typedef_::coord_type >
+ {
+ typedef oln_type_of(E, point) P;
+ typedef oln_type_of(P, coord) ret;
+ };
+
+
+ template <typename E>
+ struct single_vtype< pset_entry<E>, typedef_::grid_type >
+ {
+ typedef oln_type_of(E, point) P;
+ typedef oln_type_of(P, grid) ret;
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_PSET_ENTRY_HH