r720: Split morphers' interface and implementation.

-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 URL: https://svn.lrde.epita.fr/svn/oln/trunk/olena ChangeLog: 2007-01-19 Thomas Moulard <thomas.moulard@lrde.epita.fr> Split morphers' interface and implementation. * oln/morpher/add_isubset.hh: Split into... * oln/morpher/add_isubset.hxx: ...this new file. * oln/morpher/add_neighborhood.hh: Split into... * oln/morpher/add_neighborhood.hxx: : ...this new file. * oln/morpher/count_rw.hh: Split into... * oln/morpher/count_rw.hxx: : ...this new file. * oln/morpher/identity.hh: Split into... * oln/morpher/identity.hxx: : ...this new file. * oln/morpher/stack.hh: Split into... * oln/morpher/stack.hxx: : ...this new file. * oln/morpher/stack_rw.hh: Split into... * oln/morpher/stack_rw.hxx: : ...this new file. * oln/morpher/thru_fun.hh: Split into... * oln/morpher/thru_mfun.hh: Split into... * oln/morpher/thru_mfun.hxx: : ...this new file. * oln/morpher/two_way.hh: Split into... * oln/morpher/two_way.hxx: : ...this new file. * oln/morpher/two_way_rw.hh: Split into... * oln/morpher/two_way_rw.hxx: : ...this new file. * oln/morpher/value_cast.hh: Split into... * oln/morpher/value_cast.hxx: : ...this new file. * oln/morpher/with_lut.hh: Split into... * oln/morpher/with_lut.hxx: : ...this new file. add_isubset.hh | 60 ++---------------------- add_isubset.hxx | 98 +++++++++++++++++++++++++++++++++++++++ add_neighborhood.hh | 40 +--------------- add_neighborhood.hxx | 82 ++++++++++++++++++++++++++++++++ count_rw.hh | 62 +----------------------- count_rw.hxx | 105 ++++++++++++++++++++++++++++++++++++++++++ identity.hh | 10 ++-- identity.hxx | 55 ++++++++++++++++++++++ stack.hh | 75 +----------------------------- stack.hxx | 121 ++++++++++++++++++++++++++++++++++++++++++++++++ stack_rw.hh | 92 ++---------------------------------- stack_rw.hxx | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ thru_fun.hh | 8 +-- thru_mfun.hh | 39 +++------------ thru_mfun.hxx | 64 +++++++++++++++++++++++++ two_way.hh | 52 ++++---------------- two_way.hxx | 80 ++++++++++++++++++++++++++++++++ two_way_rw.hh | 42 +--------------- two_way_rw.hxx | 79 +++++++++++++++++++++++++++++++ value_cast.hh | 35 ++------------ value_cast.hxx | 68 +++++++++++++++++++++++++++ with_lut.hh | 64 +------------------------ with_lut.hxx | 91 ++++++++++++++++++++++++++++++++++++ 23 files changed, 1034 insertions(+), 515 deletions(-) Index: oln/morpher/stack_rw.hxx =================================================================== - --- oln/morpher/stack_rw.hxx (revision 0) +++ oln/morpher/stack_rw.hxx (revision 0) @@ -0,0 +1,127 @@ +// 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_MORPHER_STACK_RW_HXX +# define OLN_MORPHER_STACK_RW_HXX + +namespace oln +{ + + namespace morpher + { + + template <unsigned n, typename I> + stack_rw<n, I>::stack_rw(const xtd::vec<n, I>& images) : + super_t(images[0]), + images_(images) + { + } + + template <unsigned n, typename I> + xtd::vec<n, oln_value(I)> + stack_rw<n, I>::impl_op_read(const typename stack_rw<n, I>::psite_t& p) const + { + xtd::vec<n, oln_value(I)> tmp; + for (unsigned i = 0; i < n; ++i) + tmp[i] = images_[i](p); + return tmp; + } + + template <unsigned n, typename I> + typename stack_rw<n, I>::lvalue_t + stack_rw<n, I>::impl_op_readwrite(const typename stack_rw<n, I>::psite_t& p) + { + lvalue_t tmp(*this, p); + return tmp; + } + + template <unsigned n, typename I> + const I& + stack_rw<n, I>::image(unsigned i) const + { + precondition(i < n); + return images_[i]; + } + + template <unsigned n, typename I> + I& + stack_rw<n, I>::image(unsigned i) + { + precondition(i < n); + return images_[i]; + } + + } // end of namespace oln::morpher + + + template <typename I> + morpher::stack_rw<2, I> + stack_rw(abstract::mutable_image<I>& image_0, + abstract::mutable_image<I>& image_1) + { + morpher::stack_rw<2, I> tmp(xtd::mk_vec(image_0.exact(), + image_1.exact())); + return tmp; + } + + template <typename I> + morpher::stack_rw<3, I> + stack_rw(abstract::mutable_image<I>& image_0, + abstract::mutable_image<I>& image_1, + abstract::mutable_image<I>& image_2) + { + morpher::stack_rw<3, I> tmp(xtd::mk_vec(image_0.exact(), + image_1.exact(), + image_2.exact())); + return tmp; + } + + template <typename I> + morpher::stack_rw<4, I> + stack_rw(abstract::mutable_image<I>& image_0, + abstract::mutable_image<I>& image_1, + abstract::mutable_image<I>& image_2, + abstract::mutable_image<I>& image_3) + { + morpher::stack_rw<4, I> tmp(xtd::mk_vec(image_0.exact(), + image_1.exact(), + image_2.exact(), + image_3.exact())); + return tmp; + } + +} // end of namespace oln + +#endif // ! OLN_MORPHER_STACK_RW_HXX + + + + + + + + Index: oln/morpher/add_isubset.hh =================================================================== - --- oln/morpher/add_isubset.hh (revision 719) +++ oln/morpher/add_isubset.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. - -#ifndef OLN_MORPHER_ADD_ISUBSET - -# define OLN_MORPHER_ADD_ISUBSET +#ifndef OLN_MORPHER_ADD_ISUBSET_HH +# define OLN_MORPHER_ADD_ISUBSET_HH # include <oln/core/abstract/image.hh> # include <oln/core/abstract/image/type/binary.hh> @@ -93,34 +93,9 @@ protected: topo_t topo_; }; - - - - - - - -# ifndef OLN_INCLUDE_ONLY - - - - template <typename Image, typename Isubset> - - add_isubset<Image, Isubset>::add_isubset(const Image& image, const Isubset& isubset) : - - super_t(image), - - topo_(image.topo(), isubset) - - { - - // mlc::assert_equal_<oln_vtype(Image, grid), oln_vtype(Isubset, grid)>::check(); - - // FIXME: check that Image is without a isubset - - } - - - - template <typename Image, typename Isubset> - - const typename add_isubset<Image, Isubset>::topo_t& - - add_isubset<Image, Isubset>::impl_topo() const - - { - - return topo_; - - } - - - -# endif - - - - } // end of namespace oln::morpher - - template <typename I, typename S> morpher::add_isubset<I, S> operator | (const abstract::image<I>& image, @@ -135,33 +110,10 @@ operator | (const abstract::image<I>& image, const xtd::abstract::fun_nary_expr_<1,S>& fsubset); - - +} // end of namespace oln # ifndef OLN_INCLUDE_ONLY - - - - template <typename I, typename S> - - morpher::add_isubset<I, S> - - operator | (const abstract::image<I>& image, - - const abstract::binary_image<S>& isubset) - - { - - mlc::assert_equal_<oln_vtype(I, grid), oln_vtype(S, grid)>::check(); - - // FIXME: check that Image does not have yet a subset - - morpher::add_isubset<I, S> tmp(image.exact(), isubset.exact()); - - return tmp; - - } - - - - template <typename I, typename S> - - morpher::add_isubset<I, S> - - operator | (const abstract::image<I>& image, - - const xtd::abstract::fun_nary_expr_<1,S>& fsubset) - - { - - morpher::add_isubset<I, S> tmp(image.exact(), fsubset.exact_()); - - return tmp; - - } - - +# include "add_isubset.hxx" # endif - -} // end of namespace oln - - - - - -#endif // ! OLN_MORPHER_ADD_ISUBSET +#endif // ! OLN_MORPHER_ADD_ISUBSET_HH Index: oln/morpher/value_cast.hh =================================================================== - --- oln/morpher/value_cast.hh (revision 719) +++ oln/morpher/value_cast.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. - -#ifndef OLN_MORPHER_VALUE_CAST - -# define OLN_MORPHER_VALUE_CAST +#ifndef OLN_MORPHER_VALUE_CAST_HH +# define OLN_MORPHER_VALUE_CAST_HH # include <xtd/abstract/open_nary_fun.hh> # include <xtd/res.hh> @@ -86,17 +86,6 @@ value_cast(const Image& image); }; - - - -# ifndef OLN_INCLUDE_ONLY - - - - template <typename Image, typename Value> - - value_cast<Image, Value>::value_cast(const Image& image) : - - super_t(image) - - { - - } - - - -# endif - - } // end of namespace oln::morpher @@ -105,21 +94,11 @@ value_cast(const abstract::image<I>& ima); - -# ifndef OLN_INCLUDE_ONLY - - - - template <typename Value, typename I> - - morpher::value_cast<I, Value> - - value_cast(const abstract::image<I>& ima) - - { - - morpher::value_cast<I, Value> tmp(ima.exact()); - - return tmp; - - } - - - -# endif - - - - } // end of namespace oln +# ifndef OLN_INCLUDE_ONLY +# include "value_cast.hxx" +# endif - -#endif // ! OLN_MORPHER_VALUE_CAST +#endif // ! OLN_MORPHER_VALUE_CAST_HH Index: oln/morpher/add_neighborhood.hxx =================================================================== - --- oln/morpher/add_neighborhood.hxx (revision 0) +++ oln/morpher/add_neighborhood.hxx (revision 0) @@ -0,0 +1,82 @@ +// 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_MORPHER_ADD_NEIGHBORHOOD_HXX +# define OLN_MORPHER_ADD_NEIGHBORHOOD_HXX + +namespace oln +{ + + namespace morpher + { + + template <typename Image, typename Neighb> + add_neighborhood<Image, Neighb>::add_neighborhood(const Image& image, const Neighb& nbh) : + super_t(image), + topo_(image.topo(), nbh) + { + mlc::assert_equal_<oln_vtype(Image, grid), oln_vtype(Neighb, grid)>::check(); + // FIXME: check that Image is without a nbh + } + + template <typename Image, typename Neighb> + const typename add_neighborhood<Image, Neighb>::topo_t& + add_neighborhood<Image, Neighb>::impl_topo() const + { + return topo_; + } + + } // end of namespace oln::morpher + + + template <typename I, typename N> + morpher::add_neighborhood<I, N> + operator + (const abstract::image<I>& image, + const abstract::neighborhood<N>& nbh) + { + mlc::assert_equal_<oln_vtype(I, grid), oln_vtype(N, grid)>::check(); + // FIXME: check that Image is without a nbh + morpher::add_neighborhood<I, N> tmp(image.exact(), nbh.exact()); + return tmp; + } + +} // end of namespace oln + +#endif // ! ADD_NEIGHBORHOOD_HXX + + + + + + + + + + + + + Index: oln/morpher/two_way.hh =================================================================== - --- oln/morpher/two_way.hh (revision 719) +++ oln/morpher/two_way.hh (working copy) @@ -109,56 +109,24 @@ } // end of namespace oln::morpher::ERROR + } // end of namespace oln::morpher + +} // end of namespace oln + # ifndef OLN_INCLUDE_ONLY +# include "two_way.hxx" +# endif - - // public +# include <oln/value/two_way.hxx> + + +#endif // ! OLN_MORPHER_TWO_WAY_HH - - template <typename Image, typename Fun> - - two_way<Image, Fun>::two_way(Image& image) : - - super_t(image), - - fun_() - - { - - } - - - - template <typename Image, typename Fun> - - two_way<Image, Fun>::two_way(Image& image, Fun fun) : - - super_t(image), - - fun_(fun) - - { - - } - - - - template <typename Image, typename Fun> - - two_way<Image, Fun>::two_way(oln::abstract::mutable_image<Image>& image, - - const oln::abstract::fun_v2w2v<Fun>& fun) : - - super_t(image.exact()), - - fun_(fun.exact()) - - { - - } - - - - template <typename Image, typename Fun> - - typename two_way<Image, Fun>::rvalue_t - - two_way<Image, Fun>::impl_op_read(const typename two_way<Image, Fun>::psite_t& p) const - - { - - return fun_.direct(image_(p)); - - } - - - - template <typename Image, typename Fun> - - typename two_way<Image, Fun>::lvalue_t - - two_way<Image, Fun>::impl_op_readwrite(const typename two_way<Image, Fun>::psite_t& p) - - { - - value::two_way<Image, Fun> tmp(image_, fun_, p); - - return tmp; - - } - -# endif - - } // end of namespace oln::morpher - -} // end of namespace oln - -# include <oln/value/two_way.hxx> - -#endif // ! OLN_MORPHER_TWO_WAY_HH Index: oln/morpher/identity.hh =================================================================== - --- oln/morpher/identity.hh (revision 719) +++ oln/morpher/identity.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. - -#ifndef OLN_MORPHER_IDENTITY - -# define OLN_MORPHER_IDENTITY +#ifndef OLN_MORPHER_IDENTITY_HH +# define OLN_MORPHER_IDENTITY_HH # include <oln/morpher/internal/image_extension.hh> @@ -82,4 +82,6 @@ } // end of namespace oln - -#endif // ! OLN_MORPHER_IDENTITY +#endif // ! OLN_MORPHER_IDENTITY_HH + + Index: oln/morpher/thru_fun.hh =================================================================== - --- oln/morpher/thru_fun.hh (revision 719) +++ oln/morpher/thru_fun.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. - -#ifndef OLN_MORPHER_THRU_FUN - -# define OLN_MORPHER_THRU_FUN +#ifndef OLN_MORPHER_THRU_FUN_HH +# define OLN_MORPHER_THRU_FUN_HH # include <xtd/res.hh> // For xtd::case_<xtd::tag::fun_operator_1, mlc::pair_<F, Expr>, 1> @@ -149,4 +149,4 @@ - -#endif // ! OLN_MORPHER_THRU_FUN +#endif // ! OLN_MORPHER_THRU_FUN_HH Index: oln/morpher/value_cast.hxx =================================================================== - --- oln/morpher/value_cast.hxx (revision 0) +++ oln/morpher/value_cast.hxx (revision 0) @@ -0,0 +1,68 @@ +// 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_MORPHER_VALUE_CAST_HXX +# define OLN_MORPHER_VALUE_CAST_HXX + +namespace oln +{ + + namespace morpher + { + + template <typename Image, typename Value> + value_cast<Image, Value>::value_cast(const Image& image) : + super_t(image) + { + } + + } // end of namespace oln::morpher + + template <typename Value, typename I> + morpher::value_cast<I, Value> + value_cast(const abstract::image<I>& ima) + { + morpher::value_cast<I, Value> tmp(ima.exact()); + return tmp; + } + +} // end of namespace oln + +#endif // ! OLN_MORPHER_VALUE_CAST_HXX + + + + + + + + + + + + + Index: oln/morpher/add_isubset.hxx =================================================================== - --- oln/morpher/add_isubset.hxx (revision 0) +++ oln/morpher/add_isubset.hxx (revision 0) @@ -0,0 +1,98 @@ +// 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_MORPHER_ADD_ISUBSET_HXX +# define OLN_MORPHER_ADD_ISUBSET_HXX + +namespace oln +{ + + namespace morpher + { + + template <typename Image, typename Isubset> + add_isubset<Image, Isubset>::add_isubset(const Image& image, const Isubset& isubset) : + super_t(image), + topo_(image.topo(), isubset) + { + // mlc::assert_equal_<oln_vtype(Image, grid), oln_vtype(Isubset, grid)>::check(); + // FIXME: check that Image is without a isubset + } + + template <typename Image, typename Isubset> + const typename add_isubset<Image, Isubset>::topo_t& + add_isubset<Image, Isubset>::impl_topo() const + { + return topo_; + } + + } // end of namespace oln::morpher + + + template <typename I, typename S> + morpher::add_isubset<I, S> + operator | (const abstract::image<I>& image, + const abstract::binary_image<S>& isubset) + { + mlc::assert_equal_<oln_vtype(I, grid), oln_vtype(S, grid)>::check(); + // FIXME: check that Image does not have yet a subset + morpher::add_isubset<I, S> tmp(image.exact(), isubset.exact()); + return tmp; + } + + template <typename I, typename S> + morpher::add_isubset<I, S> + operator | (const abstract::image<I>& image, + const xtd::abstract::fun_nary_expr_<1,S>& fsubset) + { + morpher::add_isubset<I, S> tmp(image.exact(), fsubset.exact_()); + return tmp; + } + +} // end of namespace oln + + +#endif // ! OLN_MORPHER_ADD_ISUBSET_HXX + + + + + + + + + + + + + + + + + + + Index: oln/morpher/with_lut.hh =================================================================== - --- oln/morpher/with_lut.hh (revision 719) +++ oln/morpher/with_lut.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -122,50 +122,6 @@ lut_type lut_; }; - - - -# ifndef OLN_INCLUDE_ONLY - - - - template <typename Image, typename Lut> - - with_lut<Image, Lut>::with_lut(const Image& image, const Lut& lut) : - - super_t(image), - - lut_(lut) - - { - - mlc::assert_equal_< oln_value(Image), typename Lut::orig_value_type >::check(); - - } - - - - template <typename Image, typename Lut> - - typename with_lut<Image, Lut>::rvalue_type - - with_lut<Image, Lut>::impl_op_read(const typename with_lut<Image, Lut>::psite_type& p) const - - { - - // FIXME: What if lut_ has no value for `this->image_(p)'? At - - // least, document the behavior of this method (will it abort, - - // does the LUT have to provide a default value, etc.) - - return lut_(this->image_(p)); - - } - - - - template <typename Image, typename Lut> - - typename with_lut<Image, Lut>::value_proxy_type - - with_lut<Image, Lut>::impl_value(const value_type& v) const - - { - - return value_proxy_type(lut_, v); - - } - - - - template <typename Image, typename Lut> - - typename with_lut<Image, Lut>::mutable_value_proxy_type - - with_lut<Image, Lut>::impl_value(const value_type& v) - - { - - return mutable_value_proxy_type(lut_, v); - - } - - - - template <typename Image, typename Lut> - - const typename with_lut<Image, Lut>::lut_type& - - with_lut<Image, Lut>::lut() const - - { - - return lut_; - - } - - - -# endif - - } // end of namespace oln::morpher @@ -176,23 +132,11 @@ operator + (const abstract::image<I>& image, lookup_table<K, D>& lut); +} // end of namespace oln - -# ifndef OLN_INCLUDE_ONLY - - - - template <typename I, typename K, typename D> - - morpher::with_lut< I, lookup_table<K, D> > - - operator + (const abstract::image<I>& image, - - lookup_table<K, D>& lut) - - { - - typedef lookup_table<K, D> lut_type; - - mlc::assert_equal_< oln_value(I), typename lut_type::orig_value_type >::check(); - - morpher::with_lut<I, lut_type> tmp(image.exact(), lut); - - return tmp; - - } +# ifndef OLN_INCLUDE_ONLY +# include "with_lut.hxx" # endif - -} // end of namespace oln - - - - #endif // ! OLN_MORPHER_WITH_LUT_HH Index: oln/morpher/count_rw.hh =================================================================== - --- oln/morpher/count_rw.hh (revision 719) +++ oln/morpher/count_rw.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -99,41 +99,6 @@ } // end of namespace oln::morpher::ERROR - - - -# ifndef OLN_INCLUDE_ONLY - - - - // public - - - - template <typename Image> - - count_rw_<Image>::count_rw_(Image& image) : - - super_t(image) - - { - - } - - - - template <typename Image> - - count_rw_<Image>::count_rw_(oln::abstract::mutable_image<Image>& image) : - - super_t(image.exact()) - - { - - } - - - - template <typename Image> - - oln_rvalue(count_rw_<Image>) - - count_rw_<Image>::impl_op_read(const oln_psite(count_rw_<Image>)& p) const - - { - - value::ro_counter<Image> tmp(image_, p); - - return tmp; - - } - - - - template <typename Image> - - oln_lvalue(count_rw_<Image>) - - count_rw_<Image>::impl_op_readwrite(const oln_psite(count_rw_<Image>)& p) - - { - - value::rw_counter<Image> tmp(image_, p); - - return tmp; - - } - - - -# endif - - } // end of namespace oln::morpher @@ -145,31 +110,10 @@ morpher::count_rw_<I> count_rw(const oln::abstract::mutable_image<I>& input); +} // end of namespace oln # ifndef OLN_INCLUDE_ONLY - - - - template <typename I> - - morpher::count_rw_<I> - - count_rw(oln::abstract::mutable_image<I>& input) - - { - - morpher::count_rw_<I> tmp(input.exact()); - - return tmp; - - } - - - - template <typename I> - - morpher::count_rw_<I> - - count_rw(const oln::abstract::mutable_image<I>& input) - - { - - // FIXME: Hack. - - I& input_ = const_cast<I&>(input.exact()); - - morpher::count_rw_<I> tmp(input_); - - return tmp; - - } - - +# include "count_rw.hxx" # endif - - - -} // end of namespace oln - - - - #endif // ! OLN_MORPHER_COUNT_RW_HH Index: oln/morpher/two_way_rw.hh =================================================================== - --- oln/morpher/two_way_rw.hh (revision 719) +++ oln/morpher/two_way_rw.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -108,47 +108,13 @@ } // end of namespace oln::morpher::ERROR - - - -# ifndef OLN_INCLUDE_ONLY - - - - // public - - - - template <typename Image, typename Fun> - - two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image) : - - super_t(image.exact()), - - fun_() - - { - - } - - - - template <typename Image, typename Fun> - - two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image, - - const oln::abstract::fun_rw<Fun>& fun) : - - super_t(image.exact()), - - fun_(fun.exact()) - - { - - } - - - - template <typename Image, typename Fun> - - typename two_way_rw<Image, Fun>::rvalue_t - - two_way_rw<Image, Fun>::impl_op_read(const typename two_way_rw<Image, Fun>::psite_t& p) const - - { - - return fun_.read(this->delegate(), p); - - } - - - - template <typename Image, typename Fun> - - typename two_way_rw<Image, Fun>::lvalue_t - - two_way_rw<Image, Fun>::impl_op_readwrite(const typename two_way_rw<Image, Fun>::psite_t& p) - - { - - typename two_way_rw<Image, Fun>::lvalue_t tmp(this->delegate(), p); - - return tmp; - - } - - - -# endif - - } // end of namespace oln::morpher } // end of namespace oln +# ifndef OLN_INCLUDE_ONLY +# include "two_way_rw.hxx" +# endif # include <oln/value/two_way.hxx> Index: oln/morpher/identity.hxx =================================================================== - --- oln/morpher/identity.hxx (revision 0) +++ oln/morpher/identity.hxx (revision 0) @@ -0,0 +1,55 @@ +// 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_MORPHER_IDENTITY_HXX +# define OLN_MORPHER_IDENTITY_HXX + +namespace oln +{ + + namespace morpher + { + + template <typename Image> + identity<Image>::identity(const Image& image) : + super_t(image) + { + } + + } // end of namespace oln::morpher + +} // end of namespace oln + + +# endif // ! OLN_MORPHER_IDENTITY_HXX + + + + + + + Index: oln/morpher/two_way.hxx =================================================================== - --- oln/morpher/two_way.hxx (revision 0) +++ oln/morpher/two_way.hxx (revision 0) @@ -0,0 +1,80 @@ +// 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_MORPHER_TWO_WAY_HXX +# define OLN_MORPHER_TWO_WAY_HXX + +namespace oln +{ + + namespace morpher + { + + // public + + template <typename Image, typename Fun> + two_way<Image, Fun>::two_way(Image& image) : + super_t(image), + fun_() + { + } + + template <typename Image, typename Fun> + two_way<Image, Fun>::two_way(Image& image, Fun fun) : + super_t(image), + fun_(fun) + { + } + + template <typename Image, typename Fun> + two_way<Image, Fun>::two_way(oln::abstract::mutable_image<Image>& image, + const oln::abstract::fun_v2w2v<Fun>& fun) : + super_t(image.exact()), + fun_(fun.exact()) + { + } + + template <typename Image, typename Fun> + typename two_way<Image, Fun>::rvalue_t + two_way<Image, Fun>::impl_op_read(const typename two_way<Image, Fun>::psite_t& p) const + { + return fun_.direct(image_(p)); + } + + template <typename Image, typename Fun> + typename two_way<Image, Fun>::lvalue_t + two_way<Image, Fun>::impl_op_readwrite(const typename two_way<Image, Fun>::psite_t& p) + { + value::two_way<Image, Fun> tmp(image_, fun_, p); + return tmp; + } + + } // end of namespace oln::morpher + +} // end of namespace oln + +#endif // ! OLN_MORPHER_TWO_WAY_HXX Index: oln/morpher/stack.hh =================================================================== - --- oln/morpher/stack.hh (revision 719) +++ oln/morpher/stack.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -90,36 +90,6 @@ xtd::vec<n, I> images_; }; - - - -# ifndef OLN_INCLUDE_ONLY - - - - template <unsigned n, typename I> - - stack<n, I>::stack(const xtd::vec<n, I>& images) : - - super_t(images[0]), - - images_(images) - - { - - } - - - - template <unsigned n, typename I> - - xtd::vec<n, oln_value(I)> - - stack<n, I>::impl_op_read(const typename stack<n, I>::psite_t& p) const - - { - - xtd::vec<n, oln_value(I)> tmp; - - for (unsigned i = 0; i < n; ++i) - - tmp[i] = images_[i](p); - - return tmp; - - } - - - - template <unsigned n, typename I> - - const I& - - stack<n, I>::image(unsigned i) const - - { - - precondition(i < n); - - return images_[i]; - - } - - - -# endif - - } // end of namespace oln::morpher @@ -141,49 +111,10 @@ const abstract::image<I>& image_2, const abstract::image<I>& image_3); +} // end of namespace oln # ifndef OLN_INCLUDE_ONLY - - - - - - template <typename I> - - morpher::stack<2, I> - - stack(const abstract::image<I>& image_0, - - const abstract::image<I>& image_1) - - { - - morpher::stack<2, I> tmp(xtd::mk_vec(image_0.exact(), - - image_1.exact())); - - return tmp; - - } - - - - template <typename I> - - morpher::stack<3, I> - - stack(const abstract::image<I>& image_0, - - const abstract::image<I>& image_1, - - const abstract::image<I>& image_2) - - { - - morpher::stack<3, I> tmp(xtd::mk_vec(image_0.exact(), - - image_1.exact(), - - image_2.exact())); - - return tmp; - - } - - - - template <typename I> - - morpher::stack<4, I> - - stack(const abstract::image<I>& image_0, - - const abstract::image<I>& image_1, - - const abstract::image<I>& image_2, - - const abstract::image<I>& image_3) - - { - - morpher::stack<4, I> tmp(xtd::mk_vec(image_0.exact(), - - image_1.exact(), - - image_2.exact(), - - image_3.exact())); - - return tmp; - - } - - +# include "stack.hxx" # endif - -} // end of namespace oln - - - - #endif // ! OLN_MORPHER_STACK_HH Index: oln/morpher/thru_mfun.hh =================================================================== - --- oln/morpher/thru_mfun.hh (revision 719) +++ oln/morpher/thru_mfun.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -25,8 +25,8 @@ // reasons why the executable file might be covered by the GNU General // Public License. - -#ifndef OLN_MORPHER_THRU_MFUN - -# define OLN_MORPHER_THRU_MFUN +#ifndef OLN_MORPHER_THRU_MFUN_HH +# define OLN_MORPHER_THRU_MFUN_HH # include <xtd/res.hh> # include <xtd/abstract/open_nary_fun.hh> @@ -107,35 +107,8 @@ } // end of namespace oln::morpher::ERROR - - - -# ifndef OLN_INCLUDE_ONLY - - - - template <typename Image, typename Fun> - - thru_mfun<Image, Fun>::thru_mfun(const Image& image, const Fun& fun) : - - super_t(image), - - fun_(fun) - - { - - } - - - - template <typename Image, typename Fun> - - typename thru_mfun<Image, Fun>::rvalue_t - - thru_mfun<Image, Fun>::impl_op_read(const typename thru_mfun<Image, Fun>::psite_t& p) const - - { - - return fun_(this->image_(p)); - - } - - - - template <typename Image, typename Fun> - - typename thru_mfun<Image, Fun>::lvalue_t - - thru_mfun<Image, Fun>::impl_op_readwrite(const typename thru_mfun<Image, Fun>::psite_t& p) - - { - - return fun_(this->image_(p)); - - } - - - -# endif - - } // end of namespace oln::morpher - - } // end of namespace oln @@ -177,5 +150,9 @@ } // end of namespace xtd +# ifndef OLN_INCLUDE_ONLY +# include "thru_mfun.hxx" +# endif + +#endif // ! OLN_MORPHER_THRU_MFUN_HH - -#endif // ! OLN_MORPHER_THRU_MFUN Index: oln/morpher/with_lut.hxx =================================================================== - --- oln/morpher/with_lut.hxx (revision 0) +++ oln/morpher/with_lut.hxx (revision 0) @@ -0,0 +1,91 @@ +// 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_MORPHER_WITH_LUT_HXX +# define OLN_MORPHER_WITH_LUT_HXX + +namespace oln +{ + + namespace morpher + { + + template <typename Image, typename Lut> + with_lut<Image, Lut>::with_lut(const Image& image, const Lut& lut) : + super_t(image), + lut_(lut) + { + mlc::assert_equal_< oln_value(Image), typename Lut::orig_value_type >::check(); + } + + template <typename Image, typename Lut> + typename with_lut<Image, Lut>::rvalue_type + with_lut<Image, Lut>::impl_op_read(const typename with_lut<Image, Lut>::psite_type& p) const + { + // FIXME: What if lut_ has no value for `this->image_(p)'? At + // least, document the behavior of this method (will it abort, + // does the LUT have to provide a default value, etc.) + return lut_(this->image_(p)); + } + + template <typename Image, typename Lut> + typename with_lut<Image, Lut>::value_proxy_type + with_lut<Image, Lut>::impl_value(const value_type& v) const + { + return value_proxy_type(lut_, v); + } + + template <typename Image, typename Lut> + typename with_lut<Image, Lut>::mutable_value_proxy_type + with_lut<Image, Lut>::impl_value(const value_type& v) + { + return mutable_value_proxy_type(lut_, v); + } + + template <typename Image, typename Lut> + const typename with_lut<Image, Lut>::lut_type& + with_lut<Image, Lut>::lut() const + { + return lut_; + } + + } // end of namespace oln::morpher + + template <typename I, typename K, typename D> + morpher::with_lut< I, lookup_table<K, D> > + operator + (const abstract::image<I>& image, + lookup_table<K, D>& lut) + { + typedef lookup_table<K, D> lut_type; + mlc::assert_equal_< oln_value(I), typename lut_type::orig_value_type >::check(); + morpher::with_lut<I, lut_type> tmp(image.exact(), lut); + return tmp; + } + +} // end of namespace oln + +#endif // ! OLN_MORPHER_WITH_LUT_HXX Index: oln/morpher/count_rw.hxx =================================================================== - --- oln/morpher/count_rw.hxx (revision 0) +++ oln/morpher/count_rw.hxx (revision 0) @@ -0,0 +1,105 @@ +// 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_MORPHER_COUNT_RW_HXX +# define OLN_MORPHER_COUNT_RW_HXX + +namespace oln +{ + + namespace morpher + { + // public + + template <typename Image> + count_rw_<Image>::count_rw_(Image& image) : + super_t(image) + { + } + + template <typename Image> + count_rw_<Image>::count_rw_(oln::abstract::mutable_image<Image>& image) : + super_t(image.exact()) + { + } + + template <typename Image> + oln_rvalue(count_rw_<Image>) + count_rw_<Image>::impl_op_read(const oln_psite(count_rw_<Image>)& p) const + { + value::ro_counter<Image> tmp(image_, p); + return tmp; + } + + template <typename Image> + oln_lvalue(count_rw_<Image>) + count_rw_<Image>::impl_op_readwrite(const oln_psite(count_rw_<Image>)& p) + { + value::rw_counter<Image> tmp(image_, p); + return tmp; + } + + } // end of namespace oln::morpher + + + template <typename I> + morpher::count_rw_<I> + count_rw(oln::abstract::mutable_image<I>& input) + { + morpher::count_rw_<I> tmp(input.exact()); + return tmp; + } + + template <typename I> + morpher::count_rw_<I> + count_rw(const oln::abstract::mutable_image<I>& input) + { + // FIXME: Hack. + I& input_ = const_cast<I&>(input.exact()); + morpher::count_rw_<I> tmp(input_); + return tmp; + } + +} // end of namespace oln + +#endif // ! OLN_MORPHER_COUNT_RW_HH + + + + + + + + + + + + + + + + Index: oln/morpher/two_way_rw.hxx =================================================================== - --- oln/morpher/two_way_rw.hxx (revision 0) +++ oln/morpher/two_way_rw.hxx (revision 0) @@ -0,0 +1,79 @@ +// 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_MORPHER_TWO_WAY_RW_HXX +# define OLN_MORPHER_TWO_WAY_RW_HXX + +namespace oln +{ + + namespace morpher + { + // public + + template <typename Image, typename Fun> + two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image) : + super_t(image.exact()), + fun_() + { + } + + template <typename Image, typename Fun> + two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image, + const oln::abstract::fun_rw<Fun>& fun) : + super_t(image.exact()), + fun_(fun.exact()) + { + } + + template <typename Image, typename Fun> + typename two_way_rw<Image, Fun>::rvalue_t + two_way_rw<Image, Fun>::impl_op_read(const typename two_way_rw<Image, Fun>::psite_t& p) const + { + return fun_.read(this->delegate(), p); + } + + template <typename Image, typename Fun> + typename two_way_rw<Image, Fun>::lvalue_t + two_way_rw<Image, Fun>::impl_op_readwrite(const typename two_way_rw<Image, Fun>::psite_t& p) + { + typename two_way_rw<Image, Fun>::lvalue_t tmp(this->delegate(), p); + return tmp; + } + + } // end of namespace oln::morpher + +} // end of namespace oln + +#endif // ! OLN_MORPHER_TWO_WAY_RW_HXX + + + + + + + Index: oln/morpher/stack_rw.hh =================================================================== - --- oln/morpher/stack_rw.hh (revision 719) +++ oln/morpher/stack_rw.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -120,52 +120,6 @@ xtd::vec<n, I> images_; }; - - - -# ifndef OLN_INCLUDE_ONLY - - - - template <unsigned n, typename I> - - stack_rw<n, I>::stack_rw(const xtd::vec<n, I>& images) : - - super_t(images[0]), - - images_(images) - - { - - } - - - - template <unsigned n, typename I> - - xtd::vec<n, oln_value(I)> - - stack_rw<n, I>::impl_op_read(const typename stack_rw<n, I>::psite_t& p) const - - { - - xtd::vec<n, oln_value(I)> tmp; - - for (unsigned i = 0; i < n; ++i) - - tmp[i] = images_[i](p); - - return tmp; - - } - - - - template <unsigned n, typename I> - - typename stack_rw<n, I>::lvalue_t - - stack_rw<n, I>::impl_op_readwrite(const typename stack_rw<n, I>::psite_t& p) - - { - - lvalue_t tmp(*this, p); - - return tmp; - - } - - - - template <unsigned n, typename I> - - const I& - - stack_rw<n, I>::image(unsigned i) const - - { - - precondition(i < n); - - return images_[i]; - - } - - - - template <unsigned n, typename I> - - I& - - stack_rw<n, I>::image(unsigned i) - - { - - precondition(i < n); - - return images_[i]; - - } - - - -# endif - - } // end of namespace oln::morpher @@ -187,52 +141,18 @@ abstract::mutable_image<I>& image_2, abstract::mutable_image<I>& image_3); +} // end of namespace oln # ifndef OLN_INCLUDE_ONLY +# include "stack_rw.hxx" +# endif +# include <oln/value/two_way.hxx> - - template <typename I> - - morpher::stack_rw<2, I> - - stack_rw(abstract::mutable_image<I>& image_0, - - abstract::mutable_image<I>& image_1) - - { - - morpher::stack_rw<2, I> tmp(xtd::mk_vec(image_0.exact(), - - image_1.exact())); - - return tmp; - - } - - - - template <typename I> - - morpher::stack_rw<3, I> - - stack_rw(abstract::mutable_image<I>& image_0, - - abstract::mutable_image<I>& image_1, - - abstract::mutable_image<I>& image_2) - - { - - morpher::stack_rw<3, I> tmp(xtd::mk_vec(image_0.exact(), - - image_1.exact(), - - image_2.exact())); - - return tmp; - - } - - - - template <typename I> - - morpher::stack_rw<4, I> - - stack_rw(abstract::mutable_image<I>& image_0, - - abstract::mutable_image<I>& image_1, - - abstract::mutable_image<I>& image_2, - - abstract::mutable_image<I>& image_3) - - { - - morpher::stack_rw<4, I> tmp(xtd::mk_vec(image_0.exact(), - - image_1.exact(), - - image_2.exact(), - - image_3.exact())); - - return tmp; - - } - -# endif +#endif // ! OLN_MORPHER_STACK_RW_HH - -} // end of namespace oln - -# include <oln/value/two_way.hxx> - -#endif // ! OLN_MORPHER_STACK_RW_HH Index: oln/morpher/stack.hxx =================================================================== - --- oln/morpher/stack.hxx (revision 0) +++ oln/morpher/stack.hxx (revision 0) @@ -0,0 +1,121 @@ +// 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_MORPHER_STACK_HXX +# define OLN_MORPHER_STACK_HXX + +namespace oln +{ + + namespace morpher + { + + template <unsigned n, typename I> + stack<n, I>::stack(const xtd::vec<n, I>& images) : + super_t(images[0]), + images_(images) + { + } + + template <unsigned n, typename I> + xtd::vec<n, oln_value(I)> + stack<n, I>::impl_op_read(const typename stack<n, I>::psite_t& p) const + { + xtd::vec<n, oln_value(I)> tmp; + for (unsigned i = 0; i < n; ++i) + tmp[i] = images_[i](p); + return tmp; + } + + template <unsigned n, typename I> + const I& + stack<n, I>::image(unsigned i) const + { + precondition(i < n); + return images_[i]; + } + + } // end of namespace oln::morpher + + + template <typename I> + morpher::stack<2, I> + stack(const abstract::image<I>& image_0, + const abstract::image<I>& image_1) + { + morpher::stack<2, I> tmp(xtd::mk_vec(image_0.exact(), + image_1.exact())); + return tmp; + } + + template <typename I> + morpher::stack<3, I> + stack(const abstract::image<I>& image_0, + const abstract::image<I>& image_1, + const abstract::image<I>& image_2) + { + morpher::stack<3, I> tmp(xtd::mk_vec(image_0.exact(), + image_1.exact(), + image_2.exact())); + return tmp; + } + + template <typename I> + morpher::stack<4, I> + stack(const abstract::image<I>& image_0, + const abstract::image<I>& image_1, + const abstract::image<I>& image_2, + const abstract::image<I>& image_3) + { + morpher::stack<4, I> tmp(xtd::mk_vec(image_0.exact(), + image_1.exact(), + image_2.exact(), + image_3.exact())); + return tmp; + } + + +} // end of namespace oln + +#endif // ! OLN_MORPHER_STACK_HXX + + + + + + + + + + + + + + + + + Index: oln/morpher/add_neighborhood.hh =================================================================== - --- oln/morpher/add_neighborhood.hh (revision 719) +++ oln/morpher/add_neighborhood.hh (working copy) @@ -1,4 +1,4 @@ - -// Copyright (C) 2006 EPITA Research and Development Laboratory +// Copyright (C) 2006, 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 @@ -95,27 +95,6 @@ topo_t topo_; }; - - - -# ifndef OLN_INCLUDE_ONLY - - - - template <typename Image, typename Neighb> - - add_neighborhood<Image, Neighb>::add_neighborhood(const Image& image, const Neighb& nbh) : - - super_t(image), - - topo_(image.topo(), nbh) - - { - - mlc::assert_equal_<oln_vtype(Image, grid), oln_vtype(Neighb, grid)>::check(); - - // FIXME: check that Image is without a nbh - - } - - - - template <typename Image, typename Neighb> - - const typename add_neighborhood<Image, Neighb>::topo_t& - - add_neighborhood<Image, Neighb>::impl_topo() const - - { - - return topo_; - - } - - - -# endif - - } // end of namespace oln::morpher @@ -124,23 +103,10 @@ morpher::add_neighborhood<I, N> operator + (const abstract::image<I>& image, const abstract::neighborhood<N>& nbh); +} // end of namespace oln # ifndef OLN_INCLUDE_ONLY - - - - template <typename I, typename N> - - morpher::add_neighborhood<I, N> - - operator + (const abstract::image<I>& image, - - const abstract::neighborhood<N>& nbh) - - { - - mlc::assert_equal_<oln_vtype(I, grid), oln_vtype(N, grid)>::check(); - - // FIXME: check that Image is without a nbh - - morpher::add_neighborhood<I, N> tmp(image.exact(), nbh.exact()); - - return tmp; - - } - - +# include "add_neighborhood.hxx" # endif - -} // end of namespace oln - - - - #endif // ! OLN_MORPHER_ADD_NEIGHBORHOOD_HH Index: oln/morpher/thru_mfun.hxx =================================================================== - --- oln/morpher/thru_mfun.hxx (revision 0) +++ oln/morpher/thru_mfun.hxx (revision 0) @@ -0,0 +1,64 @@ +// 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_MORPHER_THRU_MFUN_HXX +# define OLN_MORPHER_THRU_MFUN_HXX + +namespace oln +{ + + template <typename Image, typename Fun> + thru_mfun<Image, Fun>::thru_mfun(const Image& image, const Fun& fun) : + super_t(image), + fun_(fun) + { + } + + template <typename Image, typename Fun> + typename thru_mfun<Image, Fun>::rvalue_t + thru_mfun<Image, Fun>::impl_op_read(const typename thru_mfun<Image, Fun>::psite_t& p) const + { + return fun_(this->image_(p)); + } + + template <typename Image, typename Fun> + typename thru_mfun<Image, Fun>::lvalue_t + thru_mfun<Image, Fun>::impl_op_readwrite(const typename thru_mfun<Image, Fun>::psite_t& p) + { + return fun_(this->image_(p)); + } + +} // end of namespace oln + +#endif // ! OLN_MORPHER_THRU_MFUN_HXX + + + + + + + - -- -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFFsPgX8QvmnUS5oeMRAmnZAJ98z1U0wa1aaIrCpzYqTlE1R4qW1wCgjCrC 7+Mj9v9MonIXqSS1lLptrYA= =TXwv -----END PGP SIGNATURE-----
participants (1)
-
Thomas Moulard