869: Add plain and ch_value functions on images.

https://svn.lrde.epita.fr/svn/oln/trunk/olena Index: ChangeLog from 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. oln/core/2d/image2d.hh | 3 oln/core/2d/image2d_b.hh | 3 oln/core/concept/image.hh | 1 oln/core/equipment.hh | 3 oln/core/gen/op.hh | 6 + oln/core/gen/single_value_image.hh | 6 + oln/core/internal/f_ch_value.hh | 101 +++++++++++++++++++++++++++++++++ oln/core/internal/f_pset_plain.hh | 71 +++++++++++++++++++++++ oln/core/internal/image_base.hh | 21 ++++++ oln/core/internal/instant_value.hh | 6 + oln/core/internal/op_image_plus_nbh.hh | 55 ++++++++++++++++- oln/stc/scoop.hh | 4 + tests/core/Makefile.am | 1 tests/core/neighb2d.cc | 1 14 files changed, 272 insertions(+), 10 deletions(-) Index: tests/core/neighb2d.cc --- tests/core/neighb2d.cc (revision 868) +++ tests/core/neighb2d.cc (working copy) @@ -60,6 +60,5 @@ // 2 + 3 + 2 + // 3 + 4 + 3 + // 2 + 3 + 2 = 24 - std::cout << test::run(ima + c4) << std::endl; assert(test::run(ima + c4) = 24); } Index: tests/core/Makefile.am --- tests/core/Makefile.am (revision 868) +++ tests/core/Makefile.am (working copy) @@ -25,7 +25,6 @@ image2d \ neighb2d \ npoints \ - neighb2d \ window2d \ at Index: oln/core/concept/image.hh --- oln/core/concept/image.hh (revision 868) +++ oln/core/concept/image.hh (working copy) @@ -123,6 +123,7 @@ stc_typename(pset); // stc_typename(output); // FIXME: Uncomment! + stc_typename(plain); bool owns_(const psite& p) const; rvalue operator()(const psite& p) const; Index: oln/core/equipment.hh --- oln/core/equipment.hh (revision 868) +++ oln/core/equipment.hh (working copy) @@ -95,11 +95,13 @@ // 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 @@ // s stc_decl_associated_type( std_container ); + stc_decl_associated_type( skeleton ); // t stc_decl_associated_type( tag ); Index: oln/core/2d/image2d.hh --- oln/core/2d/image2d.hh (revision 868) +++ oln/core/2d/image2d.hh (working copy) @@ -56,6 +56,9 @@ typedef box2d pset; typedef array2d_<value, coord> data; + + typedef image2d<T> plain; + typedef image2d<pl::value> skeleton; }; Index: oln/core/2d/image2d_b.hh --- oln/core/2d/image2d_b.hh (revision 868) +++ oln/core/2d/image2d_b.hh (working copy) @@ -101,6 +101,9 @@ typedef box2d pset; typedef internal::array_b_<point2d, T> data; + typedef image2d_b<T> plain; + typedef image2d_b<pl::value> skeleton; + // FIXME: wrong qiter!!! }; Index: oln/core/gen/op.hh --- oln/core/gen/op.hh (revision 868) +++ oln/core/gen/op.hh (working copy) @@ -138,6 +138,7 @@ class op_ : public super { public: + op_(); op_(L& l, R& r); }; // end of op_<L, OpName, R> @@ -147,6 +148,11 @@ # 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) { Index: oln/core/gen/single_value_image.hh --- oln/core/gen/single_value_image.hh (revision 868) +++ oln/core/gen/single_value_image.hh (working copy) @@ -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 @@ 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 @@ this->data_->value2 = new_value; } -# endif +# endif // OLN_INCLUDE_ONLY } // end of namespace oln Index: oln/core/internal/f_ch_value.hh --- oln/core/internal/f_ch_value.hh (revision 0) +++ oln/core/internal/f_ch_value.hh (revision 0) @@ -0,0 +1,101 @@ +// 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 Index: oln/core/internal/f_pset_plain.hh --- oln/core/internal/f_pset_plain.hh (revision 0) +++ oln/core/internal/f_pset_plain.hh (revision 0) @@ -0,0 +1,71 @@ +// 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 Index: oln/core/internal/op_image_plus_nbh.hh --- oln/core/internal/op_image_plus_nbh.hh (revision 868) +++ oln/core/internal/op_image_plus_nbh.hh (working copy) @@ -62,6 +62,9 @@ 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 @@ 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) + 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 Index: oln/core/internal/instant_value.hh --- oln/core/internal/instant_value.hh (revision 868) +++ oln/core/internal/instant_value.hh (working copy) @@ -60,13 +60,16 @@ { 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 @@ M<W> tmp(this->value); return tmp; } + */ # endif // OLN_INCLUDE_ONLY Index: oln/core/internal/image_base.hh --- oln/core/internal/image_base.hh (revision 868) +++ oln/core/internal/image_base.hh (working copy) @@ -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 @@ 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 @@ { 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> Index: oln/stc/scoop.hh --- oln/stc/scoop.hh (revision 868) +++ oln/stc/scoop.hh (working copy) @@ -99,6 +99,10 @@ # 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)
participants (1)
-
Thierry Geraud