Commit 6e0342df authored by Roland Levillain's avatar Roland Levillain
Browse files

Add image ``typeness'' abstraction hierarchy.

	* tests/image_entry.cc (my): Check image_typeness_type vtype and
	inheritance.
	* oln/core/typedefs.hh (value_type, image_typeness_type): Enable
	typedef.
	* oln/core/abstract/image.hh (vtypes::value_type): Enable typedef.
	(packed_vtypes::value_type): New typedef.
	(packed_vtypes::echo): Print value_type and image_typeness_type.
	(packed_vtypes::ensure): Check value_type and image_typeness_type.
	(image::value_type): Enable typedef.
	* oln/core/abstract/image_entry.hh: Include images abstractions
	headers.
	Don't include mlc/case.hh nor oln/core/abstract/image.hh.
	(mlc_case_equipment_for_namespace(oln))
	(abstraction_tags): Move...
	* oln/core/abstract/image_abstractions.hh: ...here (new file).
	* oln/core/abstract/image_dimension.hh: Include it.
	Include stc/entry.hh.
	Aesthetic changes.
	* oln/core/abstract/image_typeness.hh: New file (imported from
	Olena proto-1.0, and modified).
	* oln/core/abstract/image_typeness_integre.hh: New file
	* oln/Makefile.am (nobase_oln_HEADERS): Add
	core/abstract/image_abstractions.hh,
	core/abstract/image_typeness.hh and
	core/abstract/image_typeness_integre.hh.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@480 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 3d052779
