Commit ec13303d authored by Roland Levillain's avatar Roland Levillain
Browse files

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.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@470 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 2d1de25d
2006-04-25 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.
2006-04-22 Roland Levillain <roland@lrde.epita.fr>
Fix packed_vtypes<category::image, I>.
......
......@@ -4,7 +4,14 @@ olndir = $(includedir)/oln
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 \
......
// 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 OLENA_CORE_1D_GRID1D_HH
# define OLENA_CORE_1D_GRID1D_HH
# include <mlc/int.hh>
# include <oln/core/abstract/grid.hh>
namespace oln
{
// Forward declarations.
class grid1d;
class point1d;
class dpoint1d;
class size1d;
class coord_t;
// Super type.
stc_set_super(grid1d, abstract::grid<grid1d>);
/// Virtual types associated to oln::grid1d.
template <>
struct vtypes<category::grid, grid1d>
{
typedef point1d point_type;
typedef dpoint1d dpoint_type;
typedef coord_t coord_type;
typedef size1d size_type;
typedef mlc::uint_<1> dimvalue_type;
};
/// A 1-dimension rectangular grid.
struct grid1d : public stc_super_(grid1d)
{
protected:
grid1d() {}
};
} // end of namespace oln
#endif // ! OLENA_CORE_1D_GRID1D_HH
// 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 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_2D_GRID2D_HH
# define OLENA_CORE_2D_GRID2D_HH
# include <mlc/int.hh>
# include <oln/core/abstract/grid.hh>
namespace oln
{
// Forward declarations.
struct grid2d;
struct point2d;
struct dpoint2d;
struct size2d;
struct coord_t;
// Super type.
stc_set_super(grid2d, abstract::grid<grid2d>);
/// Virtual types associated to oln::grid2d.
template <>
struct vtypes<category::grid, grid2d>
{
typedef point2d point_type;
typedef dpoint2d dpoint_type;
typedef size2d size_type;
typedef coord_t coord_type;
typedef mlc::uint_<2> dimvalue_type;
};
/// A 2-dimension rectangular grid.
struct grid2d : public stc_super_(grid2d)
{
protected:
grid2d() {}
};
} // end of namespace oln
#endif // ! OLENA_CORE_2D_GRID2D_HH
// 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 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_3D_GRID3D_HH
# define OLENA_CORE_3D_GRID3D_HH
# include <mlc/int.hh>
# include <oln/core/abstract/grid.hh>
namespace oln
{
// Forward declarations.
struct grid3d;
struct point3d;
struct dpoint3d;
struct size3d;
struct coord_t;
// Super type.
stc_set_super(grid3d, abstract::grid<grid3d>);
/// Virtual types associated to oln::grid3d.
template <>
struct vtypes<category::grid, grid3d>
{
typedef point3d point_type;
typedef dpoint3d dpoint_type;
typedef size3d size_type;
typedef coord_t coord_type;
typedef mlc::uint_<3> dimvalue_type;
};
/// A 3-dimension rectangular grid.
struct grid3d : public stc_super_(grid3d)
{
protected:
grid3d() {}
};
} // end of namespace oln
#endif // ! OLENA_CORE_3D_GRID3D_HH
// 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 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_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) \
stc_typeof_in_namespace(oln, oln::category::grid, GridType, Alias)
# define oln_grd_type_of_(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;
}
/// Virtual types associated to oln::abstract::image.
template <typename G>
struct vtypes< category::grid, abstract::grid<G> >
{
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 packed_vtypes<category::grid, G>
{
typedef oln_grd_type_of(G, point) point_type;
typedef oln_grd_type_of(G, dpoint) dpoint_type;
typedef oln_grd_type_of(G, coord) coord_type;
typedef oln_grd_type_of(G, size) size_type;
typedef oln_grd_type_of(G, dimvalue) dimvalue_type;
static void echo(std::ostream& ostr)
{
ostr
<< "vtypes(oln::category::grid, " << mlc_to_string(G) << ") ="
<< std::endl
<< "{" << 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::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();
}
};
namespace abstract {
template <typename E>
struct grid : public oln::abstract::any<E>
{
protected:
grid()
{}
~grid()
{
packed_vtypes<category::grid, E>::ensure();
}
};
} // end of namespace oln::abstract
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_GRID_HH
......@@ -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 @@ namespace oln {
// --------------------------------------------------------------------
}
// 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 @@ namespace oln {
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 @@ namespace oln {
<< "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 @@ namespace oln {
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 @@ namespace oln {
// 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();
// --------------------------------------------------------------------
......
......@@ -38,7 +38,7 @@
namespace oln
{
/// Image category.
/// Category image.
namespace category
{
struct image;
......
......@@ -68,11 +68,7 @@ namespace oln
// General.
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc_decl_typedef(grid_type);
// --------------------------------------------------------------------
mlc_decl_typedef(grid_type);
// Iterators.
......@@ -106,17 +102,21 @@ namespace oln
// 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 @@ namespace oln
// 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.
......
......@@ -10,8 +10,10 @@ AM_CPPFLAGS = \
# 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)
// 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);
}
......@@ -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 @@ namespace oln
// 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 @@ namespace oln
// 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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment