Commit 34b029a5 authored by Roland Levillain's avatar Roland Levillain
Browse files

Fix the current implementation of image_entry, as well as some

	tests.

	* oln/core/abstract/internal/image_impl.hh (oln::category::image):
	Move this declaration...
	* oln/core/abstract/image.hh: ...here.
	* oln/core/case.hh: New file.
	* oln/core/abstract/image_abstractions.hh,
	* olena/oln/core/abstract/entry.hh,
	* oln/core/traits.hh: Use it.
	* oln/Makefile.am (nobase_oln_HEADERS): Add core/case.hh.

	* oln/core/abstract/image_dimension.hh
	(oln::ERROR::UNKNOWN_GRID_TYPE): New.
	(oln::default_case_<grid_dim_tag, grid_type): Use it.
	(ext_vtype_in_category): Turn into...
	(ext_vtype): ...this.
	* oln/core/abstract/image_typeness.hh (ext_vtype_in_category):
	Turn into...
	(ext_vtype): ...this.

	* oln/core/typedefs.hh (oln_type_of, oln_type_of_): Move
	these macros...
	* oln/core/abstract/macros.hh: ...here, and replace the previous
	ones.
	Rename file as...
	* oln/core/macros.hh: ...this.
	Adjust header guards.
	* oln/core/abstract/internal/image_impl.hh: Adjust users.
	* oln/Makefile.am (nobase_oln_HEADERS): Remove
	core/abstract/macros.hh.
	Add core/macros.hh

	* oln/core/abstract/grid.hh (oln_grd_type_of, oln_grd_type_of_):
	Remove macros.
	(vtypes_in_category< category::grid, abstract::grid<G> >): Turn
	into...
	(vtypes< abstract::grid<G> >): ...this.
	(packed_vtypes_in_category<category::grid, G>):
	s/oln_grd_type_of/oln_type_of/g.
	* oln/core/1d/grid1d.hh, oln/core/2d/grid2d.hh,
	* oln/core/3d/grid3d.hh (vtypes_in_category): Turn into...
	(vtypes): ...this.

	* tests/grid.cc: s/oln_grd_type_of_/oln_type_of_/g
	* tests/image_entry.cc (my::dummy): New declaration.
	(vtypes_in_category<category::image, my::image>): Turn into...
	(vtypes<my::image>): ...this.
	Add missing virtual types.
	(my::image): Fix base class.
	(main): Remove any references to
	packed_vtypes_in_category<oln::category::image, my::image>, since
	it no longer exists.
	* tests/Makefile.am (AM_CPPFLAGS): Add -I$(top_srcdir)/extended.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@529 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent c2111331
2006-09-12 Roland Levillain <roland@lrde.epita.fr>
Fix the current implementation of image_entry, as well as some
tests.
* oln/core/abstract/internal/image_impl.hh (oln::category::image):
Move this declaration...
* oln/core/abstract/image.hh: ...here.
* oln/core/case.hh: New file.
* oln/core/abstract/image_abstractions.hh,
* olena/oln/core/abstract/entry.hh,
* oln/core/traits.hh: Use it.
* oln/Makefile.am (nobase_oln_HEADERS): Add core/case.hh.
* oln/core/abstract/image_dimension.hh
(oln::ERROR::UNKNOWN_GRID_TYPE): New.
(oln::default_case_<grid_dim_tag, grid_type): Use it.
(ext_vtype_in_category): Turn into...
(ext_vtype): ...this.
* oln/core/abstract/image_typeness.hh (ext_vtype_in_category):
Turn into...
(ext_vtype): ...this.
* oln/core/typedefs.hh (oln_type_of, oln_type_of_): Move
these macros...
* oln/core/abstract/macros.hh: ...here, and replace the previous
ones.
Rename file as...
* oln/core/macros.hh: ...this.
Adjust header guards.
* oln/core/abstract/internal/image_impl.hh: Adjust users.
* oln/Makefile.am (nobase_oln_HEADERS): Remove
core/abstract/macros.hh.
Add core/macros.hh
* oln/core/abstract/grid.hh (oln_grd_type_of, oln_grd_type_of_):
Remove macros.
(vtypes_in_category< category::grid, abstract::grid<G> >): Turn
into...
(vtypes< abstract::grid<G> >): ...this.
(packed_vtypes_in_category<category::grid, G>):
s/oln_grd_type_of/oln_type_of/g.
* oln/core/1d/grid1d.hh, oln/core/2d/grid2d.hh,
* oln/core/3d/grid3d.hh (vtypes_in_category): Turn into...
(vtypes): ...this.
* tests/grid.cc: s/oln_grd_type_of_/oln_type_of_/g
* tests/image_entry.cc (my::dummy): New declaration.
(vtypes_in_category<category::image, my::image>): Turn into...
(vtypes<my::image>): ...this.
Add missing virtual types.
(my::image): Fix base class.
(main): Remove any references to
packed_vtypes_in_category<oln::category::image, my::image>, since
it no longer exists.
* tests/Makefile.am (AM_CPPFLAGS): Add -I$(top_srcdir)/extended.
2006-09-07 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add image2d and fix topo-related classes.
......
......@@ -2,8 +2,6 @@
olndir = $(includedir)/oln
nobase_oln_HEADERS = \
core/typedefs.hh \
\
core/1d/grid1d.hh \
\
core/2d/grid2d.hh \
......@@ -18,6 +16,9 @@ nobase_oln_HEADERS = \
core/abstract/image_dimension.hh \
core/abstract/image_typeness.hh \
core/abstract/image_typeness_integre.hh \
core/abstract/macros.hh \
\
core/abstract/internal/image_impl.hh
core/abstract/internal/image_impl.hh \
\
core/case.hh \
core/macros.hh \
core/typedefs.hh
......@@ -47,7 +47,7 @@ namespace oln
/// Virtual types associated to oln::grid1d.
template <>
struct vtypes_in_category<category::grid, grid1d>
struct vtypes<grid1d>
{
typedef point1d point_type;
typedef dpoint1d dpoint_type;
......
......@@ -47,7 +47,7 @@ namespace oln
/// Virtual types associated to oln::grid2d.
template <>
struct vtypes_in_category<category::grid, grid2d>
struct vtypes<grid2d>
{
typedef point2d point_type;
typedef dpoint2d dpoint_type;
......
......@@ -47,7 +47,7 @@ namespace oln
/// Virtual types associated to oln::grid3d.
template <>
struct vtypes_in_category<category::grid, grid3d>
struct vtypes<grid3d>
{
typedef point3d point_type;
typedef dpoint3d dpoint_type;
......
......@@ -29,7 +29,7 @@
# define OLENA_CORE_ABSTRACT_ENTRY_HH
# include <oln/core/typedefs.hh>
# include <oln/core/case.hh>
namespace oln
{
......
......@@ -35,13 +35,6 @@
# include <oln/core/typedefs.hh>
# define oln_grd_type_of(GridType, Alias) \
stc_type_of(oln, oln::category::grid, GridType, Alias)
# define oln_grd_type_of_(GridType, Alias) \
stc_type_of_(oln, oln::category::grid, GridType, Alias)
namespace oln {
......@@ -59,7 +52,7 @@ namespace oln {
/// Virtual types associated to oln::abstract::image.
template <typename G>
struct vtypes_in_category< category::grid, abstract::grid<G> >
struct vtypes< abstract::grid<G> >
{
typedef mlc::undefined point_type;
typedef mlc::none dpoint_type;
......@@ -72,11 +65,11 @@ namespace oln {
template <typename G>
struct packed_vtypes_in_category<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;
typedef oln_type_of(G, point) point_type;
typedef oln_type_of(G, dpoint) dpoint_type;
typedef oln_type_of(G, coord) coord_type;
typedef oln_type_of(G, size) size_type;
typedef oln_type_of(G, dimvalue) dimvalue_type;
static void echo(std::ostream& ostr)
{
......
......@@ -33,10 +33,16 @@
// # include <oln/core/abstract/internal/image_impl.hh>
namespace oln
{
/// Category image.
namespace category
{
struct image;
}
/*! \namespace oln::abstract
** \brief oln::abstract namespace.
*/
......
......@@ -28,10 +28,7 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
# include <mlc/case.hh>
// Add switch/case equipment in the oln namespace.
mlc_case_equipment_for_namespace(oln);
# include <oln/core/case.hh>
namespace oln
......
......@@ -107,6 +107,24 @@ namespace oln
} // end of namespace oln
/*-----------------.
| Error messages. |
`-----------------*/
namespace oln
{
/// Error messages raised by static assertions.
namespace ERROR
{
template <typename Grid>
struct UNKNOWN_GRID_TYPE;
} // end of namespace oln::ERROR
} // end of namespace oln
/*-------------------.
| Dimension switch. |
`-------------------*/
......@@ -176,7 +194,7 @@ namespace oln
template <typename grid_type>
struct default_case_<grid_dim_tag, grid_type>
{
typedef mlc::abort_<grid_dim_tag> ret;
typedef mlc::abort_< grid_dim_tag, ERROR::UNKNOWN_GRID_TYPE<grid_type> > ret;
};
/// \}
......@@ -192,10 +210,9 @@ namespace oln
{
/// Image dimension type as an extended vtype of abstract::image.
template <typename I>
struct ext_vtype_in_category< category::image,
abstract::image<I>,
// FIXME: Get rid of this typedef_:: qualifier.
typedef_::image_dimension_type >
struct ext_vtype< abstract::image<I>,
// FIXME: Get rid of this typedef_:: qualifier.
typedef_::image_dimension_type >
{
// Use the same switch as the one use in the inheritance-plugging
// mechanism above.
......
......@@ -308,10 +308,9 @@ namespace oln
{
/// Image ``typeness'' as an extended vtype of abstract::image.
template <typename I>
struct ext_vtype_in_category< category::image,
abstract::image<I>,
// FIXME: Get rid of this typedef_:: qualifier.
typedef_::image_typeness_type >
struct ext_vtype< abstract::image<I>,
// FIXME: Get rid of this typedef_:: qualifier.
typedef_::image_typeness_type >
{
// Use the same case as the one use in the inheritance-plugging
// mechanism above, but retrieve the extended vtype
......
......@@ -31,19 +31,13 @@
# include <mlc/flags.hh>
# include <oln/core/typedefs.hh>
# include <oln/core/abstract/any.hh>
# include <oln/core/abstract/macros.hh>
# include <oln/core/macros.hh>
// FIXME: To be rewtitten using Metalic's switch/case?
namespace oln
{
/// Category image.
namespace category
{
struct image;
}
namespace abstract
{
......
// 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.
/** \file oln/core/case.hh
\brief Switch/case equipment for the oln namespace.
Use this file to avoid unnecessary (duplicated) expansions of case_. */
#ifndef OLENA_CORE_CASE_HH
# define OLENA_CORE_CASE_HH
# include <mlc/case.hh>
mlc_case_equipment_for_namespace(oln);
#endif // ! OLENA_CORE_CASE_HH
......@@ -25,17 +25,23 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_MACROS_HH
# define OLENA_CORE_ABSTRACT_MACROS_HH
#ifndef OLENA_CORE_MACROS_HH
# define OLENA_CORE_MACROS_HH
/// \def Shortcuts for virtual types associated to images (version to
// be used inside a template).
# define oln_type_of(ImageType, Alias) \
stc_type_of(oln, oln::category::image, ImageType, Alias)
/// \def oln_type_of(OlnType, Alias)
///
/// Macro to retrieve an associated type \a Alias from an oln type
/// \a OlnType whose category is not specified (version to be used inside
/// a template).
# define oln_type_of(OlnType, Alias) \
stc_type_of(oln, void, OlnType, Alias)
/// \def Shortcuts for virtual types associated to images (version to
// be used outside a template).
# define oln_type_of_(ImageType, Alias) \
stc_type_of_(oln, oln::category::image, ImageType, Alias)
/// \def oln_type_of(OlnType, Alias)
///
/// Macro to retrieve an associated type \a Alias from an oln type
/// \a OlnType whose category is not specified (version to be used
/// outside a template).
# define oln_type_of_(OlnType, Alias) \
stc_type_of_(oln, void, OlnType, Alias)
#endif // ! OLENA_CORE_ABSTRACT_MACROS_HH
#endif // ! OLENA_CORE_MACROS_HH
......@@ -30,16 +30,12 @@
# include <mlc/assert.hh>
# include <mlc/case.hh>
# include <mlc/abort.hh>
# include <xtd/optraits.hh>
# include <stc/exact.hh>
# include <oln/core/type.hh>
mlc_case_equipment_for_namespace(oln);
# include <oln/core/case.hh>
namespace oln
......
......@@ -44,20 +44,8 @@
# include <stc/vtypes.hh>
# include <oln/core/type.hh>
/*! \macro oln_type_of(OlnType, Alias)
**
** Macro to retrieve an associated type \Alias from an oln type
** \OlnType whose category is not specified.
*/
# define oln_type_of(OlnType, Alias) \
stc_type_of(oln, void, OlnType, Alias)
# define oln_type_of_(OlnType, Alias) \
stc_type_of_(oln, void, OlnType, Alias)
// FIXME: Move to oln/core.
# include <oln/core/macros.hh>
namespace oln
......
## Process this file through Automake to create Makefile.in -*- Makefile -*-
AM_CPPFLAGS = \
-I$(top_srcdir)/olena -I$(top_srcdir)/static \
-I$(top_srcdir)/metalic
AM_CPPFLAGS = \
-I$(top_srcdir)/olena -I$(top_srcdir)/extended \
-I$(top_srcdir)/static -I$(top_srcdir)/metalic
# FIXME: Add
#
# AM_CXXFLAGS = $(CXXFLAGS_STRICT) $(CXXFLAGS_OPTIMIZE) -ggdb
......
......@@ -38,7 +38,7 @@ 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);
assert((mlc_value(oln_type_of_(oln::grid1d, dimvalue))) == 1);
assert((mlc_value(oln_type_of_(oln::grid2d, dimvalue))) == 2);
assert((mlc_value(oln_type_of_(oln::grid3d, dimvalue))) == 3);
}
......@@ -34,11 +34,13 @@
#include <oln/core/1d/grid1d.hh>
#include <oln/core/abstract/image_entry.hh>
namespace my
{
// Forward declaration.
class image;
struct image;
// Dummy type.
struct dummy;
}
namespace oln
......@@ -48,7 +50,7 @@ namespace oln
/// Virtual types associated to my::image.
template<>
struct vtypes_in_category<category::image, my::image>
struct vtypes<my::image>
{
// The switch for image_dimension (above image_entry) plugs the
// inheritance relation to the right abstract::image_dimension
......@@ -59,13 +61,23 @@ namespace oln
// Likewise, for the switch of image_typeness using the type of
// the value of the image.
typedef char value_type;
// FIXME: Dummy values.
typedef my::dummy topo_type;
typedef my::dummy psite_type;
typedef my::dummy rvalue_type;
typedef my::dummy point_type;
typedef my::dummy piter_type;
typedef my::dummy fwd_piter_type;
typedef my::dummy bkd_piter_type;
typedef my::dummy concrete_type;
};
}
namespace my
{
// A very simple 1-D image.
class image : public oln::set_super_type<my::image>::ret
class image : public oln::get_super_types<my::image>::ret
{
public:
typedef image self_type;
......@@ -78,6 +90,7 @@ namespace my
};
}
int
main()
{
......@@ -102,9 +115,4 @@ main()
// Ensure we can instantiate it.
my::image i;
// Print my::image's vtypes.
// FIXME: To be removed in the final version.
oln::packed_vtypes_in_category< oln::category::image,
my::image >::echo (std::cout);
}
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