Commit 555fe8df authored by Roland Levillain's avatar Roland Levillain
Browse files

Restore the compatibility of morphers with G++ 4.0.

	* oln/core/macros.hh (oln_direct_type_of, oln_direct_type_of_):
	New macros.
	* oln/morpher/internal/image_extension.hh (oln): Use
	`oln_direct_type_of(Exact, ...)' instead of
	`oln_type_of(self_t, ...)'.
	* tests/morphers.cc (main): Add more static assertions.
	* tests/identity_morpher.cc: More documentation.
	* tests/add_neighborhood_morpher.cc: New test.
	* tests/Makefile.am (check_PROGRAMS): Add
	add_neighborhood_morpher.
	(add_neighborhood_morpher_SOURCES): New.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@558 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 86a4f2fb
2006-09-24 Roland Levillain <roland@lrde.epita.fr>
Restore the compatibility of morphers with G++ 4.0.
* oln/core/macros.hh (oln_direct_type_of, oln_direct_type_of_):
New macros.
* oln/morpher/internal/image_extension.hh (oln): Use
`oln_direct_type_of(Exact, ...)' instead of
`oln_type_of(self_t, ...)'.
* tests/morphers.cc (main): Add more static assertions.
* tests/identity_morpher.cc: More documentation.
* tests/add_neighborhood_morpher.cc: New test.
* tests/Makefile.am (check_PROGRAMS): Add
add_neighborhood_morpher.
(add_neighborhood_morpher_SOURCES): New.
2006-09-22 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr> 2006-09-22 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
Add image point iterators parameterized by the image topology; Add image point iterators parameterized by the image topology;
......
...@@ -30,18 +30,36 @@ ...@@ -30,18 +30,36 @@
/// \def oln_type_of(OlnType, Alias) /// \def oln_type_of(OlnType, Alias)
/// ///
/// Macro to retrieve an associated type \a Alias from an oln type /// Macro to retrieve an associated type \a Alias from the exact type of
/// \a OlnType whose category is not specified (version to be used inside /// an oln type \a OlnType whose category is not specified (version to be
/// a template). /// used inside a template).
# define oln_type_of(OlnType, Alias) \ # define oln_type_of(OlnType, Alias) \
stc_type_of(oln, void, OlnType, Alias) stc_type_of(oln, void, OlnType, Alias)
/// \def oln_type_of(OlnType, Alias) /// \def oln_type_of(OlnType, Alias)
/// ///
/// Macro to retrieve an associated type \a Alias from an oln type /// Macro to retrieve an associated type \a Alias from the exact type of
/// \a OlnType whose category is not specified (version to be used /// an oln type \a OlnType whose category is not specified (version to be
/// outside a template). /// used outside a template).
# define oln_type_of_(OlnType, Alias) \ # define oln_type_of_(OlnType, Alias) \
stc_type_of_(oln, void, OlnType, Alias) stc_type_of_(oln, void, OlnType, Alias)
/// \def oln_direct_type_of(OlnType, Alias)
///
/// Macro to retrieve an associated type \a Alias from an oln type \a
/// OlnType directly, and whose category is not specified (version to
/// be used inside a template).
# define oln_direct_type_of(OlnType, Alias) \
stc_direct_type_of(oln, void, OlnType, Alias)
/// \def oln_direct_type_of_(OlnType, Alias)
///
/// Macro to retrieve an associated type \a Alias from an oln type \a
/// OlnType directly, and whose category is not specified (version to
/// be used inside a template).
# define oln_direct_type_of_(OlnType, Alias) \
stc_direct_type_of_(oln, void, OlnType, Alias)
#endif // ! OLENA_CORE_MACROS_HH #endif // ! OLENA_CORE_MACROS_HH
...@@ -58,7 +58,6 @@ namespace oln ...@@ -58,7 +58,6 @@ namespace oln
typedef Image ret; typedef Image ret;
}; };
namespace morpher namespace morpher
{ {
namespace internal namespace internal
...@@ -74,9 +73,9 @@ namespace oln ...@@ -74,9 +73,9 @@ namespace oln
/// Type of morphed image. /// Type of morphed image.
typedef Image image_t; typedef Image image_t;
typedef oln_type_of(self_t, topo) topo_t; typedef oln_direct_type_of(Exact, topo) topo_t;
typedef oln_type_of(self_t, value) value_t; typedef oln_direct_type_of(Exact, value) value_t;
typedef oln_type_of(self_t, point) point_t; typedef oln_direct_type_of(Exact, point) point_t;
public: public:
// FIXME: Handle the constness. // FIXME: Handle the constness.
......
...@@ -11,15 +11,19 @@ AM_CPPFLAGS = \ ...@@ -11,15 +11,19 @@ AM_CPPFLAGS = \
check_PROGRAMS = \ check_PROGRAMS = \
grid \ grid \
identity_morpher \
image_entry \ image_entry \
morphers \ npoints \
npoints \
identity_morpher \
add_neighborhood_morpher \
morphers
grid_SOURCES = grid.cc grid_SOURCES = grid.cc
identity_morpher_SOURCES = identity_morpher.cc
image_entry_SOURCES = image_entry.cc image_entry_SOURCES = image_entry.cc
npoints_SOURCES = npoints.cc npoints_SOURCES = npoints.cc
# Morphers.
identity_morpher_SOURCES = identity_morpher.cc
add_neighborhood_morpher_SOURCES = add_neighborhood_morpher.cc
morphers_SOURCES = morphers.cc morphers_SOURCES = morphers.cc
TESTS = $(check_PROGRAMS) 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 the identity morpher.
#include <mlc/assert.hh>
#include <mlc/is_a.hh>
// FIXME: We should not include oln/basics2d.hh, but only
// oln/core/2d/image2d.hh.
#include <oln/basics2d.hh>
#include <oln/morpher/add_neighborhood.hh>
int
main()
{
/*----------------.
| image2d<char>. |
`----------------*/
typedef oln::image2d<char> image_t;
// Sanity check: interfaces realized by oln::image2d.
mlc::assert_< mlc_is_a_(image_t, oln::abstract::image2d) >::check();
mlc::assert_< mlc_is_a_(image_t,
oln::abstract::grey_level_image) >::check();
mlc::assert_< mlc_is_a_(image_t,
oln::abstract::not_binary_image) >::check();
image_t ima(42, 51);
/*------------------------------------.
| add_neighborhood< image2d<char> >. |
`------------------------------------*/
typedef oln::morpher::add_neighborhood<image_t> image_with_nbh_t;
// Check that the instantiated add_neighborhood morpher realizes the
// same interfaces as the underlying morphed image.
mlc::assert_< mlc_is_a_(image_with_nbh_t, oln::abstract::image2d) >::check();
mlc::assert_< mlc_is_a_(image_with_nbh_t,
oln::abstract::grey_level_image) >::check();
mlc::assert_< mlc_is_a_(image_with_nbh_t,
oln::abstract::not_binary_image) >::check();
// Check the type of neighborhood.
mlc::assert_< mlc_eq(oln_type_of_(image_with_nbh_t, neighborhood),
oln::neighb2d) >::check();
// Instantiate a neighborhood for this image type.
oln_type_of_(image_with_nbh_t, neighborhood) nbh;
// Instantiate an object, and check its methods.
image_with_nbh_t ima_with_nbh(ima, nbh);
oln::neighb2d nbh2 = ima_with_nbh.neighborhood();
}
...@@ -30,31 +30,43 @@ ...@@ -30,31 +30,43 @@
#include <mlc/assert.hh> #include <mlc/assert.hh>
#include <mlc/is_a.hh> #include <mlc/is_a.hh>
// FIXME: We should not include oln/basics2d.hh, but oln/core/2d/image2d.hh. // FIXME: We should not include oln/basics2d.hh, but only
// oln/core/2d/image2d.hh.
#include <oln/basics2d.hh> #include <oln/basics2d.hh>
#include <oln/morpher/identity.hh> #include <oln/morpher/identity.hh>
int int
main() main()
{ {
/*----------------.
| image2d<char>. |
`----------------*/
typedef oln::image2d<char> image_t; typedef oln::image2d<char> image_t;
// Sanity check: abstractions realized by oln::image2d.
// Sanity check: interfaces realized by oln::image2d.
mlc::assert_< mlc_is_a_(image_t, oln::abstract::image2d) >::check(); mlc::assert_< mlc_is_a_(image_t, oln::abstract::image2d) >::check();
mlc::assert_< mlc_is_a_(image_t, mlc::assert_< mlc_is_a_(image_t,
oln::abstract::grey_level_image) >::check(); oln::abstract::grey_level_image) >::check();
mlc::assert_< mlc_is_a_(image_t, mlc::assert_< mlc_is_a_(image_t,
oln::abstract::not_binary_image) >::check(); oln::abstract::not_binary_image) >::check();
image_t ima(42, 51); image_t ima(42, 51);
/*----------------------------.
| identity< image2d<char> >. |
`----------------------------*/
typedef oln::morpher::identity<image_t> image_id_t; typedef oln::morpher::identity<image_t> image_id_t;
image_id_t ima_id(ima);
// Check that the instantiated identity morpher realizes the same // Check that the instantiated identity morpher realizes the same
// abstraction as the underlying morphed image. // interfaces as the underlying morphed image.
mlc::assert_< mlc_is_a_(image_id_t, oln::abstract::image2d) >::check(); mlc::assert_< mlc_is_a_(image_id_t, oln::abstract::image2d) >::check();
mlc::assert_< mlc_is_a_(image_id_t, mlc::assert_< mlc_is_a_(image_id_t,
oln::abstract::grey_level_image) >::check(); oln::abstract::grey_level_image) >::check();
mlc::assert_< mlc_is_a_(image_id_t, mlc::assert_< mlc_is_a_(image_id_t,
oln::abstract::not_binary_image) >::check(); oln::abstract::not_binary_image) >::check();
image_id_t ima_id(ima);
} }
...@@ -25,12 +25,13 @@ ...@@ -25,12 +25,13 @@
// reasons why the executable file might be covered by the GNU General // reasons why the executable file might be covered by the GNU General
// Public License. // Public License.
/// Test some morphers. /// Test some morphers and morpher composition.
#include <mlc/assert.hh> #include <mlc/assert.hh>
#include <mlc/is_a.hh> #include <mlc/is_a.hh>
// FIXME: We should not include oln/basics2d.hh, but oln/core/2d/image2d.hh. // FIXME: We should not include oln/basics2d.hh, but
// oln/core/2d/image2d.hh (and oln/core/2d/neigh2d.hh ?).
#include <oln/basics2d.hh> #include <oln/basics2d.hh>
#include <oln/morpher/identity.hh> #include <oln/morpher/identity.hh>
#include <oln/morpher/add_neighborhood.hh> #include <oln/morpher/add_neighborhood.hh>
...@@ -44,12 +45,14 @@ main() ...@@ -44,12 +45,14 @@ main()
`----------------*/ `----------------*/
typedef oln::image2d<char> image_t; typedef oln::image2d<char> image_t;
// Sanity check: abstractions realized by oln::image2d. // Sanity check: abstractions realized by oln::image2d.
mlc::assert_< mlc_is_a_(image_t, oln::abstract::image2d) >::check(); mlc::assert_< mlc_is_a_(image_t, oln::abstract::image2d) >::check();
mlc::assert_< mlc_is_a_(image_t, mlc::assert_< mlc_is_a_(image_t,
oln::abstract::grey_level_image) >::check(); oln::abstract::grey_level_image) >::check();
mlc::assert_< mlc_is_a_(image_t, mlc::assert_< mlc_is_a_(image_t,
oln::abstract::not_binary_image) >::check(); oln::abstract::not_binary_image) >::check();
image_t ima(42, 51); image_t ima(42, 51);
...@@ -58,16 +61,21 @@ main() ...@@ -58,16 +61,21 @@ main()
`------------------------------------*/ `------------------------------------*/
typedef oln::morpher::add_neighborhood<image_t> image_with_nbh_t; typedef oln::morpher::add_neighborhood<image_t> image_with_nbh_t;
// Check that the instantiated neighborhood addition morpher // Check that the instantiated neighborhood addition morpher
// realizes the same abstraction as the underlying morphed image. // realizes the same abstraction as the underlying morphed image.
mlc::assert_< mlc_is_a_(image_with_nbh_t, oln::abstract::image2d) >::check(); mlc::assert_< mlc_is_a_(image_with_nbh_t, oln::abstract::image2d) >::check();
mlc::assert_< mlc_is_a_(image_with_nbh_t, mlc::assert_< mlc_is_a_(image_with_nbh_t,
oln::abstract::image_having_neighborhood) >::check(); oln::abstract::image_having_neighborhood) >::check();
mlc::assert_< mlc_is_a_(image_with_nbh_t,
oln::abstract::not_binary_image) >::check();
// Check the type of neighborhood. // Check the type of neighborhood.
mlc::assert_< mlc_eq(oln_type_of_(image_with_nbh_t, neighborhood), mlc::assert_< mlc_eq(oln_type_of_(image_with_nbh_t, neighborhood),
oln::neighb2d) >::check(); oln::neighb2d) >::check();
oln::neighb2d nbh; // Instantiate a neighborhood for this image type.
oln_type_of_(image_with_nbh_t, neighborhood) nbh;
// Instantiate an object, and check its methods.
image_with_nbh_t ima_with_nbh(ima, nbh); image_with_nbh_t ima_with_nbh(ima, nbh);
oln::neighb2d nbh2 = ima_with_nbh.neighborhood(); oln::neighb2d nbh2 = ima_with_nbh.neighborhood();
...@@ -77,15 +85,20 @@ main() ...@@ -77,15 +85,20 @@ main()
`------------------------------------------------*/ `------------------------------------------------*/
typedef oln::morpher::identity<image_with_nbh_t> image_with_nbh_id_t; typedef oln::morpher::identity<image_with_nbh_t> image_with_nbh_id_t;
// Check that the instantiated identity morpher realizes the same // Check that the instantiated identity morpher realizes the same
// abstraction as the underlying morphed image. // abstraction as the underlying morphed image.
mlc::assert_< mlc_is_a_(image_with_nbh_id_t, mlc::assert_< mlc_is_a_(image_with_nbh_id_t,
oln::abstract::image2d) >::check(); oln::abstract::image2d) >::check();
mlc::assert_< mlc_is_a_(image_with_nbh_id_t, mlc::assert_< mlc_is_a_(image_with_nbh_id_t,
oln::abstract::image_having_neighborhood) >::check(); oln::abstract::image_having_neighborhood) >::check();
mlc::assert_< mlc_is_a_(image_with_nbh_id_t,
oln::abstract::not_binary_image) >::check();
// Check the type of neighborhood. // Check the type of neighborhood.
mlc::assert_< mlc_eq(oln_type_of_(image_with_nbh_id_t, neighborhood), mlc::assert_< mlc_eq(oln_type_of_(image_with_nbh_id_t, neighborhood),
oln::neighb2d) >::check(); oln::neighb2d) >::check();
// Instantiate an object, and check its methods.
image_with_nbh_id_t ima_with_nbh_id(ima_with_nbh); image_with_nbh_id_t ima_with_nbh_id(ima_with_nbh);
oln::neighb2d nbh3 = ima_with_nbh_id.neighborhood(); oln::neighb2d nbh3 = ima_with_nbh_id.neighborhood();
} }
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