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

Use the new entry/hierarchy system for images.

	* oln/core/abstract/image_entry.hh: Remove.
	* oln/core/abstract/image_hierarchies.hh: New.
	* oln/core/abstract/image.hh
	(oln/core/abstract/image_hierarchies.hh): Include it.
	* oln/core/image_entry.hh: Aesthetic change.

	* oln/core/abstract/image_dimension.hh:
	Update the documentation.
	(oln::ERROR::UNKNOWN_GRID_TYPE): Remove error message.
	(oln::grid_dim_tag): Remove tag.
	(stc::set_entry_node<I, oln::abstract::dimension_tag>): Remove
	switch.
	(case_<grid_dim_tag, grid_type, 1>)
	(case_<grid_dim_tag, grid_type, 2>)
	(case_<grid_dim_tag, grid_type, 3>): Update and rename as...
	(case_<image_dimension_hierarchy, E, 1>)
	(case_<image_dimension_hierarchy, E, 2>)
	(case_<image_dimension_hierarchy, E, 3>): ...this.
	(default_case_<grid_dim_tag, grid_type>): Remove.
	(oln::ext_vtype<abstract::image<I>, typedef_::image_dimension_type>):
	Remove external vtype.

	* oln/core/abstract/image_typeness.hh: Rename as...
	* oln/core/abstract/image_type.hh: ...this.
	Adjust header guards.
	Update the documentation.
	(oln::value_type_tag): Remove tag.
	(stc::set_entry_node<I, oln::abstract::typeness_tag>): Remove
	switch.
	(case_<value_type_tag, value_type, 1>)
	(case_<value_type_tag, value_type, 2>)
	(default_case_<value_type_tag, value_type>): Update and rename
	as...
	(case_<image_type_hierarchy, E, 1>)
	(case_<image_type_hierarchy, E, 2>)
	(default_case_<image_type_hierarchy, E>): ...this.
	No longer provide an `image_typeness_type' typedef.
	(oln::ext_vtype<abstract::image<I>, typedef_::image_typeness_type>):
	Remove external vtype.

	* oln/core/abstract/image_typeness_integre.hh: Rename as...
	* oln/core/abstract/image_type_integre.hh: ...this.
	Adjust header guards.
	(case_<value_type_tag, value_type, 3>)
	(case_<value_type_tag, value_type, 4>)
	(case_<value_type_tag, value_type, 5>)
	(case_<value_type_tag, value_type, 6>): Update and rename as...
	(case_<image_type_hierarchy, E, 3>)
	(case_<image_type_hierarchy, E, 4>)
	(case_<image_type_hierarchy, E, 5>)
	(case_<image_type_hierarchy, E, 6>): ...this.
	No longer provide an `image_typeness_type' typedef.
	
	* tests/image_entry.cc (my::image): Set
	oln::image_entry<my::image> as super type.
	(oln::vtypes<my::image>::psite_type)
	(oln::vtypes<my::image>::rvalue_type)
	(oln::vtypes<my::image>::piter_type): Remove these typedefs, as
	they are already defined as single typedefs in
	oln/core/image_entry.hh.
	(my::image::grid_type, my::image::value_type): Rename as...
	(my::image::grid_t, my::image::value_t): ...this.
	(my::image::image_dimension_type, my::image::image_typeness_type):
	Remove.
	(main): Adjust, and remove irrelevant assertions.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@536 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 49486f07
