Commit e63df38d authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Simplifying function concepts.

	* mln/core/concept/function.hh: Remove all concepts except
	  Function, Function_v2v, Function_v2b, Function_vv2v, and
	  Function_vv2b.

	* mln/data/transform.spe.hh: De-activate some implementation
	  routines and their related some dispatch routines.
	  (todo): New.

	* mln/topo/is_simple_cell.hh,
	* mln/topo/skeleton/breadth_first_thinning.hh,
	* mln/topo/is_n_face.hh,
	* mln/world/inter_pixel/is_separator.hh,
	* mln/world/inter_pixel/is_pixel.hh,
	* mln/world/inter_pixel/dim2/is_dot.hh,
	* mln/world/inter_pixel/dim2/is_row_odd.hh,
	* mln/world/inter_pixel/dim2/is_pixel.hh,
	* mln/world/inter_pixel/dim2/is_edge.hh,
	* mln/core/site_set/p_image.hh,
	* mln/core/site_set/p_if.hh,
	* mln/core/image/dmorph/image_if.hh,
	* mln/core/image/dmorph/p2p_image.hh,
	* mln/core/image/imorph/tr_image.hh,
	* mln/core/image/edge_image.hh,
	* mln/core/image/vertex_image.hh,
	* mln/core/point.hh,
	* mln/core/dpoint.hh,
	* mln/metal/vec.hh,
	* mln/metal/mat.hh,
	* mln/data/transform.spe.hh,
	* mln/value/shell.hh,
	* mln/make/w_window.hh,
	* mln/make/edge_image.hh,
	* mln/make/vertex_image.hh,
	* mln/test/predicate.hh,
	* mln/pw/var.hh,
	* mln/fun/p2b/chess.hh,
	* mln/fun/p2b/big_chess.hh,
	* mln/fun/p2b/antilogy.hh,
	* mln/fun/p2b/tautology.hh,
	* mln/fun/p2b/has.hh,
	* mln/fun/meta/hue.hh,
	* mln/fun/meta/inty.hh,
	* mln/fun/meta/sat.hh,
	* mln/fun/meta/blue.hh,
	* mln/fun/meta/first.hh,
	* mln/fun/meta/red.hh,
	* mln/fun/meta/second.hh,
	* mln/fun/meta/lum.hh,
	* mln/fun/meta/green.hh,
	* mln/fun/v2w2v/cos.hh,
	* mln/fun/cast.hh,
	* mln/fun/ops.hh,
	* mln/fun/i2v/all_to.hh,
	* mln/fun/i2v/array.hh,
	* mln/fun/p2p/fold.hh,
	* mln/fun/p2p/mirror.hh,
	* mln/fun/p2p/translation.hh,
	* mln/fun/p2v/elifs.hh,
	* mln/fun/p2v/ternary.hh,
	* mln/fun/p2v/iota.hh,
	* mln/fun/internal/x2x_linear_impl.hh,
	* mln/fun/internal/selector.hh,
	* mln/fun/x2x/composed.hh,
	* mln/fun/x2x/translation.hh,
	* mln/fun/x2x/rotation.hh,
	* mln/fun/v2w_w2v/norm.hh,
	* mln/set/diff.hh,
	* mln/algebra/mat.hh,
	* mln/algebra/vec.hh,
	* mln/morpho/tree/filter/min.hh,
	* mln/morpho/tree/filter/max.hh,
	* mln/morpho/tree/filter/filter.hh,
	* mln/morpho/tree/filter/direct.hh,
	* mln/morpho/tree/filter/subtractive.hh,
	* mln/morpho/tree/propagate_if.hh,
	* mln/util/internal/id2element.hh,
	* mln/util/array.hh,
	* tests/arith/minus_full.cc,
	* tests/arith/times_full.cc,
	* tests/arith/plus_full.cc,
	* tests/arith/revert_full.cc,
	* tests/data/compute_full.cc,
	* tests/data/fill_full.cc,
	* tests/data/abs_full.cc,
	* tests/data/paste_full.cc,
	* tests/data/compare_full.cc,
	* tests/border/get_full.cc,
	* tests/border/find_full.cc,
	* tests/border/resize_sub_image.cc,
	* tests/border/get.cc,
	* tests/border/resize_image_if.cc,
	* tests/make/w_window.cc,
	* tests/test/positive.cc,
	* tests/morpho/watershed/superpose.cc,
	* tests/canvas/browsing/fwd.cc,
	* tests/canvas/browsing/snake_fwd.cc,
	* tests/canvas/browsing/snake_vert.cc,
	* tests/canvas/browsing/snake_generic_2d_vert.cc,
	* tests/canvas/browsing/snake_generic_2d_hori.cc,
	* tests/canvas/browsing/snake_generic_3d_vert.cc,
	* tests/canvas/browsing/snake_generic_3d_hori.cc,
	* tests/canvas/browsing/hyper_directional.cc,
	* tests/canvas/browsing/diagonal2d.cc,
	* tests/canvas/browsing/backdiagonal2d.cc,
	* doc/examples/trash/graph.cc,
	* doc/examples/graph-data.cc,
	* doc/examples/mln_var.cc,
	* doc/examples/graph-iter.cc,
	* doc/examples/extend.cc: Propagate update.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3943 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 0d628156
