
https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Factor oln::grid1d, oln::grid2d and oln::grid3d into oln::grid_<>. * oln/core/1d/grid1d.hh, oln/core/2d/grid2d.hh, * oln/core/3d/grid3d.hh: Remove. * oln/core/gen/grid.hh: New file. * oln/core/1d/image1d.hh, oln/core/2d/image2d.hh, * oln/core/3d/image3d.hh: Include it. * oln/core/1d/aliases.hh (oln::grid_): Declare it. (oln::grid1d): Adjust definition. * oln/core/2d/aliases.hh (oln::grid_): Declare it. (oln::grid2d): Adjust definition. * oln/core/3d/aliases.hh (oln::grid_): Declare it. (oln::grid3d): Adjust definition. * oln/basics1d.hh, oln/basics2d.hh, oln/basics3d.hh, * oln/core/abstract/image/dimension/hierarchy.hh, * oln/core/abstract/image/hybrid/classical.hh, * oln/core/abstract/point_set/point_set_being_connected.hh, * oln/Makefile.am, * tests/grid.cc: Adjust. oln/Makefile.am | 4 oln/basics1d.hh | 2 oln/basics2d.hh | 2 oln/basics3d.hh | 2 oln/core/1d/aliases.hh | 8 + oln/core/1d/image1d.hh | 1 oln/core/2d/aliases.hh | 8 + oln/core/2d/image2d.hh | 1 oln/core/3d/aliases.hh | 8 + oln/core/3d/image3d.hh | 1 oln/core/abstract/image/dimension/hierarchy.hh | 8 + oln/core/abstract/image/hybrid/classical.hh | 9 + oln/core/abstract/point_set/point_set_being_connected.hh | 7 - oln/core/gen/grid.hh | 68 +++++++++++++++ tests/grid.cc | 7 - 15 files changed, 108 insertions(+), 28 deletions(-) Index: tests/grid.cc --- tests/grid.cc (revision 636) +++ tests/grid.cc (working copy) @@ -28,9 +28,10 @@ /// Test grids. #include <cassert> -#include <oln/core/1d/grid1d.hh> -#include <oln/core/2d/grid2d.hh> -#include <oln/core/3d/grid3d.hh> +#include <oln/core/1d/aliases.hh> +#include <oln/core/2d/aliases.hh> +#include <oln/core/3d/aliases.hh> +#include <oln/core/gen/grid.hh> int main() Index: oln/basics1d.hh --- oln/basics1d.hh (revision 636) +++ oln/basics1d.hh (working copy) @@ -32,7 +32,7 @@ # include <oln/core/1d/aliases.hh> -# include <oln/core/1d/grid1d.hh> +# include <oln/core/gen/grid.hh> # include <oln/core/1d/point1d.hh> # include <oln/core/1d/dpoint1d.hh> Index: oln/core/abstract/image/hybrid/classical.hh --- oln/core/abstract/image/hybrid/classical.hh (revision 636) +++ oln/core/abstract/image/hybrid/classical.hh (working copy) @@ -108,10 +108,11 @@ } // end of namespace oln::abstract - // Fwd. decl. - class grid1d; - class grid2d; - class grid3d; + // Forward declarations. + template <unsigned D> struct grid_; + typedef grid_<1> grid1d; + typedef grid_<2> grid2d; + typedef grid_<3> grid3d; /// 1D case. Index: oln/core/abstract/image/dimension/hierarchy.hh --- oln/core/abstract/image/dimension/hierarchy.hh (revision 636) +++ oln/core/abstract/image/dimension/hierarchy.hh (working copy) @@ -87,9 +87,11 @@ { // Forward declarations. - class grid1d; - class grid2d; - class grid3d; + template <unsigned D> struct grid_; + typedef grid_<1> grid1d; + typedef grid_<2> grid2d; + typedef grid_<3> grid3d; + /// 1D case. template <typename E> Index: oln/core/abstract/point_set/point_set_being_connected.hh --- oln/core/abstract/point_set/point_set_being_connected.hh (revision 636) +++ oln/core/abstract/point_set/point_set_being_connected.hh (working copy) @@ -157,9 +157,10 @@ // Forward declarations. - class grid1d; - class grid2d; - class grid3d; + template <unsigned D> struct grid_; + typedef grid_<1> grid1d; + typedef grid_<2> grid2d; + typedef grid_<3> grid3d; template <typename E> Index: oln/core/1d/aliases.hh --- oln/core/1d/aliases.hh (revision 636) +++ oln/core/1d/aliases.hh (working copy) @@ -33,8 +33,9 @@ namespace oln { - /// \{ /// Forward declarations. + /// \{ + template <unsigned D> struct grid_; template <typename C> class point1d_; template <typename C> class dpoint1d_; template <typename D> class neighb_; @@ -46,12 +47,13 @@ template <typename P> class fwd_qiter_win_; // FIXME: Not yet available. // template <typename P> class bkd_qiter_win_; - class grid1d; /// \} + /// Aliases. /// \{ - /// Alliases. + typedef grid_<1> grid1d; + typedef point1d_<int> point1d; typedef dpoint1d_<int> dpoint1d; Index: oln/core/1d/image1d.hh --- oln/core/1d/image1d.hh (revision 636) +++ oln/core/1d/image1d.hh (working copy) @@ -30,6 +30,7 @@ # define OLN_CORE_1D_IMAGE1D_HH # include <oln/core/image_entry.hh> +# include <oln/core/gen/grid.hh> # include <oln/core/gen/topo_lbbox.hh> # include <oln/core/internal/tracked_ptr.hh> # include <oln/core/1d/array1d.hh> Index: oln/core/2d/aliases.hh --- oln/core/2d/aliases.hh (revision 636) +++ oln/core/2d/aliases.hh (working copy) @@ -33,8 +33,9 @@ namespace oln { - /// \{ /// Forward declarations. + /// \{ + template <unsigned D> struct grid_; template <typename C> class point2d_; template <typename C> class dpoint2d_; template <typename D> class neighb_; @@ -46,12 +47,13 @@ template <typename P> class fwd_qiter_win_; // FIXME: Not yet available. // template <typename P> class bkd_qiter_win_; - class grid2d; /// \} + /// Aliases. /// \{ - /// Alliases. + typedef grid_<2> grid2d; + typedef point2d_<int> point2d; typedef dpoint2d_<int> dpoint2d; Index: oln/core/2d/image2d.hh --- oln/core/2d/image2d.hh (revision 636) +++ oln/core/2d/image2d.hh (working copy) @@ -30,6 +30,7 @@ # define OLN_CORE_2D_IMAGE2D_HH # include <oln/core/image_entry.hh> +# include <oln/core/gen/grid.hh> # include <oln/core/gen/topo_lbbox.hh> # include <oln/core/internal/tracked_ptr.hh> # include <oln/core/2d/array2d.hh> Index: oln/core/3d/aliases.hh --- oln/core/3d/aliases.hh (revision 636) +++ oln/core/3d/aliases.hh (working copy) @@ -33,8 +33,9 @@ namespace oln { - /// \{ /// Forward declarations. + /// \{ + template <unsigned D> struct grid_; template <typename C> class point3d_; template <typename C> class dpoint3d_; template <typename D> class neighb_; @@ -46,12 +47,13 @@ template <typename P> class fwd_qiter_win_; // FIXME: Not yet available. // template <typename P> class bkd_qiter_win_; - class grid3d; /// \} - /// \{ /// Alliases. + /// \{ + typedef grid_<3> grid3d; + typedef point3d_<int> point3d; typedef dpoint3d_<int> dpoint3d; Index: oln/core/3d/image3d.hh --- oln/core/3d/image3d.hh (revision 636) +++ oln/core/3d/image3d.hh (working copy) @@ -30,6 +30,7 @@ # define OLN_CORE_3D_IMAGE3D_HH # include <oln/core/image_entry.hh> +# include <oln/core/gen/grid.hh> # include <oln/core/gen/topo_lbbox.hh> # include <oln/core/internal/tracked_ptr.hh> # include <oln/core/3d/array3d.hh> Index: oln/core/gen/grid.hh --- oln/core/gen/grid.hh (revision 0) +++ oln/core/gen/grid.hh (revision 0) @@ -0,0 +1,68 @@ +// Copyright (C) 2005, 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 tog +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef OLN_CORE_GEN_GRID_HH +# define OLN_CORE_GEN_GRID_HH + +# include <mlc/int.hh> +# include <oln/core/abstract/grid.hh> + + +namespace oln +{ + + // Forward declaration. + template <unsigned D> struct grid_; + + + /// Super type declaration. + template <unsigned D> + struct set_super_type< grid_<D> > + { + typedef abstract::grid< grid_<D> > ret; + }; + + + /// Virtual types associated to oln::grid1d. + template <unsigned D> + struct vtypes< grid_<D> > + { + typedef mlc::uint_<D> dimvalue_type; + }; + + /// A 1D grid. + template <unsigned D> + struct grid_ : public stc_get_supers(grid_<D>) + { + protected: + grid_() {} + }; + +} // end of namespace oln + + +#endif // ! OLN_CORE_GEN_GRID_HH Index: oln/basics2d.hh --- oln/basics2d.hh (revision 636) +++ oln/basics2d.hh (working copy) @@ -32,7 +32,7 @@ # include <oln/core/2d/aliases.hh> -# include <oln/core/2d/grid2d.hh> +# include <oln/core/gen/grid.hh> # include <oln/core/2d/point2d.hh> # include <oln/core/2d/dpoint2d.hh> Index: oln/Makefile.am --- oln/Makefile.am (revision 636) +++ oln/Makefile.am (working copy) @@ -9,7 +9,6 @@ core/1d/array1d.hh \ core/1d/bbox1d.hh \ core/1d/dpoint1d.hh \ - core/1d/grid1d.hh \ core/1d/image1d.hh \ core/1d/neighb1d.hh \ core/1d/point1d.hh \ @@ -18,7 +17,6 @@ core/2d/array2d.hh \ core/2d/bbox2d.hh \ core/2d/dpoint2d.hh \ - core/2d/grid2d.hh \ core/2d/image2d.hh \ core/2d/neighb2d.hh \ core/2d/point2d.hh \ @@ -27,7 +25,6 @@ core/3d/array3d.hh \ core/3d/bbox3d.hh \ core/3d/dpoint3d.hh \ - core/3d/grid3d.hh \ core/3d/image3d.hh \ core/3d/neighb3d.hh \ core/3d/point3d.hh \ @@ -111,6 +108,7 @@ core/gen/fwd_niter_neighb.hh \ core/gen/fwd_piter_bbox.hh \ core/gen/fwd_qiter_win.hh \ + core/gen/grid.hh \ core/gen/mapimage.hh \ core/gen/neighb.hh \ core/gen/topo_add_nbh.hh \ Index: oln/basics3d.hh --- oln/basics3d.hh (revision 636) +++ oln/basics3d.hh (working copy) @@ -32,7 +32,7 @@ # include <oln/core/3d/aliases.hh> -# include <oln/core/3d/grid3d.hh> +# include <oln/core/gen/grid.hh> # include <oln/core/3d/point3d.hh> # include <oln/core/3d/dpoint3d.hh>