Commit 3ee9a03a authored by Thierry Geraud's avatar Thierry Geraud
Browse files

Add plain and ch_value functions on images.

	* oln/core/internal/f_ch_value.hh,
	* oln/core/internal/f_pset_plain.hh: New.
	* tests/core/neighb2d.cc: Fix.
	* tests/core/Makefile.am: Fix.
	* oln/core/concept/image.hh (plain): New.
	* oln/core/equipment.hh (plain, skeleton): New.
	(oln_plain): New.
	* oln/core/2d/image2d.hh: Update.
	* oln/core/2d/image2d_b.hh: Update.
	* oln/core/gen/op.hh (op_): New ctor.
	* oln/core/gen/single_value_image.hh: Update.
	* oln/core/internal/op_image_plus_nbh.hh: Separate decl and impl.
	(special_op_): New ctor.
	* oln/core/internal/instant_value.hh: Inactivate code that does not
	compile with g++-3.
	* oln/core/internal/image_base.hh (pl::value, pl::rec): New.
	(image_base_): Update.
	* oln/stc/scoop.hh (stc_type_in_, stc_type_in): New.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@869 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 6cbbd47d
2007-03-13 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add plain and ch_value functions on images.
* oln/core/internal/f_ch_value.hh,
* oln/core/internal/f_pset_plain.hh: New.
* tests/core/neighb2d.cc: Fix.
* tests/core/Makefile.am: Fix.
* oln/core/concept/image.hh (plain): New.
* oln/core/equipment.hh (plain, skeleton): New.
(oln_plain): New.
* oln/core/2d/image2d.hh: Update.
* oln/core/2d/image2d_b.hh: Update.
* oln/core/gen/op.hh (op_): New ctor.
* oln/core/gen/single_value_image.hh: Update.
* oln/core/internal/op_image_plus_nbh.hh: Separate decl and impl.
(special_op_): New ctor.
* oln/core/internal/instant_value.hh: Inactivate code that does not
compile with g++-3.
* oln/core/internal/image_base.hh (pl::value, pl::rec): New.
(image_base_): Update.
* oln/stc/scoop.hh (stc_type_in_, stc_type_in): New.
2007-03-13 Thierry Geraud <thierry.geraud@lrde.epita.fr>
Add initialization material; extend point2d and box2d with it.
......
......@@ -56,6 +56,9 @@ namespace oln
typedef box2d pset;
typedef array2d_<value, coord> data;
typedef image2d<T> plain;
typedef image2d<pl::value> skeleton;
};
......
......@@ -101,6 +101,9 @@ namespace oln
typedef box2d pset;
typedef internal::array_b_<point2d, T> data;
typedef image2d_b<T> plain;
typedef image2d_b<pl::value> skeleton;
// FIXME: wrong qiter!!!
};
......
......@@ -123,6 +123,7 @@ namespace oln
stc_typename(pset);
// stc_typename(output); // FIXME: Uncomment!
stc_typename(plain);
bool owns_(const psite& p) const;
rvalue operator()(const psite& p) const;
......
......@@ -95,11 +95,13 @@ namespace oln
// p
stc_decl_associated_type( piter );
stc_decl_associated_type( plain );
stc_decl_associated_type( point );
stc_decl_associated_type( pset );
stc_decl_associated_type( psite );
# define oln_piter(T) oln_typename_shortcut__(T, piter)
# define oln_plain(T) oln_typename_shortcut__(T, plain)
# define oln_point(T) oln_typename_shortcut__(T, point)
// q
......@@ -114,6 +116,7 @@ namespace oln
// s
stc_decl_associated_type( std_container );
stc_decl_associated_type( skeleton );
// t
stc_decl_associated_type( tag );
......
......@@ -138,6 +138,7 @@ namespace oln
class op_ : public super
{
public:
op_();
op_(L& l, R& r);
}; // end of op_<L, OpName, R>
......@@ -146,6 +147,11 @@ namespace oln
# ifndef OLN_INCLUDE_ONLY
template <typename L, typename OpName, typename R>
op_<L, OpName, R>::op_()
{
}
template <typename L, typename OpName, typename R>
op_<L, OpName, R>::op_(L& l, R& r)
: super (l, r)
......
......@@ -30,6 +30,7 @@
# include <oln/core/internal/image_base.hh>
# include <oln/core/internal/utils.hh>
# include <oln/core/internal/f_pset_plain.hh>
namespace oln
......@@ -54,6 +55,9 @@ namespace oln
typedef const T& rvalue;
typedef internal::pair<Ps, T> data;
typedef oln_f_pset_plain(Ps, T) plain;
typedef single_value_image<Ps, pl::value> skeleton;
};
......@@ -151,7 +155,7 @@ namespace oln
this->data_->value2 = new_value;
}
# endif
# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
......
// Copyright (C) 2007 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 OLN_CORE_INTERNAL_F_CH_VALUE_HH
# define OLN_CORE_INTERNAL_F_CH_VALUE_HH
# include <oln/core/internal/image_base.hh>
#define oln_ch_value_(I, T) \
oln::internal::f_ch_value_< stc_type_in_(oln, I, skeleton), T >::ret
#define oln_ch_value(I, T) \
typename oln::internal::f_ch_value_< stc_type_in(oln, I, skeleton), T >::ret
namespace oln
{
namespace internal
{
template <typename I, typename T> struct f_ch_value_;
template <template <class> class tc,
typename T>
struct f_ch_value_< tc<pl::value>,
T >
{
typedef tc<T> ret;
};
template <template <class, class> class tcc, typename t,
typename T>
struct f_ch_value_< tcc<t, pl::value>,
T >
{
typedef tcc<t, T> ret;
};
template <template <class> class tc, typename t,
typename T>
struct f_ch_value_< tc< pl::rec<t> >,
T >
{
typedef tc< oln_ch_value(t, T) > ret;
};
template <template <class, class> class tcc, typename t1, typename t2,
typename T>
struct f_ch_value_< tcc< pl::rec<t1>, t2 >,
T >
{
typedef tcc< oln_ch_value(t1, T), t2 > ret;
};
template <template <class, class, class> class tccc, typename t1, typename t2, typename t3,
typename T>
struct f_ch_value_< tccc< pl::rec<t1>, t2, t3 >,
T >
{
typedef tccc< oln_ch_value(t1, T), t2, t3 > ret;
};
} // end of namespace oln::internal
} // end of namespace oln
#endif // ! OLN_CORE_INTERNAL_F_CH_VALUE_HH
// Copyright (C) 2007 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 OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
# define OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
# include <oln/core/concept/point_set.hh>
#define oln_f_pset_plain(Ps, T) typename oln::internal::f_pset_plain_< Ps, T >::ret
namespace oln
{
// Fwd decls.
struct grid2d_rec;
template <typename P> class box_;
typedef box_<point2d> box2d;
template <typename T> class image2d_b;
namespace internal
{
template <typename Gr, typename Ps, typename T>
struct f_pset_plain__;
template <typename T>
struct f_pset_plain__< grid2d_rec, box2d, T >
{
typedef image2d_b<T> ret;
};
template <typename Ps, typename T>
struct f_pset_plain_ : private mlc::assert_< mlc_is_a(Ps, Point_Set) >,
public f_pset_plain__< stc_type(Ps, grid), Ps, T >
{
};
} // end of namespace oln::internal
} // end of namespace oln
#endif // ! OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
......@@ -40,6 +40,19 @@
namespace oln
{
// FIXME: Experimental code below.
namespace pl // placeholder for short
{
struct value;
template <typename t> struct rec;
}
// End of experimental code.
/// Fwd decls.
namespace internal
......@@ -116,7 +129,9 @@ namespace oln
typedef stc::abstract rvalue;
// FIXME: Uncomment below!
// typedef stc::abstract output;
// typedef stc::abstract ...
typedef stc::abstract skeleton;
typedef stc::abstract plain;
typedef stc::abstract data;
......@@ -155,7 +170,11 @@ namespace oln
{
typedef stc::abstract delegatee;
typedef stc::abstract behavior;
// not delegated:
typedef stc::not_delegated data;
typedef stc::not_delegated plain;
typedef stc::not_delegated skeleton;
};
template <typename Exact>
......
......@@ -60,13 +60,16 @@ namespace oln
{
V value;
/*
template <typename W>
operator M<W>() const;
operator M<W>() const; // FIXME: do not compile with g++-3!!!
*/
};
# ifndef OLN_INCLUDE_ONLY
/*
template <template<class> class M, typename V>
template <typename W>
instant_value_<M,V>::operator M<W>() const
......@@ -74,6 +77,7 @@ namespace oln
M<W> tmp(this->value);
return tmp;
}
*/
# endif // OLN_INCLUDE_ONLY
......
......@@ -62,6 +62,9 @@ namespace oln
typedef N nbh;
typedef dpoints_fwd_piter_<point__> fwd_niter;
typedef dpoints_bkd_piter_<point__> bkd_niter;
typedef op_<oln_plain(I), plus, N> plain;
typedef op_<pl::rec<I>, plus, N> skeleton;
};
......@@ -81,18 +84,60 @@ namespace oln
stc_using(data);
stc_using(delegatee);
delegatee& impl_image() { assert(this->has_data()); return this->data_->value1; }
const delegatee& impl_image() const { assert(this->has_data()); return this->data_->value1; }
delegatee& impl_image();
const delegatee& impl_image() const;
nbh impl_nbhood() const { assert(this->has_data()); return this->data_->value2; }
nbh impl_nbhood() const;
protected:
special_op_(I& ima, N& n)
{
this->data_ = new data(ima, n);
}
special_op_();
special_op_(I& ima, N& n);
};
# ifndef OLN_INCLUDE_ONLY
# define current \
special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
template <typename I, typename N>
current::special_op_()
{
}
template <typename I, typename N>
current::special_op_(I& ima, N& n)
{
this->data_ = new data(ima, n);
}
template <typename I, typename N>
typename current::delegatee&
current::impl_image()
{
assert(this->has_data());
return this->data_->value1;
}
template <typename I, typename N>
const typename current::delegatee&
current::impl_image() const
{
assert(this->has_data());
return this->data_->value1;
}
template <typename I, typename N>
typename current::nbh
current::impl_nbhood() const
{
assert(this->has_data());
return this->data_->value2;
}
# undef current
# endif // OLN_INCLUDE_ONLY
} // end of namespace oln::internal
......
......@@ -99,6 +99,10 @@ namespace stc
# define stc_type_(From, Type) vtype<From, typedef_::Type>::ret
# define stc_type(From, Type) typename stc_type_(From, Type)
# define stc_type_in_(Namespace, From, Type) Namespace::vtype<From, Namespace::typedef_::Type>::ret
# define stc_type_in(Namespace, From, Type) typename stc_type_in_(Namespace, From, Type)
# define stc_get_type_(Type) vtype<Exact, typedef_::Type>::ret
# define stc_get_type(Type) typename stc_get_type_(Type)
......
......@@ -25,7 +25,6 @@ check_PROGRAMS = \
image2d \
neighb2d \
npoints \
neighb2d \
window2d \
at
......
......@@ -60,6 +60,5 @@ int main()
// 2 + 3 + 2 +
// 3 + 4 + 3 +
// 2 + 3 + 2 = 24
std::cout << test::run(ima + c4) << std::endl;
assert(test::run(ima + c4) == 24);
}
Markdown is supported
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