2009-06-01 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Simplifying function concepts.
* mln/core/concept/function.hh: Remove all concepts except
Function, Function_v2v, Function_v2b, Function_vv2v, and
Function_vv2b.
* mln/data/transform.spe.hh: De-activate some implementation
routines and their related some dispatch routines.
(todo): New.
* mln/topo/is_simple_cell.hh,
* mln/topo/skeleton/breadth_first_thinning.hh,
* mln/topo/is_n_face.hh,
* mln/world/inter_pixel/is_separator.hh,
* mln/world/inter_pixel/is_pixel.hh,
* mln/world/inter_pixel/dim2/is_dot.hh,
* mln/world/inter_pixel/dim2/is_row_odd.hh,
* mln/world/inter_pixel/dim2/is_pixel.hh,
* mln/world/inter_pixel/dim2/is_edge.hh,
* mln/core/site_set/p_image.hh,
* mln/core/site_set/p_if.hh,
* mln/core/image/dmorph/image_if.hh,
* mln/core/image/dmorph/p2p_image.hh,
* mln/core/image/imorph/tr_image.hh,
* mln/core/image/edge_image.hh,
* mln/core/image/vertex_image.hh,
* mln/core/point.hh,
* mln/core/dpoint.hh,
* mln/metal/vec.hh,
* mln/metal/mat.hh,
* mln/data/transform.spe.hh,
* mln/value/shell.hh,
* mln/make/w_window.hh,
* mln/make/edge_image.hh,
* mln/make/vertex_image.hh,
* mln/test/predicate.hh,
* mln/pw/var.hh,
* mln/fun/p2b/chess.hh,
* mln/fun/p2b/big_chess.hh,
* mln/fun/p2b/antilogy.hh,
* mln/fun/p2b/tautology.hh,
* mln/fun/p2b/has.hh,
* mln/fun/meta/hue.hh,
* mln/fun/meta/inty.hh,
* mln/fun/meta/sat.hh,
* mln/fun/meta/blue.hh,
* mln/fun/meta/first.hh,
* mln/fun/meta/red.hh,
* mln/fun/meta/second.hh,
* mln/fun/meta/lum.hh,
* mln/fun/meta/green.hh,
* mln/fun/v2w2v/cos.hh,
* mln/fun/cast.hh,
* mln/fun/ops.hh,
* mln/fun/i2v/all_to.hh,
* mln/fun/i2v/array.hh,
* mln/fun/p2p/fold.hh,
* mln/fun/p2p/mirror.hh,
* mln/fun/p2p/translation.hh,
* mln/fun/p2v/elifs.hh,
* mln/fun/p2v/ternary.hh,
* mln/fun/p2v/iota.hh,
* mln/fun/internal/x2x_linear_impl.hh,
* mln/fun/internal/selector.hh,
* mln/fun/x2x/composed.hh,
* mln/fun/x2x/translation.hh,
* mln/fun/x2x/rotation.hh,
* mln/fun/v2w_w2v/norm.hh,
* mln/set/diff.hh,
* mln/algebra/mat.hh,
* mln/algebra/vec.hh,
* mln/morpho/tree/filter/min.hh,
* mln/morpho/tree/filter/max.hh,
* mln/morpho/tree/filter/filter.hh,
* mln/morpho/tree/filter/direct.hh,
* mln/morpho/tree/filter/subtractive.hh,
* mln/morpho/tree/propagate_if.hh,
* mln/util/internal/id2element.hh,
* mln/util/array.hh,
* tests/arith/minus_full.cc,
* tests/arith/times_full.cc,
* tests/arith/plus_full.cc,
* tests/arith/revert_full.cc,
* tests/data/compute_full.cc,
* tests/data/fill_full.cc,
* tests/data/abs_full.cc,
* tests/data/paste_full.cc,
* tests/data/compare_full.cc,
* tests/border/get_full.cc,
* tests/border/find_full.cc,
* tests/border/resize_sub_image.cc,
* tests/border/get.cc,
* tests/border/resize_image_if.cc,
* tests/make/w_window.cc,
* tests/test/positive.cc,
* tests/morpho/watershed/superpose.cc,
* tests/canvas/browsing/fwd.cc,
* tests/canvas/browsing/snake_fwd.cc,
* tests/canvas/browsing/snake_vert.cc,
* tests/canvas/browsing/snake_generic_2d_vert.cc,
* tests/canvas/browsing/snake_generic_2d_hori.cc,
* tests/canvas/browsing/snake_generic_3d_vert.cc,
* tests/canvas/browsing/snake_generic_3d_hori.cc,
* tests/canvas/browsing/hyper_directional.cc,
* tests/canvas/browsing/diagonal2d.cc,
* tests/canvas/browsing/backdiagonal2d.cc,
* doc/examples/trash/graph.cc,
* doc/examples/graph-data.cc,
* doc/examples/mln_var.cc,
* doc/examples/graph-iter.cc,
* doc/examples/extend.cc: Propagate update.
2009-06-01 Guillaume Lazzara <lazzara@lrde.epita.fr>
 
