
https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from Roland Levillain <roland@lrde.epita.fr> Add grids. * oln/core/abstract/grid.hh, * oln/core/1d/grid1d.hh, * oln/core/2d/grid2d.hh, * oln/core/3d/grid3d.hh: New files (imported from Olena proto-1.0, and modified). * oln/core/typedefs.hh (grid_type, point_type, dpoint_type) (size_type, dimvalue_type, coord_type): Enable these types. * oln/core/abstract/image.hh (grid_type): Don't mlc-declare this typedef, since oln/core/typedefs.hh already takes care of it. (vtypes< category::image, abstract::image<I> >): Enable grid_type. (packed_vtypes): Likewise. * oln/core/abstract/internal/image_impl.hh: Improve comment. * tests/grid.cc: New test. * tests/image_entry.cc: Update this test. * oln/Makefile.am (nobase_oln_HEADERS): Add core/abstract/grid.hh, core/1d/grid1d.hh, core/2d/grid2d.hh and core/3d/grid3d.hh. * tests/Makefile.am (check_PROGRAMS): Add grid. (grid_SOURCES): New. oln/Makefile.am | 7 +++ oln/core/1d/grid1d.hh | 45 ++++++++++------------ oln/core/2d/grid2d.hh | 33 +++++++--------- oln/core/3d/grid3d.hh | 32 +++++++--------- oln/core/abstract/grid.hh | 62 ++++++++++++++++++------------- oln/core/abstract/image.hh | 21 ++++------ oln/core/abstract/internal/image_impl.hh | 2 - oln/core/typedefs.hh | 24 +++++------- tests/Makefile.am | 2 + tests/grid.cc | 44 ++++++++++++++++++++++ tests/image_entry.cc | 8 ++-- 11 files changed, 166 insertions(+), 114 deletions(-) Index: tests/image_entry.cc --- tests/image_entry.cc (revision 469) +++ tests/image_entry.cc (working copy) @@ -27,12 +27,13 @@ /// Test oln::abstract::image_entry. +#include <oln/core/1d/grid1d.hh> #include <oln/core/abstract/image_entry.hh> #include <oln/core/abstract/image_dimension.hh> namespace my { - // Fwd decl. + // Forward declaration. class image; } @@ -41,7 +42,7 @@ // Warning, this sugar might be removed in the future. stc_set_super(my::image, abstract::image_entry<my::image>); - /// Virtual types associated to my::A. + /// Virtual types associated to my::image. template<> struct vtypes<category::image, my::image> { @@ -51,13 +52,14 @@ // the right image_dimension class using the sole grid information // (the grid can be seen here as a ``tag''). typedef stc::is_a<abstract::image1d> image_dimension_type; + typedef oln::grid1d grid_type; }; } namespace my { // A very simple 1D image. - class image : public oln::set_super_type<image>::ret + class image : public oln::set_super_type<my::image>::ret { typedef image self_type; typedef oln_type_of_(self_type, image_dimension) image_dimension_type; Index: tests/Makefile.am --- tests/Makefile.am (revision 469) +++ tests/Makefile.am (working copy) @@ -10,8 +10,10 @@ # when oln.m4 is available in the distribution. check_PROGRAMS = \ + grid \ image_entry image_entry_SOURCES = image_entry.cc +grid_SOURCES = grid.cc TESTS = $(check_PROGRAMS) Index: tests/grid.cc --- tests/grid.cc (revision 0) +++ tests/grid.cc (revision 0) @@ -0,0 +1,44 @@ +// 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 grids. + +#include <cassert> +#include <oln/core/1d/grid1d.hh> +#include <oln/core/2d/grid2d.hh> +#include <oln/core/3d/grid3d.hh> + +int +main() +{ + // The extra pairs of parenthesis around mlc_value are needed to + // prevent the assert macro from interpreting the arguments of + // mlc_value as its own. + assert((mlc_value(oln_grd_type_of_(oln::grid1d, dimvalue))) == 1); + assert((mlc_value(oln_grd_type_of_(oln::grid2d, dimvalue))) == 2); + assert((mlc_value(oln_grd_type_of_(oln::grid3d, dimvalue))) == 3); +} Index: oln/core/typedefs.hh --- oln/core/typedefs.hh (revision 469) +++ oln/core/typedefs.hh (working copy) @@ -68,11 +68,7 @@ // General. -// -------------------------------------------------------------------- -// FIXME: To be enabled later. -// -------------------------------------------------------------------- -// mlc_decl_typedef(grid_type); -// -------------------------------------------------------------------- + mlc_decl_typedef(grid_type); // Iterators. @@ -106,17 +102,21 @@ // mlc_decl_typedef(neighb_type); // mlc_decl_typedef(value_storage_type); // mlc_decl_typedef(storage_type); -// mlc_decl_typedef(point_type); -// mlc_decl_typedef(dpoint_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(delegated_type); + mlc_decl_typedef(size_type); // -------------------------------------------------------------------- // FIXME: To be enabled later. // -------------------------------------------------------------------- -// mlc_decl_typedef(size_type); // mlc_decl_typedef(window_type); // mlc_decl_typedef(image_neighbness_type); @@ -145,12 +145,8 @@ // category::grid. -// -------------------------------------------------------------------- -// FIXME: To be enabled later. -// -------------------------------------------------------------------- -// mlc_decl_typedef(dimvalue_type); -// mlc_decl_typedef(coord_type); -// -------------------------------------------------------------------- + mlc_decl_typedef(dimvalue_type); + mlc_decl_typedef(coord_type); // category::fun1 and category::fun2. Index: oln/core/abstract/image.hh --- oln/core/abstract/image.hh (revision 469) +++ oln/core/abstract/image.hh (working copy) @@ -37,11 +37,11 @@ namespace oln { - // fwd decl + // Forward declaration. template <typename I> class value_box; - // fwd decls + // Forward declarations. namespace abstract { template <typename I> class image; @@ -55,19 +55,16 @@ // -------------------------------------------------------------------- } - // Declare virtual types. - mlc_decl_typedef(grid_type); - /// Virtual types associated to oln::abstract::image. template <typename I> struct vtypes< category::image, abstract::image<I> > { typedef I exact_type; + typedef mlc::undefined grid_type; // -------------------------------------------------------------------- // FIXME: To be enabled later. // -------------------------------------------------------------------- -// typedef mlc::undefined grid_type; // typedef mlc::undefined concrete_type; // typedef mlc::undefined value_type; // typedef mlc::undefined point_type; @@ -97,11 +94,11 @@ template <typename I> struct packed_vtypes<category::image, I> { + typedef oln_type_of(I, grid) grid_type; + // -------------------------------------------------------------------- // FIXME: To be enabled later. // -------------------------------------------------------------------- -// typedef oln_type_of(I, grid) grid_type; - // typedef oln_type_of(I, concrete) concrete_type; // typedef oln_type_of(I, value) value_type; // typedef oln_type_of(I, point) point_type; @@ -135,11 +132,11 @@ << "vtypes_of(oln::category::image, " << mlc_to_string(I) << ") =" << std::endl << "{" << std::endl + << " grid_type = " << mlc_to_string(grid_type) << std::endl + // -------------------------------------------------------------------- // FIXME: To be enabled later. // -------------------------------------------------------------------- -// << " grid_type = " << mlc_to_string(grid_type) << std::endl - // << " concrete_type = " << mlc_to_string(concrete_type) << std::endl // << " value_type = " << mlc_to_string(value_type) << std::endl // << " point_type = " << mlc_to_string(point_type) << std::endl @@ -168,10 +165,10 @@ static void ensure() { + mlc::assert_< mlc_is_ok(grid_type) >::check(); // -------------------------------------------------------------------- // FIXME: To be enabled later. // -------------------------------------------------------------------- -// mlc::assert_< mlc_is_ok(grid_type) >::check(); // mlc::assert_< mlc_is_ok(concrete_type) >::check(); // mlc::assert_< mlc_is_ok(value_type) >::check(); // mlc::assert_< mlc_is_ok(point_type) >::check(); @@ -181,7 +178,7 @@ // 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();x +// mlc::assert_< mlc_is_ok(storage_type) >::check(); // -------------------------------------------------------------------- mlc::assert_< mlc_is_ok(delegated_type) >::check(); // -------------------------------------------------------------------- Index: oln/core/abstract/grid.hh --- oln/core/abstract/grid.hh (revision 0) +++ oln/core/abstract/grid.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory +// 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 @@ -12,8 +12,8 @@ // // 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, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. +// 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 @@ -28,39 +28,49 @@ #ifndef OLENA_CORE_ABSTRACT_GRID_HH # define OLENA_CORE_ABSTRACT_GRID_HH +# include <mlc/assert.hh> +# include <mlc/cmp.hh> +# include <mlc/to_string.hh> # include <oln/core/abstract/any.hh> # include <oln/core/typedefs.hh> # define oln_grd_type_of(GridType, Alias) \ -mlc_type_of(oln, oln::category::grid, GridType, Alias) +stc_typeof_in_namespace(oln, oln::category::grid, GridType, Alias) # define oln_grd_type_of_(GridType, Alias) \ -mlc_type_of_(oln, oln::category::grid, GridType, Alias) +stc_typeof_in_namespace_(oln, oln::category::grid, GridType, Alias) namespace oln { + /// Category grid. namespace category { struct grid; } + // Forward declaration. + namespace abstract + { + template <typename G> class grid; + } - template <> - struct set_default_props < category::grid > + /// Virtual types associated to oln::abstract::image. + template <typename G> + struct vtypes< category::grid, abstract::grid<G> > { - typedef mlc::undefined_type point_type; - typedef mlc::no_type dpoint_type; - typedef mlc::undefined_type size_type; - typedef mlc::undefined_type coord_type; - typedef mlc::undefined_type dimvalue_type; + typedef mlc::undefined point_type; + typedef mlc::none dpoint_type; + typedef mlc::undefined size_type; + typedef mlc::undefined coord_type; + typedef mlc::undefined dimvalue_type; }; template <typename G> - struct get_props < category::grid, G > + struct packed_vtypes<category::grid, G> { typedef oln_grd_type_of(G, point) point_type; typedef oln_grd_type_of(G, dpoint) dpoint_type; @@ -70,23 +80,25 @@ static void echo(std::ostream& ostr) { - ostr << "props_of( oln::category::grid, " << mlc_to_string(G) << " ) =" << std::endl + ostr + << "vtypes(oln::category::grid, " << mlc_to_string(G) << ") =" + << std::endl << "{" << std::endl - << "\t point_type = " << mlc_to_string(point_type) << std::endl - << "\t dpoint_type = " << mlc_to_string(dpoint_type) << std::endl - << "\t coord_type = " << mlc_to_string(coord_type) << std::endl - << "\t size_type = " << mlc_to_string(size_type) << std::endl - << "\t dimvalue_type = " << mlc_to_string(dimvalue_type) << std::endl + << " point_type = " << mlc_to_string(point_type) << std::endl + << " dpoint_type = " << mlc_to_string(dpoint_type) << std::endl + << " coord_type = " << mlc_to_string(coord_type) << std::endl + << " size_type = " << mlc_to_string(size_type) << std::endl + << " dimvalue_type = " << mlc_to_string(dimvalue_type) << std::endl << "}" << std::endl; } static void ensure() { - mlc::is_ok< point_type >::ensure(); - mlc::is_ok< dpoint_type >::ensure(); - mlc::is_ok< coord_type >::ensure(); - mlc::is_ok< size_type >::ensure(); - mlc::is_ok< dimvalue_type >::ensure(); + mlc::assert_< mlc_is_ok(point_type) >::check(); + mlc::assert_< mlc_is_ok(dpoint_type) >::check(); + mlc::assert_< mlc_is_ok(coord_type) >::check(); + mlc::assert_< mlc_is_ok(size_type) >::check(); + mlc::assert_< mlc_is_ok(dimvalue_type) >::check(); } }; @@ -102,7 +114,7 @@ ~grid() { - get_props<category::grid, E>::ensure(); + packed_vtypes<category::grid, E>::ensure(); } }; Index: oln/core/abstract/internal/image_impl.hh --- oln/core/abstract/internal/image_impl.hh (revision 469) +++ oln/core/abstract/internal/image_impl.hh (working copy) @@ -38,7 +38,7 @@ namespace oln { - /// Image category. + /// Category image. namespace category { struct image; Index: oln/core/1d/grid1d.hh --- oln/core/1d/grid1d.hh (revision 0) +++ oln/core/1d/grid1d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory +// 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 @@ -11,9 +11,9 @@ // 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, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. +// 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 @@ -28,45 +28,42 @@ #ifndef OLENA_CORE_1D_GRID1D_HH # define OLENA_CORE_1D_GRID1D_HH -# include <mlc/value.hh> +# include <mlc/int.hh> # include <oln/core/abstract/grid.hh> -namespace oln { +namespace oln +{ - // fwd decls - struct grid1d; - struct point1d; - struct dpoint1d; - struct size1d; - struct coord_t; + // Forward declarations. + class grid1d; + class point1d; + class dpoint1d; + class size1d; + class coord_t; - // super type - template <> - struct set_super_type < grid1d > { typedef abstract::grid< grid1d > ret; }; + // Super type. + stc_set_super(grid1d, abstract::grid<grid1d>); - // props + /// Virtual types associated to oln::grid1d. template <> - struct set_props < category::grid, grid1d > + struct vtypes<category::grid, grid1d> { typedef point1d point_type; typedef dpoint1d dpoint_type; typedef coord_t coord_type; typedef size1d size_type; - typedef mlc::value<unsigned,1> dimvalue_type; + typedef mlc::uint_<1> dimvalue_type; }; - - - struct grid1d : public abstract::grid< grid1d > + /// A 1-dimension rectangular grid. + struct grid1d : public stc_super_(grid1d) { protected: - grid1d() - {} + grid1d() {} }; } // end of namespace oln - #endif // ! OLENA_CORE_1D_GRID1D_HH Index: oln/core/2d/grid2d.hh --- oln/core/2d/grid2d.hh (revision 0) +++ oln/core/2d/grid2d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory +// 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 @@ -12,8 +12,8 @@ // // 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, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. +// 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 @@ -28,45 +28,42 @@ #ifndef OLENA_CORE_2D_GRID2D_HH # define OLENA_CORE_2D_GRID2D_HH -# include <mlc/value.hh> +# include <mlc/int.hh> # include <oln/core/abstract/grid.hh> -namespace oln { +namespace oln +{ - // fwd decls + // Forward declarations. struct grid2d; struct point2d; struct dpoint2d; struct size2d; struct coord_t; - // super type - template <> - struct set_super_type < grid2d > { typedef abstract::grid< grid2d > ret; }; + // Super type. + stc_set_super(grid2d, abstract::grid<grid2d>); - // props + /// Virtual types associated to oln::grid2d. template <> - struct set_props < category::grid, grid2d > + struct vtypes<category::grid, grid2d> { typedef point2d point_type; typedef dpoint2d dpoint_type; typedef size2d size_type; typedef coord_t coord_type; - typedef mlc::value<unsigned,2> dimvalue_type; + typedef mlc::uint_<2> dimvalue_type; }; - - - struct grid2d : public abstract::grid< grid2d > + /// A 2-dimension rectangular grid. + struct grid2d : public stc_super_(grid2d) { protected: - grid2d() - {} + grid2d() {} }; } // end of namespace oln - #endif // ! OLENA_CORE_2D_GRID2D_HH Index: oln/core/3d/grid3d.hh --- oln/core/3d/grid3d.hh (revision 0) +++ oln/core/3d/grid3d.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2005 EPITA Research and Development Laboratory +// 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 @@ -12,8 +12,8 @@ // // 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, 59 Temple Place - Suite 330, Boston, -// MA 02111-1307, USA. +// 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 @@ -28,41 +28,39 @@ #ifndef OLENA_CORE_3D_GRID3D_HH # define OLENA_CORE_3D_GRID3D_HH -# include <mlc/value.hh> +# include <mlc/int.hh> # include <oln/core/abstract/grid.hh> -namespace oln { +namespace oln +{ - // fwd decls + // Forward declarations. struct grid3d; struct point3d; struct dpoint3d; struct size3d; struct coord_t; - // super type - template <> - struct set_super_type < grid3d > { typedef abstract::grid< grid3d > ret; }; + // Super type. + stc_set_super(grid3d, abstract::grid<grid3d>); - // props + /// Virtual types associated to oln::grid3d. template <> - struct set_props < category::grid, grid3d > + struct vtypes<category::grid, grid3d> { typedef point3d point_type; typedef dpoint3d dpoint_type; typedef size3d size_type; typedef coord_t coord_type; - typedef mlc::value<unsigned,2> dimvalue_type; + typedef mlc::uint_<3> dimvalue_type; }; - - - struct grid3d : public abstract::grid< grid3d > + /// A 3-dimension rectangular grid. + struct grid3d : public stc_super_(grid3d) { protected: - grid3d() - {} + grid3d() {} }; } // end of namespace oln Index: oln/Makefile.am --- oln/Makefile.am (revision 469) +++ oln/Makefile.am (working copy) @@ -4,7 +4,14 @@ nobase_oln_HEADERS = \ core/typedefs.hh \ \ + core/1d/grid1d.hh \ + \ + core/2d/grid2d.hh \ + \ + core/3d/grid3d.hh \ + \ core/abstract/any.hh \ + core/abstract/grid.hh \ core/abstract/image.hh \ core/abstract/image_entry.hh \ core/abstract/image_dimension.hh \