
2006-09-18 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr> Move some abstract classes below entries into internal. * oln/core/abstract/point_nd.hh: Update and rename as... * oln/core/internal/point_nd.hh: ...this. * oln/core/abstract/dpoint_nd.hh: Update and rename as... * oln/core/internal/dpoint_nd.hh: ...this. * oln/core/point_set_entry.hh (is_connected_type): Add in vtypes. * oln/core/abstract/bbox.hh: Change super class from point_set_entry to point_set_having_bbox. (vtypes): Remove. (set_super_type): Remove. * oln/core/abstract/point_set_hierarchies.hh (include): Update. * oln/core/abstract/point_set_having_bbox.hh (case_): Move to... * oln/core/abstract/bbox.hh: ...this file. (case_): Refine for abstract::bbox. * oln/core/2d/dpoint2d.hh: Update. * oln/core/2d/point2d.hh: Update. * oln/core/gen/bbox.hh: Update. Index: oln/core/point_set_entry.hh =================================================================== --- oln/core/point_set_entry.hh (revision 549) +++ oln/core/point_set_entry.hh (working copy) @@ -62,6 +62,7 @@ typedef mlc::none bbox_type; typedef mlc::undefined is_random_accessible_type; typedef mlc::undefined has_known_size_type; + typedef mlc::undefined is_connected_type; }; Index: oln/core/abstract/bbox.hh =================================================================== --- oln/core/abstract/bbox.hh (revision 549) +++ oln/core/abstract/bbox.hh (working copy) @@ -29,44 +29,20 @@ #ifndef OLENA_CORE_ABSTRACT_BBOX_HH # define OLENA_CORE_ABSTRACT_BBOX_HH -# include <oln/core/point_set_entry.hh> +# include <oln/core/abstract/point_set_having_bbox.hh> namespace oln { - // Forward declaration. - namespace abstract { template <typename E> class bbox; } - - // Super type declaration. - template <typename E> - struct set_super_type< abstract::bbox<E> > - { - typedef point_set_entry<E> ret; - }; - - - /// Virtual types associated to oln::abstract::bbox<E>. - template <typename E> - struct vtypes< abstract::bbox<E> > - { - typedef mlc::true_ is_random_accessible_type; - typedef mlc::true_ has_know_size_type; - typedef mlc::true_ is_connected_type; - typedef E bbox_type; - }; - - namespace abstract { /// Abstract bbox (bounding box) class. template <typename E> - class bbox : public point_set_entry<E> + class bbox : public point_set_having_bbox<E> { - typedef oln_type_of(E, point) point_t; - public: void print(std::ostream& ostr) const @@ -92,27 +68,27 @@ { } - ~bbox() - { - mlc::assert_defined_< point_t >::check(); + }; // end of class oln::abstract::bbox<E> -// typedef oln_type_of(E, fwd_piter) fwd_piter_t; -// typedef oln_type_of(E, bkd_piter) bkd_piter_t; -// mlc::assert_defined_< fwd_piter_t >::check(); -// mlc::assert_defined_< bkd_piter_t >::check(); + } // end of namespace oln::abstract -// mlc::assert_< mlc::eq_< oln_type_of(fwd_piter_t, grid), -// oln_type_of(point_t, grid) > >::check(); -// mlc::assert_< mlc::eq_< oln_type_of(bkd_piter_t, grid), -// oln_type_of(point_t, grid) > >::check(); - } - }; // end of class oln::abstract::bbox<E> + template <typename E> + struct case_ < point_set_hierarchy_wrt_bbox, E, 1 > + : where_< mlc::eq_< oln_type_of(E, bbox), E > > + { + typedef abstract::bbox<E> ret; + }; - } // end of namespace oln::abstract + template <typename E> + struct case_ < point_set_hierarchy_wrt_bbox, E, 2 > + : where_< mlc::neq_< oln_type_of(E, bbox), mlc::none > > + { + typedef abstract::point_set_having_bbox<E> ret; + }; } // end of namespace oln Index: oln/core/abstract/point_set_hierarchies.hh =================================================================== --- oln/core/abstract/point_set_hierarchies.hh (revision 549) +++ oln/core/abstract/point_set_hierarchies.hh (working copy) @@ -45,6 +45,7 @@ # include <oln/core/abstract/point_set_having_known_size.hh> # include <oln/core/abstract/point_set_being_random_accessible.hh> # include <oln/core/abstract/point_set_having_bbox.hh> +# include <oln/core/abstract/bbox.hh> # include <oln/core/abstract/point_set_being_connected.hh> Index: oln/core/abstract/point_nd.hh =================================================================== --- oln/core/abstract/point_nd.hh (revision 549) +++ oln/core/abstract/point_nd.hh (working copy) @@ -1,213 +0,0 @@ -// 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_ABSTRACT_POINT_ND_HH -# define OLENA_CORE_ABSTRACT_POINT_ND_HH - -# include <xtd/vec.hh> -# include <xtd/optraits.hh> -# include <oln/core/traits_id.hh> - -# include <oln/core/abstract/point.hh> -# include <oln/core/abstract/dpoint_nd.hh> - - -namespace oln -{ - - - /// Function "point_ : (n, coord) -> point type". - template <unsigned n, typename C> - struct point_ - { - typedef mlc::undefined ret; - }; - - - - // Forward declaration. - namespace abstract { template <typename E> class point_nd; } - - - - // Super type declaration. - template <typename E> - struct set_super_type< abstract::point_nd<E> > - { - typedef abstract::point<E> ret; - }; - - - namespace abstract - { - - template <typename E> - class point_nd : public abstract::point<E> - { - typedef point_nd<E> self_t; - typedef oln_type_of(E, dim) dim; - typedef oln_type_of(E, coord) coord_t; - typedef oln_type_of(E, dpoint) dpoint_t; - - public: - - enum { n = mlc_value(dim) }; - - coord_t operator[](unsigned i) const - { - assert(i < n); - return v_[i]; - } - - coord_t& operator[](unsigned i) - { - assert(i < n); - return v_[i]; - } - - bool impl_equal(const self_t& rhs) const - { - return v_ == rhs.vec(); - } - - bool impl_less(const self_t& rhs) const - { - return xtd::lexi_less(v_, rhs.vec()); - } - - E& impl_plus_equal(const dpoint_t& rhs) - { - v_ += rhs.vec(); - return this->exact(); - } - - E impl_plus(const dpoint_t& rhs) const - { - E tmp(v_ + rhs.vec()); - return tmp; - } - - E& impl_minus_equal(const dpoint_t& rhs) - { - v_ += rhs.vec(); - return this->exact(); - } - - E impl_minus(const dpoint_t& rhs) const - { - E tmp(v_ - rhs.vec()); - return tmp; - } - - dpoint_t impl_minus(const self_t& rhs) const - { - dpoint_t tmp(v_ - rhs.vec()); - return tmp; - } - - const xtd::vec<n,coord_t>& vec() const - { - return v_; - } - - protected: - - /// Ctor. - point_nd() - {} - - /// Ctor. - point_nd(const xtd::vec<n,coord_t>& v) : - v_(v) - {} - - typedef xtd::vec<n,coord_t> vec_t; - vec_t v_; - }; - - } // end of namespace oln::abstract - - - template <typename E> - std::ostream& operator<<(std::ostream& ostr, const abstract::point_nd<E>& p) - { - ostr << p.vec(); - return ostr; - } - - - - /// abstract::point_nd + abstract::dpoint_nd - template <typename P, typename D> - struct case_ < xtd::op_plus, mlc::pair_<P,D>, - oln::id::op_plus_pointnd_dpointnd > - : where_< mlc::and_< mlc_is_a(P, abstract::point_nd), - mlc_is_a(D, abstract::dpoint_nd) > > - { - typedef oln_type_of(P, coord) P_coord; - typedef oln_type_of(D, coord) D_coord; - typedef xtd_op_plus_trait(P_coord, D_coord) coord; - typedef oln_type_of(P, dim) dim; - typedef typename point_<mlc_value(dim), coord>::ret ret; - }; - - - /// abstract::point_nd - abstract::dpoint_nd - template <typename P, typename D> - struct case_ < xtd::op_minus, mlc::pair_<P,D>, - oln::id::op_minus_pointnd_dpointnd > - : where_< mlc::and_< mlc_is_a(P, abstract::point_nd), - mlc_is_a(D, abstract::dpoint_nd) > > - { - typedef oln_type_of(P, coord) P_coord; - typedef oln_type_of(D, coord) D_coord; - typedef xtd_op_minus_trait(P_coord, D_coord) coord; - typedef oln_type_of(P, dim) dim; - typedef typename point_<mlc_value(dim), coord>::ret ret; - }; - - - /// abstract::point_nd - abstract::point_nd - template <typename P1, typename P2> - struct case_ < xtd::op_minus, mlc::pair_<P1,P2>, - oln::id::op_minus_pointnd_pointnd > - : where_< mlc::and_< mlc_is_a(P1, abstract::point_nd), - mlc_is_a(P2, abstract::point_nd) > > - { - typedef oln_type_of(P1, coord) P1_coord; - typedef oln_type_of(P2, coord) P2_coord; - typedef xtd_op_minus_trait(P1_coord, P2_coord) coord; - typedef oln_type_of(P1, dim) dim; - typedef typename dpoint_<mlc_value(dim), coord>::ret ret; - }; - - -} // end of namespace oln - - -#endif // ! OLENA_CORE_ABSTRACT_POINT_ND_HH Index: oln/core/abstract/point_set_having_bbox.hh =================================================================== --- oln/core/abstract/point_set_having_bbox.hh (revision 549) +++ oln/core/abstract/point_set_having_bbox.hh (working copy) @@ -55,6 +55,8 @@ return this->exact().impl_box(); } + // FIXME: attributes should be removed from this abstract class. + const point_t& pmin() const { precondition(this->is_valid()); @@ -97,12 +99,8 @@ } // end of namespace oln::abstract - template <typename E> - struct case_ < point_set_hierarchy_wrt_bbox, E, 1 > - : where_< mlc::neq_< oln_type_of(E, bbox), mlc::none > > - { - typedef abstract::point_set_having_bbox<E> ret; - }; + // an abstract sub-class of point_set_having_bbox<E> is abstract::bbox<E>; + // the switch-case mechanism is in oln/core/abstract/bbox.hh } // end of namespace oln Index: oln/core/abstract/dpoint_nd.hh =================================================================== --- oln/core/abstract/dpoint_nd.hh (revision 549) +++ oln/core/abstract/dpoint_nd.hh (working copy) @@ -1,138 +0,0 @@ -// 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_ABSTRACT_DPOINT_ND_HH -# define OLENA_CORE_ABSTRACT_DPOINT_ND_HH - -# include <mlc/value.hh> -# include <xtd/vec.hh> -# include <stc/exact.hh> -# include <oln/core/abstract/dpoint.hh> - - -namespace oln -{ - - // Forward declaration. - namespace abstract { template <typename E> class dpoint_nd; } - - - // Super type declaration. - template <typename E> - struct set_super_type< abstract::dpoint_nd<E> > - { - typedef abstract::dpoint<E> ret; - }; - - - namespace abstract - { - - template <typename E> - class dpoint_nd : public abstract::dpoint<E> - { - typedef E exact_t; - typedef dpoint_nd<E> self_t; - typedef oln_type_of(E, dim) dim; - typedef oln_type_of(E, coord) coord_t; - - public: - - enum { n = mlc_value(dim) }; - - bool impl_equal(const self_t& rhs) const - { - return v_ == rhs.v_; - } - - coord_t operator[](unsigned i) const - { - assert(i < n); - return v_[i]; - } - - coord_t& operator[](unsigned i) - { - assert(i < n); - return v_[i]; - } - - void set_all(const coord_t& c) - { - v_.set_all(c); - } - - const xtd::vec<n,coord_t>& vec() const - { - return v_; - } - - exact_t operator-() const - { - exact_t tmp(-v_); - return tmp; - } - - bool impl_less(const self_t& rhs) const - { - return xtd::lexi_less(v_, rhs.vec()); - } - - protected: - - /// Ctor. - dpoint_nd() - {} - - /// Ctor. - dpoint_nd(const xtd::vec<n,coord_t>& v) : - v_(v) - {} - - xtd::vec<n,coord_t> v_; - }; - - } // end of namespace oln::abstract - - - - /// - abstract::dpoint_nd - template <typename D> - struct case_ < xtd::op_uminus, D, - oln::id::op_uminus_dpointnd > - : where_< mlc_is_a(D, abstract::dpoint_nd) > - { - typedef stc_to_exact(D) ret; - }; - - - -} // end of namespace oln - - -#endif // ! OLENA_CORE_ABSTRACT_DPOINT_ND_HH Index: oln/core/2d/dpoint2d.hh =================================================================== --- oln/core/2d/dpoint2d.hh (revision 549) +++ oln/core/2d/dpoint2d.hh (working copy) @@ -30,7 +30,7 @@ # include <mlc/int.hh> # include <oln/core/2d/point2d.hh> -# include <oln/core/abstract/dpoint_nd.hh> +# include <oln/core/internal/dpoint_nd.hh> namespace oln @@ -45,7 +45,7 @@ // }; - /// Virtual types associated to oln::abstract::image. + /// Virtual types associated to oln::dpoint2d_<C>. template <typename C> struct vtypes< dpoint2d_<C> > { @@ -58,10 +58,10 @@ /// General 2D dpoint class. template <typename C> - class dpoint2d_ : public abstract::dpoint_nd< dpoint2d_<C> > // FIXME: stc_get_super_(dpoint2d_<C>) + class dpoint2d_ : public internal::dpoint_nd< dpoint2d_<C> > // FIXME: stc_get_super_(dpoint2d_<C>) { typedef dpoint2d_<C> self_t; - typedef abstract::dpoint_nd<self_t> super_t; // FIXME: stc_get_super(self) + typedef internal::dpoint_nd<self_t> super_t; // FIXME: stc_get_super(self_t) typedef oln_type_of(self_t, coord) coord_t; using super_t::v_; Index: oln/core/2d/point2d.hh =================================================================== --- oln/core/2d/point2d.hh (revision 549) +++ oln/core/2d/point2d.hh (working copy) @@ -29,7 +29,7 @@ # define OLENA_CORE_2D_POINT2D_HH # include <mlc/int.hh> -# include <oln/core/abstract/point_nd.hh> +# include <oln/core/internal/point_nd.hh> namespace oln @@ -43,7 +43,7 @@ /// \} - /// Virtual types associated to oln::abstract::image. + /// Virtual types associated to oln::point2d_<C>. template <typename C> struct vtypes< point2d_<C> > { @@ -56,10 +56,10 @@ /// General 2D point class. template <typename C> - class point2d_ : public abstract::point_nd< point2d_<C> > // FIXME: stc_get_super_(point2d_<C>) + class point2d_ : public internal::point_nd< point2d_<C> > // FIXME: stc_get_super_(point2d_<C>) { typedef point2d_<C> self_t; - typedef abstract::point_nd<self_t> super_t; + typedef internal::point_nd<self_t> super_t; using super_t::v_; Index: oln/core/gen/bbox.hh =================================================================== --- oln/core/gen/bbox.hh (revision 549) +++ oln/core/gen/bbox.hh (working copy) @@ -29,7 +29,7 @@ #ifndef OLENA_CORE_GEN_BBOX_HH # define OLENA_CORE_GEN_BBOX_HH -# include <oln/core/abstract/bbox.hh> +# include <oln/core/point_set_entry.hh> # include <oln/core/abstract/point.hh> @@ -47,7 +47,7 @@ struct set_super_type< bbox_<point> > { typedef bbox_<point> self_t; - typedef abstract::bbox<self_t> ret; + typedef point_set_entry<self_t> ret; }; @@ -58,17 +58,23 @@ typedef point point_type; typedef fwd_piter_<point> fwd_piter_type; typedef bkd_piter_<point> bkd_piter_type; + + typedef bbox_<point> bbox_type; + + typedef mlc::true_ is_random_accessible_type; + typedef mlc::true_ has_know_size_type; + typedef mlc::true_ is_connected_type; }; /// Bounding box class based on a point class. template <typename point> - class bbox_ : public abstract::bbox< bbox_<point> >, + class bbox_ : public point_set_entry< bbox_<point> >, private mlc::assert_< mlc_is_a(point, abstract::point) > { typedef point point_t; typedef bbox_<point> self_t; - typedef abstract::bbox<self_t> super_t; + typedef point_set_entry<self_t> super_t; typedef oln_type_of(point, coord) coord_t; Index: oln/core/internal/point_nd.hh =================================================================== --- oln/core/internal/point_nd.hh (revision 0) +++ oln/core/internal/point_nd.hh (working copy) @@ -26,15 +26,15 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef OLENA_CORE_ABSTRACT_POINT_ND_HH -# define OLENA_CORE_ABSTRACT_POINT_ND_HH +#ifndef OLENA_CORE_INTERNAL_POINT_ND_HH +# define OLENA_CORE_INTERNAL_POINT_ND_HH # include <xtd/vec.hh> # include <xtd/optraits.hh> # include <oln/core/traits_id.hh> # include <oln/core/abstract/point.hh> -# include <oln/core/abstract/dpoint_nd.hh> +# include <oln/core/internal/dpoint_nd.hh> namespace oln @@ -51,19 +51,19 @@ // Forward declaration. - namespace abstract { template <typename E> class point_nd; } + namespace internal { template <typename E> class point_nd; } // Super type declaration. template <typename E> - struct set_super_type< abstract::point_nd<E> > + struct set_super_type< internal::point_nd<E> > { typedef abstract::point<E> ret; }; - namespace abstract + namespace internal { template <typename E> @@ -150,11 +150,11 @@ vec_t v_; }; - } // end of namespace oln::abstract + } // end of namespace oln::internal template <typename E> - std::ostream& operator<<(std::ostream& ostr, const abstract::point_nd<E>& p) + std::ostream& operator<<(std::ostream& ostr, const internal::point_nd<E>& p) { ostr << p.vec(); return ostr; @@ -162,12 +162,12 @@ - /// abstract::point_nd + abstract::dpoint_nd + /// internal::point_nd + internal::dpoint_nd template <typename P, typename D> struct case_ < xtd::op_plus, mlc::pair_<P,D>, oln::id::op_plus_pointnd_dpointnd > - : where_< mlc::and_< mlc_is_a(P, abstract::point_nd), - mlc_is_a(D, abstract::dpoint_nd) > > + : where_< mlc::and_< mlc_is_a(P, internal::point_nd), + mlc_is_a(D, internal::dpoint_nd) > > { typedef oln_type_of(P, coord) P_coord; typedef oln_type_of(D, coord) D_coord; @@ -177,12 +177,12 @@ }; - /// abstract::point_nd - abstract::dpoint_nd + /// internal::point_nd - internal::dpoint_nd template <typename P, typename D> struct case_ < xtd::op_minus, mlc::pair_<P,D>, oln::id::op_minus_pointnd_dpointnd > - : where_< mlc::and_< mlc_is_a(P, abstract::point_nd), - mlc_is_a(D, abstract::dpoint_nd) > > + : where_< mlc::and_< mlc_is_a(P, internal::point_nd), + mlc_is_a(D, internal::dpoint_nd) > > { typedef oln_type_of(P, coord) P_coord; typedef oln_type_of(D, coord) D_coord; @@ -192,12 +192,12 @@ }; - /// abstract::point_nd - abstract::point_nd + /// internal::point_nd - internal::point_nd template <typename P1, typename P2> struct case_ < xtd::op_minus, mlc::pair_<P1,P2>, oln::id::op_minus_pointnd_pointnd > - : where_< mlc::and_< mlc_is_a(P1, abstract::point_nd), - mlc_is_a(P2, abstract::point_nd) > > + : where_< mlc::and_< mlc_is_a(P1, internal::point_nd), + mlc_is_a(P2, internal::point_nd) > > { typedef oln_type_of(P1, coord) P1_coord; typedef oln_type_of(P2, coord) P2_coord; @@ -210,4 +210,4 @@ } // end of namespace oln -#endif // ! OLENA_CORE_ABSTRACT_POINT_ND_HH +#endif // ! OLENA_CORE_INTERNAL_POINT_ND_HH Index: oln/core/internal/dpoint_nd.hh =================================================================== --- oln/core/internal/dpoint_nd.hh (revision 0) +++ oln/core/internal/dpoint_nd.hh (working copy) @@ -26,8 +26,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. -#ifndef OLENA_CORE_ABSTRACT_DPOINT_ND_HH -# define OLENA_CORE_ABSTRACT_DPOINT_ND_HH +#ifndef OLENA_CORE_INTERNAL_DPOINT_ND_HH +# define OLENA_CORE_INTERNAL_DPOINT_ND_HH # include <mlc/value.hh> # include <xtd/vec.hh> @@ -39,18 +39,18 @@ { // Forward declaration. - namespace abstract { template <typename E> class dpoint_nd; } + namespace internal { template <typename E> class dpoint_nd; } // Super type declaration. template <typename E> - struct set_super_type< abstract::dpoint_nd<E> > + struct set_super_type< internal::dpoint_nd<E> > { typedef abstract::dpoint<E> ret; }; - namespace abstract + namespace internal { template <typename E> @@ -117,15 +117,15 @@ xtd::vec<n,coord_t> v_; }; - } // end of namespace oln::abstract + } // end of namespace oln::internal - /// - abstract::dpoint_nd + /// - internal::dpoint_nd template <typename D> struct case_ < xtd::op_uminus, D, oln::id::op_uminus_dpointnd > - : where_< mlc_is_a(D, abstract::dpoint_nd) > + : where_< mlc_is_a(D, internal::dpoint_nd) > { typedef stc_to_exact(D) ret; }; @@ -135,4 +135,4 @@ } // end of namespace oln -#endif // ! OLENA_CORE_ABSTRACT_DPOINT_ND_HH +#endif // ! OLENA_CORE_INTERNAL_DPOINT_ND_HH