Disable registration test.
......@@ -39,7 +39,7 @@ namespace mln
namespace mln
{
struct my_ext : public Function_p2v<my_ext>
struct my_ext : public Function_v2v<my_ext>
{
typedef value::rgb8 result;
......
......@@ -12,7 +12,7 @@
// \{
template <typename S>
struct viota_t : public mln::Function_p2v< viota_t<S> >
struct viota_t : public mln::Function_v2v< viota_t<S> >
{
typedef unsigned result;
......
......@@ -5,7 +5,7 @@
#include <doc/tools/sample_utils.hh>
struct viota_t : public mln::Function_p2v< viota_t >
struct viota_t : public mln::Function_v2v< viota_t >
{
typedef unsigned result;
......
......@@ -4,7 +4,7 @@
#include <mln/pw/all.hh>
#include <mln/core/var.hh>
struct my_values_t : mln::Function_p2v<my_values_t>
struct my_values_t : mln::Function_v2v<my_values_t>
{
typedef int result;
......
......@@ -36,7 +36,7 @@
template <typename P>
struct lg_vertex_values : public mln::Function_p2v< lg_vertex_values<P> >
struct lg_vertex_values : public mln::Function_v2v< lg_vertex_values<P> >
{
typedef float result;
......
......@@ -107,7 +107,7 @@ namespace mln
/// Constructor; coordinates are set by function \p f.
template <typename F>
mat(const Function_i2v<F>& f);
mat(const Function_v2v<F>& f);
template <typename U>
mat& operator=(const mat<n,m,U>& rhs);
......@@ -480,7 +480,7 @@ namespace mln
template <unsigned n, unsigned m, typename T>
template <typename F>
inline
mat<n,m,T>::mat(const Function_i2v<F>& f_)
mat<n,m,T>::mat(const Function_v2v<F>& f_)
{
mlc_converts_to(mln_result(F), T)::check();
const F& f = exact(f_);
......
......@@ -241,7 +241,7 @@ namespace mln
/// Constructor; coordinates are set by function \p f.
template <typename F>
vec(const Function_i2v<F>& f);
vec(const Function_v2v<F>& f);
/// Zero value.
static const vec<n, T> zero;
......@@ -553,7 +553,7 @@ namespace mln
template <unsigned n, typename T>
template <typename F>
inline
vec<n, T>::vec(const Function_i2v<F>& f_)
vec<n, T>::vec(const Function_v2v<F>& f_)
{
mlc_converts_to(mln_result(F), T)::check();
const F& f = exact(f_);
......
......@@ -31,7 +31,7 @@
/// \file mln/core/concept/function.hh
///
/// Definition of several concepts of functions.
/// \brief Definition of several concepts of functions.
# include <mln/core/concept/object.hh>
......@@ -39,22 +39,14 @@
namespace mln
{
// Fwd decls.
// Forward declarations.
template <typename E> struct Function;
template <typename E> struct Function_v2v;
template <typename E> struct Function_v2w2v;
template <typename E> struct Function_v2w_w2v;
template <typename E> struct Function_i2b;
template <typename E> struct Function_i2v;
template <typename E> struct Function_p2v;
template <typename E> struct Function_v2b;
template <typename E> struct Function_p2b;
template <typename E> struct Function_p2p;
template <typename E> struct Function_x2x;
template <typename E> struct Function_vv2v;
template <typename E> struct Function_vv2b;
/// Function category flag type.
template <>
struct Function<void>
......@@ -63,19 +55,19 @@ namespace mln
};
/// Base class for implementation of function-objects.
/// \brief Base class for implementation of function-objects.
///
/// The parameter \a E is the exact type.
///
/// \ingroup modfun
//
template <typename E>
struct Function : public Object<E>
{
typedef Function<void> category;
/*
** An operator() has to be provided. Its signature depends
** on the particular function-object one considers.
*/
/// An operator() has to be provided. Its signature depends
/// on the particular function-object one considers.
protected:
Function();
......@@ -90,6 +82,7 @@ namespace mln
template <>
struct Function_v2v<void> { typedef Function<void> super; };
/// \brief Base class for implementation of function-objects from
/// value to value.
///
......@@ -108,149 +101,6 @@ namespace mln
};
/*----------------------------.
| Value <-> Value (Bijective) |
`----------------------------*/
// FIXME : should it also be a v2v function?
template <>
struct Function_v2w2v<void> { typedef Function<void> super; };
/*!
* \brief Base class for implementation of function-objects from
* value V to value W and vice versa.
*
* The parameter \a E is the exact type.
*
* \ingroup modfun
*/
template <typename E>
struct Function_v2w2v : public Function<E>
{
typedef Function_v2w2v<void> category;
/*
result operator() (value);
value f_1 (result);
*/
protected:
Function_v2w2v();
Function_v2w2v(const Function_v2w2v&);
};
/*---------------------------.
| Value <-> Value (Two ways) |
`---------------------------*/
// FIXME : should it also be a v2v function?
template <>
struct Function_v2w_w2v<void> { typedef Function<void> super; };
/*!
* \brief Base class for implementation of function-objects from
* value V to value W and from W to V thanks to the previous
* value V.
*
* The parameter \a E is the exact type.
*
* eg: f : x -> norm(x)
* f_1: (x, n) -> x' := x / norm(x) * n
*
* \ingroup modfun
*/
template <typename E>
struct Function_v2w_w2v : public Function<E>
{
typedef Function_v2w_w2v<void> category;
/*
result operator() (value);
value f_1 (result, value);
*/
protected:
Function_v2w_w2v();
Function_v2w_w2v(const Function_v2w_w2v&);
};
/*-----------------.
| Index -> bool. |
`-----------------*/
template <>
struct Function_i2b<void> { typedef Function_v2b<void> super; };
/// Base class for implementation of function-objects from
/// index to value.
///
/// The parameter \a E is the exact type.
///
/// \ingroup modfun
//
template <typename E>
struct Function_i2b : public Function_v2b<E>
{
typedef Function_i2b<void> category;
typedef bool result;
protected:
Function_i2b();
Function_i2b(const Function_i2b&);
};
/*-----------------.
| Index -> Value. |
`-----------------*/
template <>
struct Function_i2v<void> { typedef Function_v2v<void> super; };
/// Base class for implementation of function-objects from
/// index to value.
///
/// The parameter \a E is the exact type.
///
/// \ingroup modfun
//
template <typename E>
struct Function_i2v : public Function_v2v<E>
{
typedef Function_i2v<void> category;
protected:
Function_i2v();
Function_i2v(const Function_i2v&);
};
/*-----------------.
| Point -> Value. |
`-----------------*/
template <>
struct Function_p2v<void> { typedef Function_v2v<void> super; };
/// Base class for implementation of function-objects from point to
/// value.
///
/// The parameter \a E is the exact type.
///
/// \ingroup modfun
//
template <typename E>
struct Function_p2v : public virtual Function_v2v<E>
{
typedef Function_p2v<void> category;
protected:
Function_p2v();
Function_p2v(const Function_p2v&);
};
/*----------------.
| Value -> bool. |
`----------------*/
......@@ -258,8 +108,9 @@ namespace mln
template <>
struct Function_v2b<void> { typedef Function_v2v<void> super; };
/// Base class for implementation of function-objects from value to
/// bool.
/// \brief Base class for implementation of function-objects from a
/// value to a Boolean.
///
/// The parameter \a E is the exact type.
///
......@@ -276,112 +127,17 @@ namespace mln
};
/*----------------.
| Point -> bool. |
`----------------*/
template <>
struct Function_p2b<void> { typedef Function_p2v<void> super; }; // FIXME
/// Base class for implementation of function-objects from point to
/// bool.
///
/// The parameter \a E is the exact type.
///
/// \ingroup modfun
//
template <typename E>
struct Function_p2b : public Function_p2v<E>,
public Function_v2b<E>
{
typedef Function_p2b<void> category;
typedef bool result;
protected:
Function_p2b();
Function_p2b(const Function_p2b&);
};
/*-----------------.
| Point -> Point. |
`-----------------*/
template <>
struct Function_p2p<void> { typedef Function_p2v<void> super; }; // FIXME
/// Base class for implementation of function-objects from point to
/// point.
///
/// The parameter \a E is the exact type.
///
/// \ingroup modfun
//
template <typename E>
struct Function_p2p : public Function_p2v<E>
{
typedef Function_p2p<void> category;
protected:
Function_p2p();
Function_p2p(const Function_p2p&);
};
/*-------------------.
| Vector -> Vector. |
`-------------------*/
template <>
struct Function_x2x<void> { typedef Function_v2v<void> super; }; // FIXME
/// Base class for implementation of function-objects from vector to
/// Vector.
///
/// The parameter \a E is the exact type.
///
/// \ingroup modfun
//
template <typename E>
struct Function_x2x : public Function_v2v<E>
{
typedef Function_x2x<void> category;
protected:
Function_x2x();
Function_x2x(const Function_x2x&);
};
/*--------------------.
| Vector <-> Vector. |
`--------------------*/
/// Base class for implementation of bijective function-objects from
/// vector to vector.
///
/// The parameter \a E is the exact type.
///
/// \ingroup modfun
//
template <typename E>
struct Bijection_x2x : public Function_x2x< E >
{
/*
typedef invert;
invert inv() const;
*/
protected:
Bijection_x2x();
};
/*------------------------.
| Value, Value -> Value. |
`------------------------*/
/*--------------------------.
| (Value, Value) -> Value. |
`--------------------------*/
template <>
struct Function_vv2v<void> { typedef Function<void> super; };
/// Base class for implementation of function-objects from
/// a couple of values to a value.
/// \brief Base class for implementation of function-objects from a
/// couple of values to a value.
///
/// The parameter \a E is the exact type.
///
......@@ -396,15 +152,17 @@ namespace mln
Function_vv2v(const Function_vv2v&);
};
/*------------------------.
| Value, Value -> Boolean.|
`------------------------*/
/*--------------------------.
| (Value, Value) -> Boolean.|
`--------------------------*/
template <>
struct Function_vv2b<void> { typedef Function<void> super; };
/// Base class for implementation of function-objects from
/// a couple of values to a boolean.
/// \brief Base class for implementation of function-objects from a
/// couple of values to a Boolean.
///
/// The parameter \a E is the exact type.
///
......@@ -421,8 +179,11 @@ namespace mln
};
# ifndef MLN_INCLUDE_ONLY
// Function.
template <typename E>
inline
Function<E>::Function()
......@@ -437,6 +198,8 @@ namespace mln
{
}
// Function_v2v.
template <typename E>
inline
Function_v2v<E>::Function_v2v()
......@@ -450,72 +213,7 @@ namespace mln
{
}
template <typename E>
inline
Function_v2w2v<E>::Function_v2w2v()
{
}
template <typename E>
inline
Function_v2w2v<E>::Function_v2w2v(const Function_v2w2v<E>& rhs)
: Function<E>(rhs)
{
}
template <typename E>
inline
Function_v2w_w2v<E>::Function_v2w_w2v()
{
}
template <typename E>
inline
Function_v2w_w2v<E>::Function_v2w_w2v(const Function_v2w_w2v<E>& rhs)
: Function<E>(rhs)
{
}
template <typename E>
inline
Function_i2b<E>::Function_i2b()
{
}
template <typename E>
inline
Function_i2b<E>::Function_i2b(const Function_i2b<E>& rhs)
: Function_v2v<E>(rhs),
Function_v2b<E>(rhs)