2006-09-14 Roland Levillain <roland@lrde.epita.fr>
Use the new entry/hierarchy system for images.
* oln/core/abstract/image_entry.hh: Remove.
* oln/core/abstract/image_hierarchies.hh: New.
* oln/core/abstract/image.hh
(oln/core/abstract/image_hierarchies.hh): Include it.
* oln/core/image_entry.hh: Aesthetic change.
* oln/core/abstract/image_dimension.hh:
Update the documentation.
(oln::ERROR::UNKNOWN_GRID_TYPE): Remove error message.
(oln::grid_dim_tag): Remove tag.
(stc::set_entry_node<I, oln::abstract::dimension_tag>): Remove
switch.
(case_<grid_dim_tag, grid_type, 1>)
(case_<grid_dim_tag, grid_type, 2>)
(case_<grid_dim_tag, grid_type, 3>): Update and rename as...
(case_<image_dimension_hierarchy, E, 1>)
(case_<image_dimension_hierarchy, E, 2>)
(case_<image_dimension_hierarchy, E, 3>): ...this.
(default_case_<grid_dim_tag, grid_type>): Remove.
(oln::ext_vtype<abstract::image<I>, typedef_::image_dimension_type>):
Remove external vtype.
* oln/core/abstract/image_typeness.hh: Rename as...
* oln/core/abstract/image_type.hh: ...this.
Adjust header guards.
Update the documentation.
(oln::value_type_tag): Remove tag.
(stc::set_entry_node<I, oln::abstract::typeness_tag>): Remove
switch.
(case_<value_type_tag, value_type, 1>)
(case_<value_type_tag, value_type, 2>)
(default_case_<value_type_tag, value_type>): Update and rename
as...
(case_<image_type_hierarchy, E, 1>)
(case_<image_type_hierarchy, E, 2>)
(default_case_<image_type_hierarchy, E>): ...this.
No longer provide an `image_typeness_type' typedef.
(oln::ext_vtype<abstract::image<I>, typedef_::image_typeness_type>):
Remove external vtype.
* oln/core/abstract/image_typeness_integre.hh: Rename as...
* oln/core/abstract/image_type_integre.hh: ...this.
Adjust header guards.
(case_<value_type_tag, value_type, 3>)
(case_<value_type_tag, value_type, 4>)
(case_<value_type_tag, value_type, 5>)
(case_<value_type_tag, value_type, 6>): Update and rename as...
(case_<image_type_hierarchy, E, 3>)
(case_<image_type_hierarchy, E, 4>)
(case_<image_type_hierarchy, E, 5>)
(case_<image_type_hierarchy, E, 6>): ...this.
No longer provide an `image_typeness_type' typedef.
* tests/image_entry.cc (my::image): Set
oln::image_entry<my::image> as super type.
(oln::vtypes<my::image>::psite_type)
(oln::vtypes<my::image>::rvalue_type)
(oln::vtypes<my::image>::piter_type): Remove these typedefs, as
they are already defined as single typedefs in
oln/core/image_entry.hh.
(my::image::grid_type, my::image::value_type): Rename as...
(my::image::grid_t, my::image::value_t): ...this.
(my::image::image_dimension_type, my::image::image_typeness_type):
Remove.
(main): Adjust, and remove irrelevant assertions.
2006-09-14 Roland Levillain <roland@lrde.epita.fr>
Add missing files to Olena's distribution.
......
......@@ -154,5 +154,7 @@ namespace oln
} // end of namespace oln
# include <oln/core/abstract/image_hierarchies.hh>
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_HH
......@@ -28,9 +28,7 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
# define OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
# include <stc/entry.hh>
# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/image_abstractions.hh>
/* Image dimension hierarchy (summary).
......@@ -53,17 +51,23 @@
o
|
stc::set_entry_node<I, dimension_tag>
/switch_<image_dimension_hierarchy, I>::ret/
(image dimension selector)
^
|
/image_entry<I>/
/entry<abstract::image, I>/
^
|
image_entry<I>
^
|
I
(a concrete image)
*/
Default case: If no known grid type is returned by `oln_type_of(I, grid)',
the entry is directly plugged to abstract::image<I>. */
/*-------------------------.
| Dimension abstractions. |
......@@ -107,47 +111,10 @@ 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. |
`-------------------*/
namespace oln
{
/// Case tag for the dimension.
struct grid_dim_tag;
}
// Register the dimension switch for oln::abstract::image_entry.
namespace stc
{
template <typename I>
struct set_entry_node<I, oln::abstract::dimension_tag> :
public oln::switch_< oln::grid_dim_tag, oln_type_of(I, grid) >::ret
::template instantiated_with<I>::ret
{
};
} // end of namespace stc
namespace oln
{
......@@ -156,69 +123,31 @@ namespace oln
class grid2d;
class grid3d;
/// Switch on on the grid dimension.
/// \{
/// 1-D case.
template <typename grid_type>
struct case_<grid_dim_tag, grid_type, 1> :
// Test.
public mlc::where_< mlc_eq(grid_type, oln::grid1d) >
template <typename E>
struct case_< image_dimension_hierarchy, E, 1 > :
where_< mlc::eq_< oln_type_of(E, grid), oln::grid1d > >
{
// Super class if test succeeds.
typedef stc::abstraction_as_type<abstract::image1d> ret;
typedef abstract::image1d<E> ret;
};
/// 2-D case.
template <typename grid_type>
struct case_<grid_dim_tag, grid_type, 2> :
// Test.
public mlc::where_< mlc_eq(grid_type, oln::grid2d) >
template <typename E>
struct case_< image_dimension_hierarchy, E, 2 > :
where_< mlc::eq_< oln_type_of(E, grid), oln::grid2d > >
{
// Super class if test succeeds.
typedef stc::abstraction_as_type<abstract::image2d> ret;
typedef abstract::image2d<E> ret;
};
/// 3-D case.
template <typename grid_type>
struct case_<grid_dim_tag, grid_type, 3> :
// Test.
public mlc::where_< mlc_eq(grid_type, oln::grid3d) >
{
// Super class if test succeeds.
typedef stc::abstraction_as_type<abstract::image3d> ret;
};
/// Default case: abort when grid_type is not handled by the previous cases.
template <typename grid_type>
struct default_case_<grid_dim_tag, grid_type>
template <typename E>
struct case_< image_dimension_hierarchy, E, 3 > :
where_< mlc::eq_< oln_type_of(E, grid), oln::grid3d > >
{
typedef mlc::abort_< grid_dim_tag, ERROR::UNKNOWN_GRID_TYPE<grid_type> > ret;
typedef abstract::image3d<E> ret;
};
/// \}
} // end of namespace oln
/*----------------------------------.
| Dimension extended virtual type. |
`----------------------------------*/
// FIXME: Is this extended vtype really useful?
namespace oln
{
/// Image dimension type as an extended vtype of abstract::image.
template <typename I>
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.
typedef typename oln::switch_< oln::grid_dim_tag,
oln_type_of(I, grid) >::ret ret;
};
}
#endif // ! OLENA_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 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_IMAGE_ENTRY_HH
# define OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
# include <stc/entry.hh>
# include <oln/core/abstract/image_abstractions.hh>
// Abstraction hierachies.
# include <oln/core/abstract/image_dimension.hh>
# include <oln/core/abstract/image_typeness.hh>
namespace oln
{
namespace abstract
{
// Forward declaration.
template <typename E> struct image_entry;
}
/// \brief Uplink.
///
/// oln::abstract::image<E> is not the direct super type of
/// oln::abstract::image_entry<E>, however, it is declared as such
/// using set_super_type, to make the virtual type retrieval system
/// work.
template <typename E>
struct set_super_type< abstract::image_entry<E> >
{
typedef abstract::image<E> ret;
};
namespace abstract
{
template <typename E>
struct image_entry : public stc::entry<E>
{
protected:
image_entry() {}
};
} // end of namespace oln::abstract
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
......@@ -25,34 +25,33 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
#ifndef OLENA_CORE_ABSTRACT_IMAGE_HIERARCHIES_HH
# define OLENA_CORE_ABSTRACT_IMAGE_HIERARCHIES_HH
# include <oln/core/case.hh>
# include <oln/core/abstract/image.hh>
namespace oln
{
namespace abstract
{
/// \brief Tags for abstractions.
///
/// Use them instead of hard-coded numbers.
enum abstraction_tags
{
// constness_tag,
dimension_tag = 1,
typeness_tag
// valuedness_tag,
// rawness_tag,
// neighbness_tag,
// ...
};
} // end of namespace oln::abstract
typedef hierarchy<abstract::image, 1> image_dimension_hierarchy;
typedef hierarchy<abstract::image, 2> image_type_hierarchy;
// FIXME: To be continued.
#if 0
typedef hierarchy<abstract::image, 3> image_value_hierarchy;
// FIXME: Rename (``rawness'' means ``crudit'' in French...).
typedef hierarchy<abstract::image, 4> image_rawness_hierarchy;
typedef hierarchy<abstract::image, 5> image_neighborhood_hierarchy;
// ...
#endif
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
# include <oln/core/abstract/image_dimension.hh>
# include <oln/core/abstract/image_type.hh>
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_HIERARCHIES_HH
......@@ -25,15 +25,13 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
#ifndef OLENA_CORE_ABSTRACT_IMAGE_TYPE_HH
# define OLENA_CORE_ABSTRACT_IMAGE_TYPE_HH
# include <stc/entry.hh>
# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/image_abstractions.hh>
/* Image ``typeness'' hierarchy (summary).
/* Image ``type'' hierarchy (summary).
/image<I>/
......@@ -48,29 +46,35 @@
| | | ^ | | |
| | | | | | |
,---------------------------------------------------------------------.
| The selection of the super classe(s) is made according to the value |
| The selection of the super class(es) is made according to the value |
| of type_of(I, value). |
`---------------------------------------------------------------------'
| | | | | | |
o o o o o o o
o
o
|
stc::set_entry_node<I, typeness_tag>
(image typeness selector)
/switch_<image_dimension_type, I>::ret/
(image type selector)
^
|
/image_entry<I>/
/entry<abstract::image, I>/
^
|
image_entry<I>
^
|
I
(a concrete image)
*/
/*------------------------.
| Typeness abstractions. |
`------------------------*/
Default case: If no known value type is returned by `oln_type_of(I, value)',
the entry is plugged to abstract::data_image<I>. */
/*--------------------.
| Type abstractions. |
`--------------------*/
namespace oln
{
......@@ -212,28 +216,9 @@ namespace oln
} // end of namespace oln
/*------------------.
| Typeness switch. |
`------------------*/
namespace oln
{
/// Case tag for the dimension.
struct value_type_tag;
}
// Register the dimension switch/case for oln::abstract::image_entry.
namespace stc
{
template <typename I>
struct set_entry_node<I, oln::abstract::typeness_tag> :
public oln::case_< oln::value_type_tag, oln_type_of(I, value) >::ret
::super_type::template instantiated_with<I>::ret
{
};
} // end of namespace stc
/*--------------.
| Type switch. |
`--------------*/
namespace oln
{
......@@ -246,33 +231,25 @@ namespace oln
// ----------------------------------------------- //
/// Binary case.
template <typename value_type>
struct case_<value_type_tag, value_type, 1> :
public mlc::where_< mlc_eq(value_type, bool) >
template <typename E>
struct case_< image_type_hierarchy, E, 1 > :
where_< mlc::eq_< oln_type_of(E, value), bool > >
{
// Definition of the super class corresponding to this case.
typedef stc::abstraction_as_type<abstract::binary_image> super_type;
// Definition of the extended virtual type (same as the super
// class in this case).
typedef super_type image_typeness_type;
typedef abstract::binary_image<E> ret;
};
/// Grey-level case.
template <typename value_type>
struct case_<value_type_tag, value_type, 2> :
public mlc::where_<
mlc::or_list_< mlc_eq(value_type, char),
mlc_eq(value_type, signed char),
mlc_eq(value_type, unsigned char) > >
template <typename E>
struct case_< image_type_hierarchy, E, 2 > :
where_< mlc::or_list_< mlc::eq_<oln_type_of(E, value), char>,
mlc::eq_<oln_type_of(E, value), signed char>,
mlc::eq_<oln_type_of(E, value), unsigned char> > >
{
// Definition of the super class corresponding to this case
// (abstract::grey_level_image_ is the conjunction of
// abstract::grey_level_image and abstract::not_binary_image).
typedef stc::abstraction_as_type<abstract::internal::grey_level_image_>
super_type;
// Definition of the extended virtual type.
typedef stc::abstraction_as_type<abstract::grey_level_image>
image_typeness_type;
typedef abstract::internal::grey_level_image_<E> ret;
};
......@@ -281,17 +258,13 @@ namespace oln
// -------------- //
/// Default case: image of ``data''.
template <typename value_type>
struct default_case_<value_type_tag, value_type>
template <typename E>
struct default_case_< image_type_hierarchy, E >
{
// Definition of the super class corresponding to this case
// (abstract::data_image_ is the conjunction of
// abstract::data_image and abstract::not_binary_image).
typedef stc::abstraction_as_type<abstract::internal::data_image_>
super_type;
// Definition of the extended virtual type.
typedef stc::abstraction_as_type<abstract::data_image>
image_typeness_type;
typedef abstract::internal::data_image_<E> ret;
};
/// \}
......@@ -299,27 +272,4 @@ namespace oln
} // end of namespace oln
/*---------------------------------.
| Typeness extended virtual type. |
`---------------------------------*/
// FIXME: Is this extended vtype really useful?
namespace oln
{
/// Image ``typeness'' as an extended vtype of abstract::image.
template <typename I>
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
// (image_typename_type), not the super type.
typedef
typename oln::case_< oln::value_type_tag,
oln_type_of(I, value) >::ret::image_typeness_type
ret;
};
}
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_TYPE_HH
......@@ -29,10 +29,10 @@
// FIXME: Move this file into Integre? Or in a another project,
// serving as a glue between Integre and Olena?
#ifndef OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_INTEGRE_HH
# define OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_INTEGRE_HH
#ifndef OLENA_CORE_ABSTRACT_IMAGE_TYPE_INTEGRE_HH
# define OLENA_CORE_ABSTRACT_IMAGE_TYPE_INTEGRE_HH
# include <oln/core/abstract/image_typeness.hh>
# include <oln/core/abstract/image_type.hh>
// Forward declarations.
......@@ -77,9 +77,9 @@ namespace ntg
} // end of namespace ntg
/*--------------------------.
| Typeness switch (cont.). |
`--------------------------*/
/*----------------------.
| Type switch (cont.). |
`----------------------*/
namespace oln {
......@@ -91,72 +91,55 @@ namespace oln {
// Cases where the value type is an Integre type. //
// ----------------------------------------------- //
// (The first cases are located in oln/core/abstract/image_typeness.hh).
// (The first cases are located in oln/core/abstract/image_type.hh).
/// Binary case.
template <typename value_type>
struct case_<value_type_tag, value_type, 3> :
public mlc::where_<
mlc::or_list_< mlc_eq(value_type, ntg::bin),
ntg::eq_<ntg::int_u, 1, value_type>,
ntg::eq_<ntg::int_s, 1, value_type> > >
template <typename E>
struct case_< image_type_hierarchy, E, 3 > :
where_< mlc::or_list_< mlc::eq_<oln_type_of(E, value), ntg::bin>,
ntg::eq_<ntg::int_u, 1, oln_type_of(E, value)>,
ntg::eq_<ntg::int_s, 1, oln_type_of(E, value)> > >
{
// Definition of the super class corresponding to this case.
typedef stc::abstraction_as_type<abstract::binary_image> super_type;
// Definition of the extended virtual type (same as the super
// class in this case).
typedef super_type image_typeness_type;
typedef abstract::binary_image<E> ret;
};