2006-04-27 Roland Levillain <roland@lrde.epita.fr>
Add image ``typeness'' abstraction hierarchy.
* tests/image_entry.cc (my): Check image_typeness_type vtype and
inheritance.
* oln/core/typedefs.hh (value_type, image_typeness_type): Enable
typedef.
* oln/core/abstract/image.hh (vtypes::value_type): Enable typedef.
(packed_vtypes::value_type): New typedef.
(packed_vtypes::echo): Print value_type and image_typeness_type.
(packed_vtypes::ensure): Check value_type and image_typeness_type.
(image::value_type): Enable typedef.
* oln/core/abstract/image_entry.hh: Include images abstractions
headers.
Don't include mlc/case.hh nor oln/core/abstract/image.hh.
(mlc_case_equipment_for_namespace(oln))
(abstraction_tags): Move...
* oln/core/abstract/image_abstractions.hh: ...here (new file).
* oln/core/abstract/image_dimension.hh: Include it.
Include stc/entry.hh.
Aesthetic changes.
* oln/core/abstract/image_typeness.hh: New file (imported from
Olena proto-1.0, and modified).
* oln/core/abstract/image_typeness_integre.hh: New file
* oln/Makefile.am (nobase_oln_HEADERS): Add
core/abstract/image_abstractions.hh,
core/abstract/image_typeness.hh and
core/abstract/image_typeness_integre.hh.
2006-04-25 Roland Levillain <roland@lrde.epita.fr>
* oln/core/abstract/image_dimension.hh: Add some more
......
......@@ -13,8 +13,11 @@ nobase_oln_HEADERS = \
core/abstract/any.hh \
core/abstract/grid.hh \
core/abstract/image.hh \
core/abstract/image_abstractions.hh \
core/abstract/image_entry.hh \
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
......@@ -67,7 +67,11 @@ namespace oln {
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// typedef mlc::undefined concrete_type;
// typedef mlc::undefined value_type;
// --------------------------------------------------------------------
typedef mlc::undefined value_type;
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// typedef mlc::undefined point_type;
// typedef mlc::undefined size_type;
......@@ -103,7 +107,11 @@ namespace oln {
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// typedef oln_type_of(I, concrete) concrete_type;
// typedef oln_type_of(I, value) value_type;
// --------------------------------------------------------------------
typedef oln_type_of(I, value) value_type;
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// typedef oln_type_of(I, point) point_type;
// typedef oln_type_of(I, size) size_type;
......@@ -128,6 +136,7 @@ namespace oln {
// Defined externally virtual types.
typedef oln_type_of(I, image_dimension) image_dimension_type;
typedef oln_type_of(I, image_typeness) image_typeness_type;
/// Pretty-printing.
static void echo(std::ostream& ostr)
......@@ -144,7 +153,11 @@ namespace oln {
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// << " concrete_type = " << mlc_to_string(concrete_type) << std::endl
// << " value_type = " << mlc_to_string(value_type) << std::endl
// --------------------------------------------------------------------
<< " value_type = " << mlc_to_string(value_type) << std::endl
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// << " point_type = " << mlc_to_string(point_type) << std::endl
// << " size_type = " << mlc_to_string(size_type) << std::endl
......@@ -165,7 +178,10 @@ namespace oln {
// << " image_constness_type = " << mlc_to_string(image_constness_type) << std::endl
// << " image_rawness_type = " << mlc_to_string(image_rawness_type) << std::endl
// --------------------------------------------------------------------
<< " image_dimension_type = " << mlc_to_string(image_dimension_type) << std::endl
<< " image_dimension_type = " << mlc_to_string(image_dimension_type)
<< std::endl
<< " image_typeness_type = " << mlc_to_string(image_typeness_type)
<< std::endl
<< "}" << std::endl;
}
......@@ -179,7 +195,11 @@ namespace oln {
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc::assert_< mlc_is_ok(concrete_type) >::check();
// mlc::assert_< mlc_is_ok(value_type) >::check();
// --------------------------------------------------------------------
mlc::assert_< mlc_is_ok(value_type) >::check();
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// mlc::assert_< mlc_is_ok(point_type) >::check();
// mlc::assert_< mlc_is_ok(size_type) >::check();
// mlc::assert_< mlc_is_ok(piter_type) >::check();
......@@ -200,6 +220,7 @@ namespace oln {
// mlc::assert_< mlc_is_ok(image_rawness_type) >::check();
// --------------------------------------------------------------------
mlc::assert_< mlc_is_ok(image_dimension_type) >::check();
mlc::assert_< mlc_is_ok(image_typeness_type) >::check();
}
};
......@@ -235,12 +256,16 @@ namespace oln
template <typename E>
struct image : public internal::get_image_impl < image<E>, E >
{
/// Typedefs.
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// /// typedefs
// typedef oln_type_of(E, size) size_type;
// typedef oln_type_of(E, value) value_type;
// --------------------------------------------------------------------
typedef oln_type_of(E, value) value_type;
// --------------------------------------------------------------------
// FIXME: To be enabled later.
// --------------------------------------------------------------------
// typedef oln_type_of(E, point) point_type;
// --------------------------------------------------------------------
......
// 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.
#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);
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
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
......@@ -28,7 +28,10 @@
#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).
......@@ -62,55 +65,36 @@
*/
/*! \namespace oln
** \brief oln namespace.
*/
namespace oln {
/*! \namespace oln::abstract
** \brief oln::abstract namespace.
*/
namespace abstract {
namespace oln
{
namespace abstract
{
/*! \class abstract::image1d<E>
**
** Class of 1d images.
*/
/// Class of 1D images.
template <typename E>
struct image1d : public virtual image<E>
{
protected:
/*! \brief Constructor (protected, empty).
*/
/// Constructor (protected, empty).
image1d() {}
};
/*! \class abstract::image2d<E>
**
** Class of 2d images.
*/
/// Class of 2D images.
template <typename E>
struct image2d : public virtual image<E>
{
protected:
/*! \brief Constructor (protected, empty).
*/
/// Constructor (protected, empty).
image2d() {}
};
/*! \class abstract::image3d<E>
**
** Class of 3d images.
*/
/// Class of 3d images.
template <typename E>
struct image3d : public virtual image<E>
{
protected:
/*! \brief Constructor (protected, empty).
*/
/// Constructor (protected, empty).
image3d() {}
};
......@@ -121,12 +105,10 @@ namespace oln {
| Dimension switch. |
`-------------------*/
/// Forward declarations.
/// \{
// Forward declarations.
class grid1d;
class grid2d;
class grid3d;
/// \}
/// Case tag for the dimension.
struct grid_dim_tag;
......@@ -182,9 +164,11 @@ namespace stc
};
} // end of namespace stc
// FIXME: Is this external property really useful?
namespace oln
{
/// An external type associated to my::B.
/// Image dimension type as an external vtype of abstract::image.
template <typename I>
struct ext_vtype< category::image,
abstract::image<I>,
......
......@@ -28,9 +28,13 @@
#ifndef OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
# define OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
# include <mlc/case.hh>
# include <stc/entry.hh>
# include <oln/core/abstract/image.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
{
......@@ -62,22 +66,9 @@ namespace oln
image_entry() {}
};
/// \brief Tags for abstractions.
/// Use them instead of hard-coded numbers.
enum abstraction_tags
{
dimension_tag = 1,
constness_tag
// ...
};
} // end of namespace oln::abstract
} // end of namespace oln::abstract
} // end of namespace oln
// Add switch/case equipment in the oln namespace.
mlc_case_equipment_for_namespace(oln);
#endif // ! OLENA_CORE_ABSTRACT_IMAGE_ENTRY_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_TYPENESS_HH
# define OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
# include <stc/entry.hh>
# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/image_abstractions.hh>
/* Image ``typeness'' hierarchy (summary).
/image<I>/
^
|
,--------------+-------------+-------------+--------+---------.
| | | | | |
/grey_level_image/ /color_image/ /label_image/ /data_image/ ... /not_binary_
^ ^ ^ ^ ^ ^ image/
| | | | | | ^
| | | /binary_image/ | | |
| | | ^ | | |
| | | | | | |
,---------------------------------------------------------------------.
| The selection of the super classe(s) is made according to the value |
| of type_of(I, value). |
`---------------------------------------------------------------------'
| | | | | | |
o o o o o o o
o
|
stc::set_entry_node<I, typeness_tag>
(image typeness selector)
^
|
/image_entry<I>/
^
|
I
(a concrete image)
*/
namespace oln {
namespace abstract
{
/// \brief Class of grey-level images.
///
/// An image that contains values whose type is \c int or
/// <tt>unsigned char</tt>, or ntg::int_u<8> (...) is <b>not</b> a
/// grey-level image.
///
/// FIXME: Say more.
template <typename E>
struct grey_level_image : public virtual image<E>
{
protected:
/// Constructor (protected, empty).
grey_level_image() {}
};
/// Class of color images.
template <typename E>
struct color_image : public virtual image<E>
{
protected:
/// Constructor (protected, empty).
color_image() {}
};
/// \brief Class of images whose data are NOT Boolean values.
///
/// However such images can derive from abstract::label_image (we
/// can have labels that are not binary ones).
template <typename E>
struct not_binary_image : public virtual image<E>
{
protected:
/// Constructor (protected, empty).
not_binary_image() {}
};
/// \brief Class of images whose data are labels.
///
/// Such images do not support arithmetics.
template <typename E>
struct label_image : public virtual image<E>
{
protected:
/// Constructor (protected, empty).
label_image() {}
};
/// \brief Class of images whose data are Boolean values.
///
/// Such images are also oln::abstract::label_image.
template <typename E>
struct binary_image : public label_image<E>
{
protected:
/// Constructor (protected, empty).
binary_image() {}
};
/// \brief Class of images whose data cannot be qualified of
/// grey-levels, colors, or labels.
template <typename E>
struct data_image : public virtual image<E>
{
protected:
/// Constructor (protected, empty).
data_image() {}
};
/*---------------------.
| Conjunctions types. |
`---------------------*/
namespace internal
{
/// \brief Conjunctions types
///
/// These types are helpers to express the inheritance relation
/// ``is a X and not_binary_image''. These abstractions are not
/// to be used by client code (i.e., algorithms), they are only
/// part of the inheritance machinery.
//
/// \{
/// <em>Grey-level image</em> and <em>not binary image</em> abstraction.
template <typename E>
struct grey_level_image_ : public grey_level_image<E>,
public not_binary_image<E>
{
protected:
/// Constructor (protected, empty).
grey_level_image_() {}
};
/// <em>Label image</em> and <em>not binary image</em> abstraction.
template <typename E>
struct label_image_ : public label_image<E>,
public not_binary_image<E>
{
protected:
/// Constructor (protected, empty).
label_image_() {}
};
/// <em>Color image</em> and <em>not binary image</em> abstraction.
template <typename E>
struct color_image_ : public color_image<E>,
public not_binary_image<E>
{
protected:
/// Constructor (protected, empty).
color_image_() {}
};
/// <em>Data image</em> and <em>not binary image</em> abstraction.
template <typename E>
struct data_image_ : public data_image<E>,
public not_binary_image<E>
{
protected:
/// Constructor (protected, empty).
data_image_() {}
};
/// \}
} // end of namespace oln::abstract::internal
} // end of namespace oln::abstract
/*--------------------.
| Value type switch. |
`--------------------*/
/// Case tag for the dimension.
struct value_type_tag;
/// Switch on on the grid dimension.
/// \{
// ----------------------------------------------- //
// Cases where the value type is an builtin type. //
// ----------------------------------------------- //
/// Binary case.
template <typename value_type>
struct case_<value_type_tag, value_type, 1> :
public mlc::where_< mlc_eq(value_type, bool) >
{
// Definition of the super class corresponding to this case.
typedef stc::abstraction_as_type<abstract::binary_image> super_type;
// Definition of the external virtual type (same as the super
// class in this case).
typedef super_type image_typeness_type;
};
/// 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, unsigned char),
mlc_eq(value_type, 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 external virtual type.
typedef stc::abstraction_as_type<abstract::grey_level_image>
image_typeness_type;
};
// -------------- //
// Default case. //
// -------------- //
/// Default case: image of ``data''.
template <typename value_type>
struct default_case_<value_type_tag, value_type>
{
// 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 external virtual type.
typedef stc::abstraction_as_type<abstract::data_image>
image_typeness_type;
};
/// \}
} // end of namespace oln
// 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