Olena-patches
Threads by month
- ----- 2025 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- 9625 discussions
2006-10-25 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Update xtd bool op traits.
* xtd/builtin/traits.hh (bool): Fix partially.
* xtd/internal/opmacros.hh
(xtd_internal_decl_binary_logical_operator): New macro.
* xtd/math/logic.hh: Update.
Index: xtd/math/logic.hh
===================================================================
--- xtd/math/logic.hh (revision 676)
+++ xtd/math/logic.hh (working copy)
@@ -34,9 +34,9 @@
namespace xtd
{
- xtd_internal_decl_binary_operator( land, and );
- xtd_internal_decl_binary_operator( lor, or );
- xtd_internal_decl_binary_operator( lxor, xor );
+ xtd_internal_decl_binary_logical_operator( land, and );
+ xtd_internal_decl_binary_logical_operator( lor, or );
+ xtd_internal_decl_binary_logical_operator( lxor, xor );
xtd_internal_decl_unary_operator( lnot, not );
Index: xtd/builtin/traits.hh
===================================================================
--- xtd/builtin/traits.hh (revision 676)
+++ xtd/builtin/traits.hh (working copy)
@@ -76,7 +76,8 @@
: public mlc::where_< mlc::or_< mlc::eq_<L, bool>,
mlc::eq_<R, bool> > >
{
- typedef mlc::undefined ret;
+ // FIXME: check that both L and R are bool and that it is not an arithmetical trait
+ typedef bool ret;
};
// 2) If either operand is of type long double, the other shall be
Index: xtd/internal/opmacros.hh
===================================================================
--- xtd/internal/opmacros.hh (revision 676)
+++ xtd/internal/opmacros.hh (working copy)
@@ -199,4 +199,73 @@
+# define xtd_internal_decl_binary_logical_operator(OperatorName, OperatorSymbol) \
+ \
+ \
+ template <typename T1, typename T2> \
+ struct plain_##OperatorName##_; \
+ \
+ template <typename T1, typename T2> \
+ struct fun_traits_< plain_##OperatorName##_<T1, T2> > \
+ { \
+ typedef T1 arg1_type; \
+ typedef T2 arg2_type; \
+ typedef xtd_op_##OperatorName##_trait(T1, T2) res_type; \
+ }; \
+ \
+ \
+ template <typename T1, typename T2> \
+ struct plain_##OperatorName##_ \
+ \
+ : public abstract::plain_nary_fun_< 2, plain_##OperatorName##_<T1, T2> > \
+ { \
+ typedef plain_##OperatorName##_<T1, T2> self; \
+ xtd_res(self) impl_op(const T1& arg1, const T2& arg2) const \
+ { \
+ return arg1 OperatorSymbol arg2; \
+ } \
+ }; \
+ \
+ \
+ typedef m2fun_<plain_##OperatorName##_> OperatorName##_type; \
+ const OperatorName##_type OperatorName; \
+ \
+ \
+ template <typename L, typename R> \
+ struct case_ < op_##OperatorName, mlc::pair_<L, R>, \
+ 2 > : public mlc::where_< mlc::or_< mlc_is_a(L, xtd::abstract::fun_expr_), \
+ mlc_is_a(R, xtd::abstract::fun_expr_) > > \
+ { \
+ struct protected_ { \
+ typedef typename mlc::if_< mlc_is_a(L, xtd::abstract::fun_expr_), \
+ L, \
+ xtd::literal_expr_<L> >::ret Lexpr; \
+ \
+ typedef typename mlc::if_< mlc_is_a(R, xtd::abstract::fun_expr_), \
+ R, \
+ xtd::literal_expr_<R> >::ret Rexpr; \
+ \
+ typedef xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> ret; \
+ }; \
+ }; \
+ \
+ \
+ template <typename Lexpr, typename Rexpr> \
+ xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> \
+ operator OperatorSymbol (const xtd::abstract::fun_expr_<Lexpr>& lexpr, \
+ const xtd::abstract::fun_expr_<Rexpr>& rexpr) \
+ { \
+ xtd::m2expr_<xtd::OperatorName##_type, Lexpr, Rexpr> tmp(lexpr, rexpr); \
+ return tmp; \
+ } \
+ \
+ \
+ xtd_internal_decl_binop_w_lit(OperatorName, OperatorSymbol, bool); \
+ \
+ \
+ struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
+
+
+
+
#endif // ! XTD_INTERNAL_OPMACROS_HH
1
0
2006-10-24 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add point-wise values.
* tests/core/pw_value.cc: New.
* tests/core/Makefile.am: Update.
* oln/core/gen/pw_value.hh: New.
* oln/Makefile.am: Update.
Index: tests/core/pw_value.cc
===================================================================
--- tests/core/pw_value.cc (revision 0)
+++ tests/core/pw_value.cc (revision 0)
@@ -0,0 +1,50 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// Test pw_value.
+
+#include <cassert>
+
+#include <oln/basics2d.hh>
+#include <oln/core/gen/pw_value.hh>
+
+
+
+int main()
+{
+ using namespace oln;
+
+ point2d p(0,0);
+ image2d<int> ima1(3,3);
+ ima1(p) = 1;
+
+ image2d<float> ima2(3,3);
+ ima2(p) = 2.3;
+
+ double d = ((pw_value(ima1) + 4 * pw_value(ima2)) / .2)(p);
+ assert(d > 50.9999 and d < 51.0001);
+}
Index: tests/core/Makefile.am
===================================================================
--- tests/core/Makefile.am (revision 675)
+++ tests/core/Makefile.am (working copy)
@@ -27,6 +27,7 @@
image2d \
image3d \
npoints \
+ pw_value \
window2d \
\
at
@@ -40,6 +41,7 @@
image2d_SOURCES = image2d.cc
image3d_SOURCES = image3d.cc
npoints_SOURCES = npoints.cc
+pw_value_SOURCES = pw_value.cc
window2d_SOURCES = window2d.cc
# Methods.
Index: oln/core/gen/pw_value.hh
===================================================================
--- oln/core/gen/pw_value.hh (revision 0)
+++ oln/core/gen/pw_value.hh (revision 0)
@@ -0,0 +1,106 @@
+// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_PW_VALUE_HH
+# define OLN_CORE_GEN_PW_VALUE_HH
+
+# include <oln/core/abstract/image.hh>
+# include <xtd/abstract/meta_nary_fun.hh>
+# include <xtd/math.hh>
+
+
+
+namespace xtd
+{
+
+ // Fwd decl.
+ template <typename I>
+ class pw_value_type;
+
+
+ template <typename I, typename A>
+ struct res_< pw_value_type<I>, A >
+ {
+ typedef oln_rvalue(I) ret;
+ };
+
+
+ template <typename I>
+ class pw_value_type : public xtd::abstract::meta_nary_fun_< 1, pw_value_type<I> >
+ {
+ public:
+
+ pw_value_type(const I& ima);
+
+ template <typename P>
+ oln_rvalue(I) impl_calc(const P& p) const;
+
+ protected:
+
+ const I& ima_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I>
+ template <typename A>
+ oln_rvalue(I)
+ pw_value_type<I>::impl_calc(const A& a) const
+ {
+ mlc::assert_< mlc_is_a(A, oln::abstract::point) >::check();
+ return ima_(a);
+ }
+
+ template <typename I>
+ pw_value_type<I>::pw_value_type(const I& ima)
+ : ima_(ima)
+ {
+ }
+
+# endif
+
+
+} // end of namespace xtd
+
+
+namespace oln
+{
+
+ template <typename I>
+ xtd::m1expr_< xtd::pw_value_type<I>, xtd::arg_<1> >
+ pw_value(const abstract::image<I>& ima)
+ {
+ xtd::pw_value_type<I> pwv(ima.exact());
+ using xtd::_1;
+ return pwv(_1); // expects one argument (for instance a point) or an expression :)
+ }
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_PW_VALUE_HH
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 675)
+++ oln/Makefile.am (working copy)
@@ -123,6 +123,7 @@
core/gen/grid.hh \
core/gen/mapimage.hh \
core/gen/neighb.hh \
+ core/gen/pw_value.hh \
core/gen/topo_add_nbh.hh \
core/gen/topo_bbox.hh \
core/gen/topo_lbbox.hh \
1
0
2006-10-24 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add a morpher to count read-write ops.
* tests/morphers/count_rw_morpher.cc: New.
* tests/morphers/Makefile.am: Update.
* oln/morpher/count_rw.hh: New.
* oln/value/proxy.hh: New.
* oln/value/rw_counter.hh: New.
* oln/Makefile.am: Update.
* oln/core/traits_id.hh (unop_vproxy, binop_vproxy): New.
(others): Update.
* oln/core/typedefs.hh
(oln_is_computed, oln_is_computed_): New.
* oln/morpher/internal/image_value_morpher.hh
(image_value_morpher): New overloading for ctor.
(image_): Add & to its type.
Index: tests/morphers/count_rw_morpher.cc
===================================================================
--- tests/morphers/count_rw_morpher.cc (revision 0)
+++ tests/morphers/count_rw_morpher.cc (revision 0)
@@ -0,0 +1,53 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// Test the count_rw morpher.
+
+#include <cassert>
+#include <oln/basics2d.hh>
+#include <oln/morpher/count_rw.hh>
+
+
+int main()
+{
+ using namespace oln;
+
+ typedef image2d<int> image_t;
+ image_t ima(3,3);
+ morpher::count_rw<image_t> ima2(ima);
+ point2d p(0,0);
+
+ ima2(p);
+ ima2(p) = 51;
+ int i = ima2(p);
+ i = 0; // suppress "unused i" warning
+
+ assert(value::counter::n_readwrite_calls(ima) == 3);
+ assert(value::counter::n_readonly_calls(ima) == 0);
+ assert(value::counter::n_reads(ima) == 1);
+ assert(value::counter::n_writes(ima) == 1);
+}
Index: tests/morphers/Makefile.am
===================================================================
--- tests/morphers/Makefile.am (revision 674)
+++ tests/morphers/Makefile.am (working copy)
@@ -21,6 +21,7 @@
check_PROGRAMS = \
identity_morpher \
add_neighborhood_morpher \
+ count_rw_morpher \
slice_morpher \
stack_morpher \
value_cast \
@@ -31,6 +32,7 @@
# Morphers.
identity_morpher_SOURCES = identity_morpher.cc
add_neighborhood_morpher_SOURCES = add_neighborhood_morpher.cc
+count_rw_morpher_SOURCES = count_rw_morpher.cc
slice_morpher_SOURCES = slice_morpher.cc
stack_morpher_SOURCES = stack_morpher.cc
value_cast_SOURCES = value_cast.cc
Index: oln/core/traits_id.hh
===================================================================
--- oln/core/traits_id.hh (revision 674)
+++ oln/core/traits_id.hh (working copy)
@@ -37,12 +37,22 @@
namespace id
{
+ /// \{
+ /// Generic identifiers for operators.
+ enum {
+ unop_vproxy = 1,
+ binop_vproxy = 1
+ };
+
+ /// \}
+
+
/// \{
/// Identifiers for oln binary operators +.
enum {
- op_plus_pointnd_dpointnd = 1
+ op_plus_pointnd_dpointnd = 2
};
/// \}
@@ -53,8 +63,8 @@
/// Identifiers for oln binary operators -.
enum {
- op_minus_pointnd_pointnd = 1,
- op_minus_pointnd_dpointnd = 2
+ op_minus_pointnd_pointnd = 2,
+ op_minus_pointnd_dpointnd = 3
};
/// \}
@@ -65,7 +75,7 @@
/// Identifiers for oln unary operators -.
enum {
- op_uminus_dpointnd = 1
+ op_uminus_dpointnd = 2
};
/// \}
Index: oln/core/typedefs.hh
===================================================================
--- oln/core/typedefs.hh (revision 674)
+++ oln/core/typedefs.hh (working copy)
@@ -227,6 +227,9 @@
# define oln_dpoint(T) oln_type_of(T, dpoint)
# define oln_dpoint_(T) oln_type_of_(T, dpoint)
+# define oln_is_computed(T) oln_type_of(T, is_computed)
+# define oln_is_computed_(T) oln_type_of_(T, is_computed)
+
# define oln_value(T) oln_type_of(T, value)
# define oln_value_(T) oln_type_of_(T, value)
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 674)
+++ oln/Makefile.am (working copy)
@@ -170,6 +170,7 @@
morpher/internal/image_value_morpher.hh \
\
morpher/add_neighborhood.hh \
+ morpher/count_rw.hh \
morpher/fwd_decls.hh \
morpher/identity.hh \
morpher/tags.hh \
@@ -186,6 +187,8 @@
value/all.hh \
value/default.hh \
value/greylevel.hh \
+ value/proxy.hh \
+ value/rw_counter.hh \
value/tags.hh \
\
basics1d.hh \
Index: oln/morpher/internal/image_value_morpher.hh
===================================================================
--- oln/morpher/internal/image_value_morpher.hh (revision 674)
+++ oln/morpher/internal/image_value_morpher.hh (working copy)
@@ -88,13 +88,15 @@
{
public:
- // FIXME: Handle the constness.
+ // FIXME: Hack here; constness should be properly handled.
image_value_morpher(const Image& image);
+ image_value_morpher(Image& image);
+
const Image& delegate() const;
Image& delegate();
protected:
- Image image_;
+ Image& image_;
};
@@ -103,6 +105,12 @@
template <typename Image, typename Exact>
image_value_morpher<Image, Exact>::image_value_morpher(const Image& image) :
+ image_(const_cast<Image&>(image))
+ {
+ }
+
+ template <typename Image, typename Exact>
+ image_value_morpher<Image, Exact>::image_value_morpher(Image& image) :
image_(image)
{
}
Index: oln/morpher/count_rw.hh
===================================================================
--- oln/morpher/count_rw.hh (revision 0)
+++ oln/morpher/count_rw.hh (revision 0)
@@ -0,0 +1,156 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHER_COUNT_RW_HH
+# define OLN_MORPHER_COUNT_RW_HH
+
+# include <oln/value/rw_counter.hh>
+# include <oln/morpher/internal/image_value_morpher.hh>
+
+
+namespace oln
+{
+
+
+ namespace morpher
+ {
+ // Forward declaration.
+ template <typename Image> struct count_rw;
+
+ } // end of namespace oln::morpher
+
+
+ /// Super type.
+ template <typename Image>
+ struct set_super_type< morpher::count_rw<Image> >
+ {
+ typedef morpher::count_rw<Image> self_t;
+ typedef morpher::internal::image_value_morpher<Image, self_t> ret;
+ };
+
+
+ template <typename Image>
+ struct vtypes< morpher::count_rw<Image> >
+ {
+ public:
+ typedef mlc::true_ is_computed_type;
+
+ typedef oln_value(Image) value_type;
+ typedef value::rw_counter<Image> lvalue_type;
+ };
+
+ template <typename Image>
+ struct single_vtype< morpher::count_rw<Image>, typedef_::rvalue_type >
+ {
+ typedef value::ro_counter<Image> ret;
+ };
+
+
+
+ namespace morpher
+ {
+
+ /// 'Image thru Function' morpher.
+ template <typename Image>
+ class count_rw : public internal::image_value_morpher< Image,
+ morpher::count_rw<Image> >
+ {
+ private:
+
+ typedef count_rw<Image> self_t;
+ typedef internal::image_value_morpher<Image, self_t> super_t;
+
+ using super_t::image_;
+
+ public:
+
+ count_rw(Image& image);
+ count_rw(oln::abstract::mutable_image<Image>& image);
+
+ oln_rvalue(self_t) impl_op_read(const oln_psite(self_t)& p) const;
+ oln_lvalue(self_t) impl_op_readwrite(const oln_psite(self_t)& p);
+ };
+
+
+ namespace ERROR
+ {
+
+ struct FIXME;
+
+ } // 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
+
+
+ template <typename I>
+ morpher::count_rw<I>
+ count_rw(oln::abstract::mutable_image<I>& input)
+ {
+ morpher::count_rw<I> tmp(input.exact());
+ return tmp;
+ }
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHER_COUNT_RW_HH
Index: oln/value/proxy.hh
===================================================================
--- oln/value/proxy.hh (revision 0)
+++ oln/value/proxy.hh (revision 0)
@@ -0,0 +1,472 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_VALUE_PROXY_HH
+# define OLN_CORE_VALUE_PROXY_HH
+
+# include <xtd/optraits.hh>
+# include <oln/core/type.hh>
+# include <oln/core/traits_id.hh>
+
+
+namespace oln
+{
+
+
+ namespace value
+ {
+
+ namespace abstract
+ {
+
+ template <typename E>
+ struct proxy : public virtual stc::any__simple<E>,
+ public oln::type
+ {
+ protected:
+ proxy();
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename E>
+ proxy<E>::proxy()
+ {
+ }
+
+# endif
+
+ } // end of namespace oln::value::abstract
+
+
+ } // end of namespace oln::value
+
+
+
+ // Traits.
+ //---------------------------
+
+
+ /// unary op on a value proxy
+ template <typename name, typename T>
+ struct case_ < xtd::op_<name>, T,
+ oln::id::unop_vproxy >
+ : where_< mlc_is_a(T, value::abstract::proxy) >
+ {
+ struct protected_ {
+ typedef typename T::value_type V;
+ typedef xtd_unop_trait(xtd::op_<name>, V) ret;
+ };
+ };
+
+
+ /// binary op involving at least one value proxy
+ template <typename name, typename T1, typename T2>
+ struct case_ < xtd::op_<name>, mlc::pair_<T1,T2>,
+ oln::id::binop_vproxy >
+ : where_< mlc::or_< mlc_is_a(T1, value::abstract::proxy),
+ mlc_is_a(T2, value::abstract::proxy) > >
+ {
+ template <typename T>
+ struct value_type
+ {
+ typedef mlc_typedef(T, value_type) V;
+ typedef typename mlc::if_< mlc_is_found(V), V, T >::ret ret;
+ };
+ struct protected_ {
+ typedef mlc_ret(value_type<T1>) V1;
+ typedef mlc_ret(value_type<T2>) V2;
+ typedef xtd_binop_trait(xtd::op_<name>, V1, V2) ret;
+ };
+ };
+
+
+
+ // Unary ops.
+ //---------------------------
+
+
+ // Op -.
+ template <typename P>
+ xtd_op_uminus_trait(P) operator - (const value::abstract::proxy<P>& val);
+ // Op not.
+ template <typename P>
+ xtd_op_lnot_trait(P) operator not (const value::abstract::proxy<P>& val);
+
+ // FIXME: To be continued.
+
+
+
+ // Binary ops.
+ //---------------------------
+
+ // Op +.
+ template <typename P, typename V>
+ xtd_op_plus_trait(P, V) operator + (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_plus_trait(V, P) operator + (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op -.
+ template <typename P, typename V>
+ xtd_op_minus_trait(P, V) operator - (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_minus_trait(V, P) operator - (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op *.
+ template <typename P, typename V>
+ xtd_op_mult_trait(P, V) operator * (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_mult_trait(V, P) operator * (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op /.
+ template <typename P, typename V>
+ xtd_op_div_trait(P, V) operator / (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_div_trait(V, P) operator / (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op %.
+ template <typename P, typename V>
+ xtd_op_mod_trait(P, V) operator % (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_mod_trait(V, P) operator % (const V& lhs, const value::abstract::proxy<P>& rhs);
+
+ // Op ==.
+ template <typename P, typename V>
+ xtd_op_eq_trait(P, V) operator == (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_eq_trait(V, P) operator == (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op !=.
+ template <typename P, typename V>
+ xtd_op_neq_trait(P, V) operator != (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_neq_trait(V, P) operator != (const V& lhs, const value::abstract::proxy<P>& rhs);
+
+ // Op <.
+ template <typename P, typename V>
+ xtd_op_less_trait(P, V) operator < (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_less_trait(V, P) operator < (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op <=.
+ template <typename P, typename V>
+ xtd_op_leq_trait(P, V) operator <= (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_leq_trait(V, P) operator <= (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op >=.
+ template <typename P, typename V>
+ xtd_op_geq_trait(P, V) operator >= (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_geq_trait(V, P) operator >= (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op >.
+ template <typename P, typename V>
+ xtd_op_greater_trait(P, V) operator > (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_greater_trait(V, P) operator > (const V& lhs, const value::abstract::proxy<P>& rhs);
+
+ // Op and.
+ template <typename P, typename V>
+ xtd_op_land_trait(P, V) operator and (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_land_trait(V, P) operator and (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op or.
+ template <typename P, typename V>
+ xtd_op_lor_trait(P, V) operator or (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_lor_trait(V, P) operator or (const V& lhs, const value::abstract::proxy<P>& rhs);
+ // Op xor.
+ template <typename P, typename V>
+ xtd_op_lxor_trait(P, V) operator xor (const value::abstract::proxy<P>& lhs, const V& rhs);
+ template <typename V, typename P>
+ xtd_op_lxor_trait(V, P) operator xor (const V& lhs, const value::abstract::proxy<P>& rhs);
+
+ // FIXME: To be continued.
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // Unary ops.
+ //---------------------------
+
+
+ // Op -.
+ template <typename P>
+ xtd_op_uminus_trait(P) operator - (const value::abstract::proxy<P>& val)
+ {
+ return - val.exact().value();
+ }
+
+ // Op not.
+
+ template <typename P>
+ xtd_op_lnot_trait(P)
+ operator not (const value::abstract::proxy<P>& val)
+ {
+ return not val.exact().value();
+ }
+
+
+ // FIXME: To be continued.
+
+
+
+ // Binary ops.
+ //---------------------------
+
+ // Op +.
+
+ template <typename P, typename V>
+ xtd_op_plus_trait(P, V)
+ operator + (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() + rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_plus_trait(V, P)
+ operator + (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs + rhs.exact().value();
+ }
+
+ // Op -.
+
+ template <typename P, typename V>
+ xtd_op_minus_trait(P, V)
+ operator - (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() - rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_minus_trait(V, P)
+ operator - (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs - rhs.exact().value();
+ }
+
+ // Op *.
+
+ template <typename P, typename V>
+ xtd_op_mult_trait(P, V)
+ operator * (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() * rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_mult_trait(V, P)
+ operator * (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs * rhs.exact().value();
+ }
+
+ // Op /.
+
+ template <typename P, typename V>
+ xtd_op_div_trait(P, V)
+ operator / (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() / rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_div_trait(V, P)
+ operator / (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs / rhs.exact().value();
+ }
+
+ // Op %.
+
+ template <typename P, typename V>
+ xtd_op_mod_trait(P, V)
+ operator % (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() % rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_mod_trait(V, P)
+ operator % (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs % rhs.exact().value();
+ }
+
+
+ // Op ==.
+
+ template <typename P, typename V>
+ xtd_op_eq_trait(P, V)
+ operator == (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() == rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_eq_trait(V, P)
+ operator == (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs == rhs.exact().value();
+ }
+
+
+ // Op !=.
+
+ template <typename P, typename V>
+ xtd_op_neq_trait(P, V)
+ operator != (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() != rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_neq_trait(V, P)
+ operator != (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs != rhs.exact().value();
+ }
+
+
+ // Op <.
+
+ template <typename P, typename V>
+ xtd_op_less_trait(P, V)
+ operator < (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() < rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_less_trait(V, P)
+ operator < (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs < rhs.exact().value();
+ }
+
+ // Op <=.
+
+ template <typename P, typename V>
+ xtd_op_leq_trait(P, V)
+ operator <= (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() <= rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_leq_trait(V, P)
+ operator <= (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs <= rhs.exact().value();
+ }
+
+ // Op >=.
+
+ template <typename P, typename V>
+ xtd_op_geq_trait(P, V)
+ operator >= (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() >= rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_geq_trait(V, P)
+ operator >= (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs >= rhs.exact().value();
+ }
+
+ // Op >.
+
+ template <typename P, typename V>
+ xtd_op_greater_trait(P, V)
+ operator > (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() > rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_greater_trait(V, P)
+ operator > (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs > rhs.exact().value();
+ }
+
+
+ // Op and.
+
+ template <typename P, typename V>
+ xtd_op_land_trait(P, V)
+ operator and (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() and rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_land_trait(V, P)
+ operator and (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs and rhs.exact().value();
+ }
+
+ // Op or.
+
+ template <typename P, typename V>
+ xtd_op_lor_trait(P, V)
+ operator or (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() or rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_lor_trait(V, P)
+ operator or (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs or rhs.exact().value();
+ }
+
+ // Op xor.
+
+ template <typename P, typename V>
+ xtd_op_lxor_trait(P, V)
+ operator xor (const value::abstract::proxy<P>& lhs, const V& rhs)
+ {
+ return lhs.exact().value() xor rhs;
+ }
+
+ template <typename V, typename P>
+ xtd_op_lxor_trait(V, P)
+ operator xor (const V& lhs, const value::abstract::proxy<P>& rhs)
+ {
+ return lhs xor rhs.exact().value();
+ }
+
+ // FIXME: To be continued.
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_VALUE_PROXY_HH
Index: oln/value/rw_counter.hh
===================================================================
--- oln/value/rw_counter.hh (revision 0)
+++ oln/value/rw_counter.hh (revision 0)
@@ -0,0 +1,241 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_VALUE_RW_COUNTER_HH
+# define OLN_CORE_VALUE_RW_COUNTER_HH
+
+# include <iostream>
+# include <map>
+# include <oln/value/proxy.hh>
+# include <oln/core/abstract/image/all.hh>
+
+
+namespace oln
+{
+
+
+ namespace value
+ {
+
+
+ struct counter
+ {
+ typedef std::map<void*, unsigned> map_t;
+
+ // read-write call
+ static unsigned& n_readwrite_calls(const oln::type& ima)
+ {
+ static map_t n;
+ return n[(void*)(&ima)];
+ }
+ // read-only call
+ static unsigned& n_readonly_calls(const oln::type& ima)
+ {
+ static map_t n;
+ return n[(void*)(&ima)];
+ }
+ // read (effective)
+ static unsigned& n_reads(const oln::type& ima)
+ {
+ static map_t n;
+ return n[(void*)(&ima)];
+ }
+ // write (effective)
+ static unsigned& n_writes(const oln::type& ima)
+ {
+ static map_t n;
+ return n[(void*)(&ima)];
+ }
+
+ static void print(const oln::type& ima)
+ {
+ std::cout << "n_readwrite_calls = " << n_readwrite_calls(ima) << std::endl
+ << "n_readonly_calls = " << n_readonly_calls(ima) << std::endl
+ << "n_reads = " << n_reads(ima) << std::endl
+ << "n_writes = " << n_writes(ima) << std::endl;
+ }
+ };
+
+
+ template <typename I>
+ class rw_counter : public abstract::proxy< rw_counter<I> >
+ {
+ public:
+
+ typedef oln_value(I) value_type;
+
+ // Ctor.
+ rw_counter(oln::abstract::mutable_image<I>& ima,
+ const oln_psite(I)& p);
+
+ // Read.
+ template <typename V>
+ operator V() const;
+
+ // Explicit read.
+ oln_rvalue(I) value() const;
+
+ // Write.
+ template <typename V>
+ rw_counter<I>& operator=(const V& value);
+
+ protected:
+ I& ima_;
+ const oln_psite(I)& p_;
+ };
+
+
+ template <typename I>
+ std::ostream& operator<<(std::ostream& ostr, const rw_counter<I>& proxy);
+
+
+ template <typename I>
+ class ro_counter : public abstract::proxy< ro_counter<I> >
+ {
+ public:
+
+ typedef oln_value(I) value_type;
+
+ // Ctor.
+ ro_counter(const oln::abstract::image<I>& ima,
+ const oln_psite(I)& p);
+
+ // Read.
+ template <typename V>
+ operator V() const;
+
+ // Explicit read.
+ oln_rvalue(I) value() const;
+
+ protected:
+ const I& ima_;
+ const oln_psite(I)& p_;
+ };
+
+
+ template <typename I>
+ std::ostream& operator<<(std::ostream& ostr, const ro_counter<I>& proxy);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ // Ctor.
+ template <typename I>
+ rw_counter<I>::rw_counter(oln::abstract::mutable_image<I>& ima,
+ const oln_psite(I)& p)
+ : ima_(ima.exact()),
+ p_(p)
+ {
+ ++counter::n_readwrite_calls(ima_);
+ }
+
+ // Read.
+ template <typename I>
+ template <typename V>
+ rw_counter<I>::operator V() const
+ {
+ ++counter::n_reads(ima_);
+ V tmp = ima_(p_);
+ return tmp;
+ }
+
+ // Explicit read.
+ template <typename I>
+ oln_rvalue(I)
+ rw_counter<I>::value() const
+ {
+ ++counter::n_reads(ima_);
+ return ima_(p_);
+ }
+
+ // Write.
+
+ template <typename I>
+ template <typename V>
+ rw_counter<I>&
+ rw_counter<I>::operator=(const V& value)
+ {
+ ima_(p_) = value;
+ ++counter::n_writes(ima_);
+ return *this;
+ }
+
+ // Op <<.
+ template <typename I>
+ std::ostream& operator<<(std::ostream& ostr,
+ const rw_counter<I>& proxy)
+ {
+ return ostr << proxy.value();
+ }
+
+
+ // Ctor.
+ template <typename I>
+ ro_counter<I>::ro_counter(const oln::abstract::image<I>& ima,
+ const oln_psite(I)& p)
+ : ima_(ima.exact()),
+ p_(p)
+ {
+ ++counter::n_readonly_calls(ima_);
+ }
+
+ // Read.
+ template <typename I>
+ template <typename V>
+ ro_counter<I>::operator V() const
+ {
+ ++counter::n_reads(ima_);
+ V tmp = ima_(p_);
+ return tmp;
+ }
+
+ // Explicit read.
+ template <typename I>
+ oln_rvalue(I)
+ ro_counter<I>::value() const
+ {
+ ++counter::n_reads(ima_);
+ return ima_(p_);
+ }
+
+ // Op <<.
+ template <typename I>
+ std::ostream& operator<<(std::ostream& ostr,
+ const ro_counter<I>& proxy)
+ {
+ return ostr << proxy.value();
+ }
+
+# endif
+
+ } // end of namespace oln::value
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_VALUE_RW_COUNTER_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add a morpher adding a look-up table to an image.
* oln/core/lookup_table.hh: New.
* oln/morpher/with_lut.hh: New morpher.
* oln/Makefile.am (nobase_oln_HEADERS): Add core/lookup_table.hh
and morpher/with_lut.hh.
* tests/morphers/with_lut.cc: New test.
* tests/morphers/Makefile.am (check_PROGRAMS): Add with_lut.
(with_lut_SOURCES): New.
oln/Makefile.am | 2
oln/core/lookup_table.hh | 125 +++++++++++++++++++++++++++++++
oln/morpher/with_lut.hh | 177 +++++++++++++++++++++++++++++++++++++++++++++
tests/morphers/Makefile.am | 2
tests/morphers/with_lut.cc | 96 ++++++++++++++++++++++++
5 files changed, 402 insertions(+)
Index: tests/morphers/with_lut.cc
--- tests/morphers/with_lut.cc (revision 0)
+++ tests/morphers/with_lut.cc (revision 0)
@@ -0,0 +1,96 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// Test the look-up table morpher.
+
+#include <oln/basics2d.hh>
+#include <oln/morpher/with_lut.hh>
+#include <oln/value/color/rgb.hh>
+#include <oln/level/fill.hh>
+#include <oln/debug/print.hh>
+
+
+// FIXME: Remove.
+using namespace oln;
+
+template <typename I>
+void image_test(const oln::abstract::image<I>&)
+{
+ // Do nothing.
+}
+
+oln::value::color::rgb8 white(255, 255, 255);
+oln::value::color::rgb8 blue ( 0, 0, 255);
+
+int main()
+{
+ using oln::value::color::rgb8;
+
+ unsigned data[] = { 0, 1, 2, 0, 1, 2, 0, 1, 2};
+
+ typedef image2d<unsigned> image_t;
+ image_t ima(3, 3);
+ level::fill(ima, data);
+ debug::print(ima);
+
+ typedef lookup_table<unsigned, rgb8> lut_t;
+ lut_t lut;
+ rgb8 c(16, 6, 4);
+ lut.
+ add(0, blue).
+ add(1, white).
+ add(2, c);
+ std::cout << lut << std::endl;
+
+ typedef morpher::with_lut<image_t, lut_t> lutimage_t;
+ lutimage_t ima2 = ima + lut;
+
+ // ima2 is an image, and can be as argument to to image routines.
+ image_test(ima2);
+
+ // FIXME: To be enabled later.
+#if 0
+ // it is value-wise accessible:
+ ima2.value(c) = red;
+#endif
+
+ // let's look at it
+ debug::print(ima2);
+ std::cout << std::endl;
+
+ // it is a 2D image so we have:
+ point2d p(1, 1);
+ std::cout << "ima2(p) =" << ima2(p) << std::endl;
+ // or (likewise):
+ std::cout << "ima2.at(1, 1) =" << ima2.at(1, 1) << std::endl;
+
+ // FIXME: To be enabled later.
+#if 0
+ // FIXME...
+ level::apply(ima2, fun); // 3 ops only !!!
+#endif
+}
Index: tests/morphers/Makefile.am
--- tests/morphers/Makefile.am (revision 673)
+++ tests/morphers/Makefile.am (working copy)
@@ -24,6 +24,7 @@
slice_morpher \
stack_morpher \
value_cast \
+ with_lut \
\
morphers
@@ -33,6 +34,7 @@
slice_morpher_SOURCES = slice_morpher.cc
stack_morpher_SOURCES = stack_morpher.cc
value_cast_SOURCES = value_cast.cc
+with_lut_SOURCES = with_lut.cc
morphers_SOURCES = morphers.cc
Index: oln/core/lookup_table.hh
--- oln/core/lookup_table.hh (revision 0)
+++ oln/core/lookup_table.hh (revision 0)
@@ -0,0 +1,125 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_LOOKUP_TABLE_HH
+# define OLN_CORE_LOOKUP_TABLE_HH
+
+# include <map>
+# include <ostream>
+
+namespace oln
+{
+
+ template <typename Key, typename Data>
+ class lookup_table
+ {
+ typedef lookup_table<Key, Data> self_t;
+
+ public:
+ typedef Key key_type;
+ typedef Data data_type;
+ typedef std::map<Key, Data> map_type;
+
+ public:
+ lookup_table();
+
+ self_t& add (const key_type& k, const data_type& d);
+
+ const data_type operator () (const key_type& key) const;
+
+ const map_type& map() const;
+
+ private:
+ std::map<Key, Data> map_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Key, typename Data>
+ lookup_table<Key, Data>::lookup_table() :
+ map_()
+ {
+ }
+
+ template <typename Key, typename Data>
+ lookup_table<Key, Data>&
+ lookup_table<Key, Data>::add (const Key& k, const Data& d)
+ {
+ map_.insert(std::make_pair(k, d));
+ return *this;
+ }
+
+ template <typename Key, typename Data>
+ const Data
+ lookup_table<Key, Data>::operator () (const Key& key) const
+ {
+ typedef typename lookup_table<Key, Data>::map_type map_t;
+ typename map_t::const_iterator i = map_.find(key);
+ // FIXME: Is this the expected behavior when the LUT has no data
+ // for \a key.
+ assert(i != map_.end());
+ return i->second;
+ }
+
+ template <typename Key, typename Data>
+ const typename lookup_table<Key, Data>::map_type&
+ lookup_table<Key, Data>::map() const
+ {
+ return map_;
+ }
+
+# endif
+
+
+ /// Print a look-up table.
+ template <typename Key, typename Data>
+ std::ostream&
+ operator<< (std::ostream& ostr, const lookup_table<Key, Data>& lut);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Key, typename Data>
+ std::ostream&
+ operator<< (std::ostream& ostr, const lookup_table<Key, Data>& lut)
+ {
+ typedef lookup_table<Key, Data> lut_t;
+ const typename lut_t::map_type& map = lut.map();
+ for (typename lut_t::map_type::const_iterator i = map.begin ();
+ i != map.end(); ++i)
+ ostr << " " << i->first << " -> " << i->second << std::endl;
+ return ostr;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+
+#endif // ! OLN_CORE_LOOKUP_TABLE_HH
Index: oln/Makefile.am
--- oln/Makefile.am (revision 673)
+++ oln/Makefile.am (working copy)
@@ -148,6 +148,7 @@
core/fwd_decls.hh \
core/image_entry.hh \
core/iterator_vtypes.hh \
+ core/lookup_table.hh \
core/macros.hh \
core/neighborhood_entry.hh \
core/point_set_entry.hh \
@@ -177,6 +178,7 @@
morpher/thru_fun.hh \
morpher/thru_mfun.hh \
morpher/value_cast.hh \
+ morpher/with_lut.hh \
\
value/color/rgb.hh \
\
Index: oln/morpher/with_lut.hh
--- oln/morpher/with_lut.hh (revision 0)
+++ oln/morpher/with_lut.hh (revision 0)
@@ -0,0 +1,177 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHER_WITH_LUT_HH
+# define OLN_MORPHER_WITH_LUT_HH
+
+# include <oln/morpher/internal/image_value_morpher.hh>
+# include <oln/core/lookup_table.hh>
+
+
+namespace oln
+{
+
+ namespace morpher
+ {
+ // Forward declaration.
+ template <typename Image, typename Lut> struct with_lut;
+
+ } // end of namespace oln::morpher
+
+
+ /// Super type.
+ template <typename Image, typename Lut>
+ struct set_super_type< morpher::with_lut<Image, Lut> >
+ {
+ typedef morpher::with_lut<Image, Lut> self_t;
+ typedef morpher::internal::image_value_morpher<Image, self_t> ret;
+ };
+
+ /// Virtual types associated to oln::morpher::with_lut<Image, Lut>.
+ /// \{
+ template <typename Image, typename Lut>
+ struct vtypes< morpher::with_lut<Image, Lut> >
+ {
+ private:
+ typedef oln_type_of(Image, rvalue) orig_value_type;
+ public:
+ typedef mlc::true_ is_computed_type;
+ // Value type.
+ typedef typename Lut::data_type value_type;
+ // Look-up table type.
+ typedef Lut lut_type;
+ };
+
+ // Rvalue.
+ template <typename Image, typename Lut>
+ struct single_vtype< morpher::with_lut<Image, Lut>, typedef_::rvalue_type >
+ {
+ typedef morpher::with_lut<Image, Lut> self_t;
+ typedef oln_value(self_t) ret;
+ };
+
+ // FIXME: What about lvalue type?
+
+// // Lvalue.
+// template <typename Image>
+// struct single_vtype< morpher::slice<Image>, typedef_::lvalue_type >
+// {
+// typedef oln_type_of(Image, lvalue) ret;
+// };
+ /// \}
+
+
+ namespace morpher
+ {
+ /// Look-up table addition morpher.
+ template <typename Image, typename Lut>
+ class with_lut : public stc_get_supers(mlc_comma_1(with_lut<Image, Lut>))
+ // FIXME: Ensure oln_value(Image) == Lut::data_type? Or just let
+ // the ctor check this property?
+ {
+ private:
+ typedef with_lut<Image, Lut> self_t;
+ typedef stc_get_super(self_t) super_t;
+ typedef Lut lut_t;
+ typedef oln_type_of(self_t, value) value_t;
+ typedef oln_type_of(self_t, rvalue) rvalue_t;
+ typedef oln_type_of(self_t, psite) psite_t;
+ // FIXME: Useful typedef?
+// typedef oln_type_of(Image, value) orig_value_t;
+
+ public:
+ with_lut(const Image& image, const Lut& lut);
+ const lut_t& lut() const;
+
+ rvalue_t impl_op_read(const psite_t& p) const;
+
+ // FIXME: Implement impl_op_write() when there is value proxy?
+
+ protected:
+ lut_t 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::key_type >::check();
+ }
+
+ template <typename Image, typename Lut>
+ typename with_lut<Image, Lut>::rvalue_t
+ with_lut<Image, Lut>::
+ impl_op_read(const typename with_lut<Image, Lut>::psite_t& 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>
+ const typename with_lut<Image, Lut>::lut_t&
+ with_lut<Image, Lut>::lut() const
+ {
+ return lut_;
+ }
+
+# endif
+
+ } // 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,
+ const lookup_table<K, D>& lut);
+
+
+# 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,
+ const lookup_table<K, D>& lut)
+ {
+ typedef lookup_table<K, D> lut_t;
+ mlc::assert_equal_< oln_value(I), typename lut_t::key_type >::check();
+ morpher::with_lut<I, lut_t> tmp(image.exact(), lut);
+ return tmp;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHER_WITH_LUT_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Partial clean up of oln::morpher::add_neighborhood.
* oln/morpher/add_neighborhood.hh: Fix header guards.
(oln::morpher::add_neighborhood): Use the macro stc_get_supers to
set the super class.
(oln::morpher::add_neighborhood::super_t): Use the macro
stc_get_super to define it.
add_neighborhood.hh | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
Index: oln/morpher/add_neighborhood.hh
--- oln/morpher/add_neighborhood.hh (revision 672)
+++ oln/morpher/add_neighborhood.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_MORPHER_ADD_NEIGHBORHOOD
-# define OLN_MORPHER_ADD_NEIGHBORHOOD
+#ifndef OLN_MORPHER_ADD_NEIGHBORHOOD_HH
+# define OLN_MORPHER_ADD_NEIGHBORHOOD_HH
# include <oln/morpher/internal/image_extension.hh>
# include <oln/core/gen/topo_add_nbh.hh>
@@ -69,14 +69,13 @@
{
/// Neighborhood addition morpher.
template <typename Image, typename Neighb>
- class add_neighborhood : public morpher::internal::image_extension< Image,
- add_neighborhood<Image, Neighb> >
- // FIXME: Uncomment. stc_get_supers(mlc_comma_1(add_neighborhood<Image, Neighb>))
+ class add_neighborhood :
+ public stc_get_supers(mlc_comma_1(add_neighborhood<Image, Neighb>))
{
private:
typedef add_neighborhood<Image, Neighb> self_t;
- typedef stc_get_nth_super(self_t, 1) super_t;
+ typedef stc_get_super(self_t) super_t;
typedef oln_type_of(self_t, topo) topo_t;
public:
@@ -144,4 +143,4 @@
} // end of namespace oln
-#endif // ! OLN_MORPHER_ADD_NEIGHBORHOOD
+#endif // ! OLN_MORPHER_ADD_NEIGHBORHOOD_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Move oln::color to oln::value::color.
* oln/color/rgb.hh: Move...
* oln/value/color/rgb.hh: ...here.
(oln::color): Move the contents of this namespace...
(oln::value::color): ...into this one.
* oln/value/all.hh: Adjust.
* oln/Makefile.am (nobase_oln_HEADERS):
s|color/rgb.hh|value/color/rgb.hh|.
Makefile.am | 4 ++--
value/all.hh | 2 +-
value/color/rgb.hh | 14 ++++++++++----
3 files changed, 13 insertions(+), 7 deletions(-)
Index: oln/value/all.hh
--- oln/value/all.hh (revision 671)
+++ oln/value/all.hh (working copy)
@@ -35,7 +35,7 @@
# include <oln/value/bin.hh>
# include <oln/value/default.hh>
-# include <oln/color/rgb.hh>
+# include <oln/value/color/rgb.hh>
#endif // ! OLN_VALUE_ALL_HH
Index: oln/value/color/rgb.hh
--- oln/value/color/rgb.hh (revision 671)
+++ oln/value/color/rgb.hh (working copy)
@@ -25,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_COLOR_RGB_HH
-# define OLN_CORE_COLOR_RGB_HH
+#ifndef OLN_CORE_VALUE_COLOR_RGB_HH
+# define OLN_CORE_VALUE_COLOR_RGB_HH
# include <xtd/vec.hh>
# include <oln/core/abstract/value.hh>
@@ -35,6 +35,10 @@
namespace oln
{
+ namespace value
+ {
+
+ // FIXME: Perhaps this additional namespace is not necessary.
namespace color
{
@@ -177,9 +181,11 @@
# endif
- } // end of namespace oln::color
+ } // end of namespace oln::value::color
+
+ } // end of namespace oln::value
} // end of namespace oln
-#endif // ! OLN_CORE_COLOR_RGB_HH
+#endif // ! OLN_CORE_VALUE_COLOR_RGB_HH
Index: oln/Makefile.am
--- oln/Makefile.am (revision 671)
+++ oln/Makefile.am (working copy)
@@ -3,8 +3,6 @@
olndir = $(includedir)/oln
nobase_oln_HEADERS = \
\
- color/rgb.hh \
- \
core/1d/aliases.hh \
core/1d/array1d.hh \
core/1d/dpoint1d.hh \
@@ -180,6 +178,8 @@
morpher/thru_mfun.hh \
morpher/value_cast.hh \
\
+ value/color/rgb.hh \
+ \
value/accessor.hh \
value/all.hh \
value/default.hh \
1
0
671: Fix debug track and disambiguate the 'at' method overloading in const and mutable nD images.
by Thierry GERAUD 23 Oct '06
by Thierry GERAUD 23 Oct '06
23 Oct '06
2006-10-23 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Fix debug track and disambiguate the 'at' method overloading
in const and mutable nD images.
* oln/core/abstract/array.hh: New.
* oln/debug/track.hh (n_arrays): New.
(include): Fix.
* oln/core/abstract/image.hh (image): New cpy ctor so fix
n_images tracking.
* oln/core/abstract/image/dimension/1d.hh: Disambiguate by
changing inheritance to virtual + inserting a using directive.
* oln/core/abstract/image/dimension/2d.hh: Likewise.
* oln/core/abstract/image/dimension/3d.hh: Likewise.
* oln/core/1d/array1d.hh (array1d): Add inheritance.
* oln/core/2d/array2d.hh: Likewise.
* oln/core/3d/array3d.hh: Likewise.
* oln/Makefile.am: Update.
1
0
670: Add stack morpher and remove the hack related to indexed mutable access.
by Thierry GERAUD 23 Oct '06
by Thierry GERAUD 23 Oct '06
23 Oct '06
2006-10-23 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add stack morpher and remove the hack related to indexed mutable
access.
* tests/morphers/stack_morpher.cc: New.
* tests/morphers/Makefile.am: Update.
* oln/debug/track.hh: New.
* oln/core/automatic/image/mutable_image2d.hh: New.
* oln/core/automatic/image/mutable_image3d.hh: New.
* oln/core/automatic/image/mutable_image1d.hh: New.
* oln/morpher/stack.hh: New.
* oln/Makefile.am: Update.
* oln/debug/print.hh (println): Remove; too dummy.
(operator): New.
* oln/level/fill.hh (fill): New specialization for C arrays.
* oln/core/automatic/image/image1d.hh: Remove hack of 'at'.
* oln/core/automatic/image/image2d.hh: Likewise.
* oln/core/automatic/image/image3d.hh: Likewise.
* oln/core/abstract/image.hh (image, ~image): Add counting.
(include): Update.
* oln/core/abstract/image/dimension/1d.hh
(image1d): Split partially into...
(mutable_image1d): ...this new class.
(include): Update.
* oln/core/abstract/image/dimension/2d.hh: Likewise.
* oln/core/abstract/image/dimension/3d.hh: Likewise.
* oln/core/abstract/image/dimension/hierarchy.hh
(case_): Update.
* oln/core/2d/array2d.hh (memsize): Better sig.
(include): Update.
* oln/core/2d/image2d.hh (image2d): New overloading for no arg.
Index: tests/morphers/stack_morpher.cc
===================================================================
--- tests/morphers/stack_morpher.cc (revision 0)
+++ tests/morphers/stack_morpher.cc (revision 0)
@@ -0,0 +1,48 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/// Test the stack morpher.
+
+#include <cassert>
+#include <oln/basics2d.hh>
+#include <oln/morpher/stack.hh>
+
+
+int main()
+{
+ using namespace oln;
+ typedef image2d<int> image_t;
+
+ image_t ima(3,3);
+ morpher::stack<2,image_t> ima_v = stack(ima, ima);
+
+ point2d p(2, 2);
+ ima(p) = 51;
+
+ assert(ima(p) == ima_v.image(1)(p));
+ assert(ima_v.at(2, 2) == ima_v(p));
+}
Index: tests/morphers/Makefile.am
===================================================================
--- tests/morphers/Makefile.am (revision 669)
+++ tests/morphers/Makefile.am (working copy)
@@ -22,6 +22,7 @@
identity_morpher \
add_neighborhood_morpher \
slice_morpher \
+ stack_morpher \
value_cast \
\
morphers
@@ -30,6 +31,7 @@
identity_morpher_SOURCES = identity_morpher.cc
add_neighborhood_morpher_SOURCES = add_neighborhood_morpher.cc
slice_morpher_SOURCES = slice_morpher.cc
+stack_morpher_SOURCES = stack_morpher.cc
value_cast_SOURCES = value_cast.cc
morphers_SOURCES = morphers.cc
Index: oln/debug/track.hh
===================================================================
--- oln/debug/track.hh (revision 0)
+++ oln/debug/track.hh (revision 0)
@@ -0,0 +1,47 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_DEBUG_TRACK_HH
+# define OLN_DEBUG_TRACK_HH
+
+# include <oln/core/abstract/image.hh>
+
+
+namespace oln
+{
+
+ namespace debug
+ {
+
+ static unsigned n_images = 0;
+
+ } // end of namespace oln::debug
+
+} // end of namespace oln
+
+
+#endif // ! OLN_DEBUG_TRACK_HH
Index: oln/debug/print.hh
===================================================================
--- oln/debug/print.hh (revision 669)
+++ oln/debug/print.hh (working copy)
@@ -48,11 +48,7 @@
template <typename I>
void print(const abstract::image<I>& input, std::ostream& ostr = std::cout);
- /// Fwd decl.
- template <typename I>
- void println(const abstract::image<I>& input, std::ostream& ostr = std::cout);
-
# ifndef OLN_INCLUDE_ONLY
namespace impl
@@ -111,15 +107,6 @@
impl::print(input.exact(), ostr);
}
-
- /// Facade.
- template <typename I>
- void println(const abstract::image<I>& input, std::ostream& ostr)
- {
- print(input, ostr);
- ostr << std::endl;
- }
-
# endif // ! OLN_INCLUDE_ONLY
} // end of namespace oln::debug
Index: oln/level/fill.hh
===================================================================
--- oln/level/fill.hh (revision 669)
+++ oln/level/fill.hh (working copy)
@@ -29,6 +29,8 @@
#ifndef OLN_LEVEL_FILL_HH
# define OLN_LEVEL_FILL_HH
+# include <iostream>
+
# include <mlc/assert.hh>
# include <mlc/is_a.hh>
@@ -45,14 +47,28 @@
struct FIRST_ARGUMENT_OF_oln_level_fill_IS_NOT_MUTABLE;
}
+
+ /// Fwd decl.
+ template <typename I, typename V>
+ I& operator<<(abstract::mutable_image<I>& input, const V values[]);
+
+ /// Fwd decl.
+ template <typename I>
+ I& operator<<(abstract::mutable_image<I>& input, const oln_value(I)& value);
+
+
namespace level
{
/// Fwd decl.
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& val);
+ void fill(abstract::mutable_image<I>& input, const oln_value(I)& value);
+ /// Fwd decl.
+ template <typename I, typename V>
+ void fill(abstract::mutable_image<I>& input, const V values[]);
+
# ifndef OLN_INCLUDE_ONLY
namespace impl
@@ -60,27 +76,66 @@
/// Generic version.
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& val)
+ void fill(abstract::mutable_image<I>& input, const oln_value(I)& value)
{
oln_piter(I) p(input.topo());
for_all(p)
- input(p) = val;
+ input(p) = value;
}
+ /// Generic version.
+ template <typename I, typename V>
+ void fill(abstract::mutable_image<I>& input, const V values[])
+ {
+ oln_piter(I) p(input.topo());
+ unsigned i = 0;
+ for_all(p)
+ input(p) = values[i++];
+ }
+
} // end of namespace oln::level::fill
/// Facade.
template <typename I>
- void fill(abstract::mutable_image<I>& input, const oln_value(I)& val)
+ void fill(abstract::mutable_image<I>& input, const oln_value(I)& value)
{
- impl::fill(input.exact(), val);
+ impl::fill(input.exact(), value);
}
+ /// Facade.
+ template <typename I, typename V>
+ void fill(abstract::mutable_image<I>& input, const V values[])
+ {
+ return impl::fill(input.exact(), values);
+ }
+
+
# endif
} // end of namespace oln::level
+
+# ifndef OLN_INCLUDE_ONLY
+
+ /// Fwd decl.
+ template <typename I, typename V>
+ I& operator<<(abstract::mutable_image<I>& input, const V values[])
+ {
+ level::fill(input, values);
+ return input.exact();
+ }
+
+ /// Fwd decl.
+ template <typename I>
+ I& operator<<(abstract::mutable_image<I>& input, const oln_value(I)& value)
+ {
+ level::fill(input, value);
+ return input.exact();
+ }
+
+# endif
+
} // end of namespace oln
Index: oln/core/automatic/image/mutable_image2d.hh
===================================================================
--- oln/core/automatic/image/mutable_image2d.hh (revision 0)
+++ oln/core/automatic/image/mutable_image2d.hh (revision 0)
@@ -0,0 +1,82 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_AUTOMATIC_IMAGE_MUTABLE_IMAGE2D_HH
+# define OLN_CORE_AUTOMATIC_IMAGE_MUTABLE_IMAGE2D_HH
+
+# include <oln/core/automatic/impl.hh>
+# include <oln/morpher/tags.hh>
+# include <oln/core/2d/point2d.hh>
+
+
+namespace oln
+{
+ // Forward declaration.
+ namespace abstract
+ {
+ template <typename E> class mutable_image2d;
+
+ } // end of namespace oln::abstract
+
+
+ namespace automatic
+ {
+
+
+ /// Default implementation corresponding to the interface
+ /// oln::abstract::mutable_image2d.
+ template <typename E, typename tag>
+ class set_impl<abstract::mutable_image2d, tag, E> :
+ public virtual stc::any__simple<E>
+ {
+ public:
+ oln_lvalue(E) impl_at(const oln_coord(E)& row, const oln_coord(E)& col);
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // 1. convert (row, col) -> p then 2. call operator()(p).
+
+ template <typename E, typename tag>
+ oln_lvalue(E)
+ set_impl<abstract::mutable_image2d, tag, E>
+ ::impl_at(const oln_coord(E)& row, const oln_coord(E)& col)
+ {
+ point2d tmp(row, col);
+ return this->exact().operator()(tmp);
+ }
+
+# endif
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+#endif // ! OLN_CORE_AUTOMATIC_IMAGE_MUTABLE_IMAGE2D_HH
Index: oln/core/automatic/image/mutable_image3d.hh
===================================================================
--- oln/core/automatic/image/mutable_image3d.hh (revision 0)
+++ oln/core/automatic/image/mutable_image3d.hh (revision 0)
@@ -0,0 +1,85 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_AUTOMATIC_IMAGE_MUTABLE_IMAGE3D_HH
+# define OLN_CORE_AUTOMATIC_IMAGE_MUTABLE_IMAGE3D_HH
+
+# include <oln/core/automatic/impl.hh>
+# include <oln/morpher/tags.hh>
+# include <oln/core/3d/point3d.hh>
+
+
+namespace oln
+{
+ // Forward declaration.
+ namespace abstract
+ {
+ template <typename E> class mutable_image3d;
+
+ } // end of namespace oln::abstract
+
+
+ namespace automatic
+ {
+
+
+ /// Default implementation corresponding to the interface
+ /// oln::abstract::mutable_image3d.
+ template <typename E, typename tag>
+ class set_impl<abstract::mutable_image3d, tag, E> :
+ public virtual stc::any__simple<E>
+ {
+ public:
+ oln_lvalue(E) impl_at(const oln_coord(E)& slice,
+ const oln_coord(E)& row,
+ const oln_coord(E)& col);
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // 1. convert (slice, row, col) -> p then 2. call operator()(p).
+
+ template <typename E, typename tag>
+ oln_lvalue(E)
+ set_impl<abstract::mutable_image3d, tag, E>
+ ::impl_at(const oln_coord(E)& slice,
+ const oln_coord(E)& row,
+ const oln_coord(E)& col)
+ {
+ point3d tmp(slice, row, col);
+ return this->exact().operator()(tmp);
+ }
+
+# endif
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+#endif // ! OLN_CORE_AUTOMATIC_IMAGE_MUTABLE_IMAGE3D_HH
Index: oln/core/automatic/image/image1d.hh
===================================================================
--- oln/core/automatic/image/image1d.hh (revision 669)
+++ oln/core/automatic/image/image1d.hh (working copy)
@@ -58,35 +58,15 @@
oln_rvalue(E) impl_at(const oln_coord(E)& index) const;
// FIXME: Hack.
- oln_lvalue(E) impl_at(const oln_coord(E)& index);
bool impl_has_at(const oln_coord(E)& index) const;
};
-
- /// Implementation corresponding to the interface
- /// oln::abstract::image1d for an identity morpher.
- template <typename E>
- class set_impl<abstract::image1d, morpher::tag::identity, E> :
- public virtual stc::any__simple<E>
- {
- public:
-
- oln_rvalue(E) impl_at(const oln_coord(E)& index) const;
-
- // FIXME: Hack.
- oln_lvalue(E) impl_at(const oln_coord(E)& index);
- bool impl_has_at(const oln_coord(E)& index) const;
-
- };
-
-
-
# ifndef OLN_INCLUDE_ONLY
- // Default is: 1. convert (index) -> p then 2. call operator()(p).
+ // 1. convert (index) -> p then 2. call operator()(p).
template <typename E, typename tag>
oln_rvalue(E)
@@ -98,15 +78,6 @@
}
template <typename E, typename tag>
- oln_lvalue(E)
- set_impl<abstract::image1d, tag, E>
- ::impl_at(const oln_coord(E)& index)
- {
- point1d tmp(index);
- return this->exact().operator()(tmp);
- }
-
- template <typename E, typename tag>
bool
set_impl<abstract::image1d, tag, E>
::impl_has_at(const oln_coord(E)& index) const
@@ -115,33 +86,6 @@
return this->exact().has(tmp);
}
-
- // For morphers: delegate.
-
- template <typename E>
- oln_rvalue(E)
- set_impl<abstract::image1d, morpher::tag::identity, E>
- ::impl_at(const oln_coord(E)& index) const
- {
- return this->exact().delegate().at(index);
- }
-
- template <typename E>
- oln_lvalue(E)
- set_impl<abstract::image1d, morpher::tag::identity, E>
- ::impl_at(const oln_coord(E)& index)
- {
- return this->exact().delegate().at(index);
- }
-
- template <typename E>
- bool
- set_impl<abstract::image1d, morpher::tag::identity, E>
- ::impl_has_at(const oln_coord(E)& index) const
- {
- return this->exact().delegate().has_at(index);
- }
-
# endif
} // end of namespace oln::automatic
Index: oln/core/automatic/image/image2d.hh
===================================================================
--- oln/core/automatic/image/image2d.hh (revision 669)
+++ oln/core/automatic/image/image2d.hh (working copy)
@@ -57,36 +57,17 @@
oln_rvalue(E) impl_at(const oln_coord(E)& row, const oln_coord(E)& col) const;
- // FIXME: Hack.
- oln_lvalue(E) impl_at(const oln_coord(E)& row, const oln_coord(E)& col);
+ // FIXME: Hack; should be elsewhere...
bool impl_has_at(const oln_coord(E)& row, const oln_coord(E)& col) const;
};
- /// Implementation corresponding to the interface
- /// oln::abstract::image2d for an identity morpher.
- template <typename E>
- class set_impl<abstract::image2d, morpher::tag::identity, E> :
- public virtual stc::any__simple<E>
- {
- public:
-
- oln_rvalue(E) impl_at(const oln_coord(E)& row, const oln_coord(E)& col) const;
-
- // FIXME: Hack.
- oln_lvalue(E) impl_at(const oln_coord(E)& row, const oln_coord(E)& col);
- bool impl_has_at(const oln_coord(E)& row, const oln_coord(E)& col) const;
-
- };
-
-
-
# ifndef OLN_INCLUDE_ONLY
- // Default is: 1. convert (row, col) -> p then 2. call operator()(p).
+ // 1. convert (row, col) -> p then 2. call operator()(p).
template <typename E, typename tag>
oln_rvalue(E)
@@ -98,15 +79,6 @@
}
template <typename E, typename tag>
- oln_lvalue(E)
- set_impl<abstract::image2d, tag, E>
- ::impl_at(const oln_coord(E)& row, const oln_coord(E)& col)
- {
- point2d tmp(row, col);
- return this->exact().operator()(tmp);
- }
-
- template <typename E, typename tag>
bool
set_impl<abstract::image2d, tag, E>
::impl_has_at(const oln_coord(E)& row, const oln_coord(E)& col) const
@@ -115,33 +87,6 @@
return this->exact().has(tmp);
}
-
- // For morphers: delegate.
-
- template <typename E>
- oln_rvalue(E)
- set_impl<abstract::image2d, morpher::tag::identity, E>
- ::impl_at(const oln_coord(E)& row, const oln_coord(E)& col) const
- {
- return this->exact().delegate().at(row, col);
- }
-
- template <typename E>
- oln_lvalue(E)
- set_impl<abstract::image2d, morpher::tag::identity, E>
- ::impl_at(const oln_coord(E)& row, const oln_coord(E)& col)
- {
- return this->exact().delegate().at(row, col);
- }
-
- template <typename E>
- bool
- set_impl<abstract::image2d, morpher::tag::identity, E>
- ::impl_has_at(const oln_coord(E)& row, const oln_coord(E)& col) const
- {
- return this->exact().delegate().has_at(row, col);
- }
-
# endif
} // end of namespace oln::automatic
Index: oln/core/automatic/image/image3d.hh
===================================================================
--- oln/core/automatic/image/image3d.hh (revision 669)
+++ oln/core/automatic/image/image3d.hh (working copy)
@@ -60,9 +60,6 @@
const oln_coord(E)& col) const;
// FIXME: Hack.
- oln_lvalue(E) impl_at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col);
bool impl_has_at(const oln_coord(E)& slice,
const oln_coord(E)& row,
const oln_coord(E)& col) const;
@@ -71,34 +68,10 @@
- /// Implementation corresponding to the interface
- /// oln::abstract::image3d for an identity morpher.
- template <typename E>
- class set_impl<abstract::image3d, morpher::tag::identity, E> :
- public virtual stc::any__simple<E>
- {
- public:
-
- oln_rvalue(E) impl_at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col) const;
-
- // FIXME: Hack.
- oln_lvalue(E) impl_at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col);
- bool impl_has_at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col) const;
-
- };
-
-
-
# ifndef OLN_INCLUDE_ONLY
- // Default is: 1. convert (slice, row, col) -> p then 2. call operator()(p).
+ // 1. convert (slice, row, col) -> p then 2. call operator()(p).
template <typename E, typename tag>
oln_rvalue(E)
@@ -112,17 +85,6 @@
}
template <typename E, typename tag>
- oln_lvalue(E)
- set_impl<abstract::image3d, tag, E>
- ::impl_at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col)
- {
- point3d tmp(slice, row, col);
- return this->exact().operator()(tmp);
- }
-
- template <typename E, typename tag>
bool
set_impl<abstract::image3d, tag, E>
::impl_has_at(const oln_coord(E)& slice,
@@ -133,39 +95,6 @@
return this->exact().has(tmp);
}
-
- // For morphers: delegate.
-
- template <typename E>
- oln_rvalue(E)
- set_impl<abstract::image3d, morpher::tag::identity, E>
- ::impl_at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col) const
- {
- return this->exact().delegate().at(slice, row, col);
- }
-
- template <typename E>
- oln_lvalue(E)
- set_impl<abstract::image3d, morpher::tag::identity, E>
- ::impl_at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col)
- {
- return this->exact().delegate().at(slice, row, col);
- }
-
- template <typename E>
- bool
- set_impl<abstract::image3d, morpher::tag::identity, E>
- ::impl_has_at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col) const
- {
- return this->exact().delegate().has_at(slice, row, col);
- }
-
# endif
} // end of namespace oln::automatic
Index: oln/core/automatic/image/mutable_image1d.hh
===================================================================
--- oln/core/automatic/image/mutable_image1d.hh (revision 0)
+++ oln/core/automatic/image/mutable_image1d.hh (revision 0)
@@ -0,0 +1,82 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_AUTOMATIC_IMAGE_IMAGE1D_HH
+# define OLN_CORE_AUTOMATIC_IMAGE_IMAGE1D_HH
+
+# include <oln/core/automatic/impl.hh>
+# include <oln/morpher/tags.hh>
+# include <oln/core/1d/point1d.hh>
+
+
+namespace oln
+{
+ // Forward declaration.
+ namespace abstract
+ {
+ template <typename E> class image1d;
+
+ } // end of namespace oln::abstract
+
+
+ namespace automatic
+ {
+
+
+ /// Default implementation corresponding to the interface
+ /// oln::abstract::image1d.
+ template <typename E, typename tag>
+ class set_impl<abstract::image1d, tag, E> :
+ public virtual stc::any__simple<E>
+ {
+ public:
+ oln_lvalue(E) impl_at(const oln_coord(E)& index);
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // 1. convert (index) -> p then 2. call operator()(p).
+
+ template <typename E, typename tag>
+ oln_lvalue(E)
+ set_impl<abstract::image1d, tag, E>
+ ::impl_at(const oln_coord(E)& index)
+ {
+ point1d tmp(index);
+ return this->exact().operator()(tmp);
+ }
+
+# endif
+
+ } // end of namespace oln::automatic
+
+} // end of namespace oln
+
+#endif // ! OLN_CORE_AUTOMATIC_IMAGE_IMAGE1D_HH
Index: oln/core/abstract/image.hh
===================================================================
--- oln/core/abstract/image.hh (revision 669)
+++ oln/core/abstract/image.hh (working copy)
@@ -29,9 +29,12 @@
#ifndef OLN_CORE_ABSTRACT_IMAGE_HH
# define OLN_CORE_ABSTRACT_IMAGE_HH
+# include <cstddef>
+
# include <oln/core/typedefs.hh>
# include <oln/core/abstract/fwd_decls.hh>
# include <oln/core/automatic/image/image.hh>
+# include <oln/debug/track.hh>
namespace oln
@@ -136,12 +139,14 @@
template <typename E>
image<E>::image()
{
+ ++debug::n_images;
}
template <typename E>
image<E>::~image()
{
decl();
+ --debug::n_images;
}
template <typename E>
Index: oln/core/abstract/image/dimension/1d.hh
===================================================================
--- oln/core/abstract/image/dimension/1d.hh (revision 669)
+++ oln/core/abstract/image/dimension/1d.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/abstract/image.hh>
# include <oln/core/automatic/image/image1d.hh>
+# include <oln/core/automatic/image/mutable_image1d.hh>
namespace oln
@@ -49,7 +50,6 @@
oln_rvalue(E) at(const oln_coord(E)& index) const;
// FIXME: Hack (should be elsewhere)!
- oln_lvalue(E) at(const oln_coord(E)& index);
bool has_at(const oln_coord(E)& index) const;
protected:
@@ -58,8 +58,26 @@
};
+ /// Class of 1D mutable images.
+ template <typename E>
+ struct mutable_image1d :
+ public image1d<E>,
+ public automatic::get_impl<mutable_image1d, E>
+ {
+ public:
+
+ oln_lvalue(E) at(const oln_coord(E)& index);
+
+ protected:
+ /// Constructor (protected, empty).
+ mutable_image1d();
+ };
+
+
# ifndef OLN_INCLUDE_ONLY
+ // image1d
+
template <typename E>
image1d<E>::image1d()
{
@@ -73,19 +91,26 @@
}
template <typename E>
- oln_lvalue(E)
- image1d<E>::at(const oln_coord(E)& index)
+ bool
+ image1d<E>::has_at(const oln_coord(E)& index) const
{
- return this->exact().impl_at(index);
+ return this->exact().impl_has_at(index);
}
+ // mutable_image1d
+
template <typename E>
- bool
- image1d<E>::has_at(const oln_coord(E)& index) const
+ mutable_image1d<E>::mutable_image1d()
{
- return this->exact().impl_has_at(index);
}
+ template <typename E>
+ oln_lvalue(E)
+ mutable_image1d<E>::at(const oln_coord(E)& index)
+ {
+ return this->exact().impl_at(index);
+ }
+
# endif
} // end of namespace oln::abstract
Index: oln/core/abstract/image/dimension/2d.hh
===================================================================
--- oln/core/abstract/image/dimension/2d.hh (revision 669)
+++ oln/core/abstract/image/dimension/2d.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/abstract/image.hh>
# include <oln/core/automatic/image/image2d.hh>
+# include <oln/core/automatic/image/mutable_image2d.hh>
namespace oln
@@ -49,7 +50,6 @@
oln_rvalue(E) at(const oln_coord(E)& row, const oln_coord(E)& col) const;
// FIXME: Hack (should be elsewhere)!
- oln_lvalue(E) at(const oln_coord(E)& row, const oln_coord(E)& col);
bool has_at(const oln_coord(E)& row, const oln_coord(E)& col) const;
protected:
@@ -58,8 +58,27 @@
};
+ /// Class of 2D mutable images.
+ template <typename E>
+ struct mutable_image2d :
+ public image2d<E>,
+ public automatic::get_impl<mutable_image2d, E>
+ {
+ public:
+
+ oln_lvalue(E) at(const oln_coord(E)& row, const oln_coord(E)& col);
+
+ protected:
+ /// Constructor (protected, empty).
+ mutable_image2d();
+ };
+
+
+
# ifndef OLN_INCLUDE_ONLY
+ // image2d
+
template <typename E>
image2d<E>::image2d()
{
@@ -73,19 +92,26 @@
}
template <typename E>
- oln_lvalue(E)
- image2d<E>::at(const oln_coord(E)& row, const oln_coord(E)& col)
+ bool
+ image2d<E>::has_at(const oln_coord(E)& row, const oln_coord(E)& col) const
{
- return this->exact().impl_at(row, col);
+ return this->exact().impl_has_at(row, col);
}
+ // mutable_image2d
+
template <typename E>
- bool
- image2d<E>::has_at(const oln_coord(E)& row, const oln_coord(E)& col) const
+ mutable_image2d<E>::mutable_image2d()
{
- return this->exact().impl_has_at(row, col);
}
+ template <typename E>
+ oln_lvalue(E)
+ mutable_image2d<E>::at(const oln_coord(E)& row, const oln_coord(E)& col)
+ {
+ return this->exact().impl_at(row, col);
+ }
+
# endif
} // end of namespace oln::abstract
Index: oln/core/abstract/image/dimension/3d.hh
===================================================================
--- oln/core/abstract/image/dimension/3d.hh (revision 669)
+++ oln/core/abstract/image/dimension/3d.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/abstract/image.hh>
# include <oln/core/automatic/image/image3d.hh>
+# include <oln/core/automatic/image/mutable_image3d.hh>
namespace oln
@@ -51,9 +52,6 @@
const oln_coord(E)& col) const;
// FIXME: Hack (should be elsewhere)!
- oln_lvalue(E) at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col);
bool has_at(const oln_coord(E)& slice,
const oln_coord(E)& row,
const oln_coord(E)& col) const;
@@ -64,8 +62,29 @@
};
+
+ /// Class of 3D mutable images.
+ template <typename E>
+ struct mutable_image3d :
+ public image3d<E>,
+ public automatic::get_impl<mutable_image3d, E>
+ {
+ public:
+
+ oln_lvalue(E) at(const oln_coord(E)& slice,
+ const oln_coord(E)& row,
+ const oln_coord(E)& col);
+
+ protected:
+ /// Constructor (protected, empty).
+ mutable_image3d();
+ };
+
+
# ifndef OLN_INCLUDE_ONLY
+ // image3d
+
template <typename E>
image3d<E>::image3d()
{
@@ -81,15 +100,6 @@
}
template <typename E>
- oln_lvalue(E)
- image3d<E>::at(const oln_coord(E)& slice,
- const oln_coord(E)& row,
- const oln_coord(E)& col)
- {
- return this->exact().impl_at(slice, row, col);
- }
-
- template <typename E>
bool
image3d<E>::has_at(const oln_coord(E)& slice,
const oln_coord(E)& row,
@@ -98,6 +108,22 @@
return this->exact().impl_has_at(slice, row, col);
}
+ // mutable_image3d
+
+ template <typename E>
+ mutable_image3d<E>::mutable_image3d()
+ {
+ }
+
+ template <typename E>
+ oln_lvalue(E)
+ mutable_image3d<E>::at(const oln_coord(E)& slice,
+ const oln_coord(E)& row,
+ const oln_coord(E)& col)
+ {
+ return this->exact().impl_at(slice, row, col);
+ }
+
# endif
} // end of namespace oln::abstract
Index: oln/core/abstract/image/dimension/hierarchy.hh
===================================================================
--- oln/core/abstract/image/dimension/hierarchy.hh (revision 669)
+++ oln/core/abstract/image/dimension/hierarchy.hh (working copy)
@@ -65,7 +65,10 @@
Default case: If no known grid type is returned by `oln_type_of(I, grid)',
the entry is directly plugged to abstract::image<I>. */
+// FIXME: Figure above is obsolete because of the introduction of
+// sub-abstractions related to mutability.
+
/*-------------------------.
| Dimension abstractions. |
`-------------------------*/
@@ -90,26 +93,53 @@
/// 1D case.
+
template <typename E>
struct case_< image_hierarchy_wrt_dimension, E, 1 > :
- where_< mlc::eq_< oln_type_of(E, grid), oln::grid1d > >
+ where_< mlc::and_< mlc::eq_< oln_grid(E), oln::grid1d >,
+ mlc_is_ok(oln_lvalue(E)) > >
{
+ typedef abstract::mutable_image1d<E> ret;
+ };
+
+ template <typename E>
+ struct case_< image_hierarchy_wrt_dimension, E, 2 > :
+ where_< mlc::eq_< oln_grid(E), oln::grid1d > >
+ {
typedef abstract::image1d<E> ret;
};
/// 2D case.
+
template <typename E>
- struct case_< image_hierarchy_wrt_dimension, E, 2 > :
- where_< mlc::eq_< oln_type_of(E, grid), oln::grid2d > >
+ struct case_< image_hierarchy_wrt_dimension, E, 3 > :
+ where_< mlc::and_< mlc::eq_< oln_grid(E), oln::grid2d >,
+ mlc_is_ok(oln_lvalue(E)) > >
{
+ typedef abstract::mutable_image2d<E> ret;
+ };
+
+ template <typename E>
+ struct case_< image_hierarchy_wrt_dimension, E, 4 > :
+ where_< mlc::eq_< oln_grid(E), oln::grid2d > >
+ {
typedef abstract::image2d<E> ret;
};
/// 3D case.
+
template <typename E>
- struct case_< image_hierarchy_wrt_dimension, E, 3 > :
- where_< mlc::eq_< oln_type_of(E, grid), oln::grid3d > >
+ struct case_< image_hierarchy_wrt_dimension, E, 5 > :
+ where_< mlc::and_< mlc::eq_< oln_grid(E), oln::grid3d >,
+ mlc_is_ok(oln_lvalue(E)) > >
{
+ typedef abstract::mutable_image3d<E> ret;
+ };
+
+ template <typename E>
+ struct case_< image_hierarchy_wrt_dimension, E, 6 > :
+ where_< mlc::eq_< oln_grid(E), oln::grid3d > >
+ {
typedef abstract::image3d<E> ret;
};
Index: oln/core/2d/array2d.hh
===================================================================
--- oln/core/2d/array2d.hh (revision 669)
+++ oln/core/2d/array2d.hh (working copy)
@@ -29,7 +29,7 @@
#ifndef OLN_CORE_2D_ARRAY2D_HH
# define OLN_CORE_2D_ARRAY2D_HH
-# include <cstdlib>
+# include <cstddef>
# include <mlc/contract.hh>
@@ -55,7 +55,7 @@
bool has(coord_t i, coord_t j) const;
- size_t memsize() const;
+ std::size_t memsize() const;
protected:
Index: oln/core/2d/image2d.hh
===================================================================
--- oln/core/2d/image2d.hh (revision 669)
+++ oln/core/2d/image2d.hh (working copy)
@@ -79,6 +79,9 @@
public:
+ /// Ctor without info.
+ image2d();
+
/// Ctor using sizes.
image2d(unsigned nrows, unsigned ncols, unsigned border = 2);
@@ -107,6 +110,13 @@
# ifndef OLN_INCLUDE_ONLY
template <typename T>
+ image2d<T>::image2d()
+ : topo_(),
+ data_()
+ {
+ }
+
+ template <typename T>
image2d<T>::image2d(unsigned nrows, unsigned ncols, unsigned border)
: topo_(bbox2d(point2d(0, 0 ),
point2d(nrows - 1, ncols - 1)),
@@ -145,6 +155,7 @@
template <typename T>
T image2d<T>::impl_at(int row, int col) const
{
+ precondition(data_ != 0);
precondition(data_->has(row, col));
return data_->operator()(row, col);
}
Index: oln/Makefile.am
===================================================================
--- oln/Makefile.am (revision 669)
+++ oln/Makefile.am (working copy)
@@ -98,6 +98,9 @@
core/automatic/image/image2d.hh \
core/automatic/image/image3d.hh \
core/automatic/image/mutable_image.hh \
+ core/automatic/image/mutable_image1d.hh \
+ core/automatic/image/mutable_image2d.hh \
+ core/automatic/image/mutable_image3d.hh \
core/automatic/image/image_being_random_accessible.hh \
core/automatic/image/image_having_neighborhood.hh \
core/automatic/image/image_having_neighborhood.hh \
@@ -156,6 +159,7 @@
core/type.hh \
\
debug/print.hh \
+ debug/track.hh \
debug/typename.hh \
\
io/pnm.hh \
@@ -170,6 +174,7 @@
morpher/identity.hh \
morpher/tags.hh \
morpher/slice.hh \
+ morpher/stack.hh \
morpher/thru_fun.hh \
morpher/thru_mfun.hh \
morpher/value_cast.hh \
Index: oln/morpher/stack.hh
===================================================================
--- oln/morpher/stack.hh (revision 0)
+++ oln/morpher/stack.hh (revision 0)
@@ -0,0 +1,191 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_MORPHER_STACK_HH
+# define OLN_MORPHER_STACK_HH
+
+# include <xtd/vec.hh>
+# include <oln/morpher/internal/image_value_morpher.hh>
+
+
+
+namespace oln
+{
+
+ namespace morpher
+ {
+ // Forward declaration.
+ template <unsigned n, typename I> struct stack;
+
+ } // end of namespace oln::morpher
+
+
+ /// Super type.
+ template <unsigned n, typename I>
+ struct set_super_type< morpher::stack<n, I> >
+ {
+ typedef morpher::stack<n, I> self_t;
+ typedef morpher::internal::image_value_morpher<I, self_t> ret;
+ };
+
+ template <unsigned n, typename I>
+ struct vtypes< morpher::stack<n, I> >
+ {
+ typedef mlc::true_ is_computed_type;
+ typedef xtd::vec<n, oln_value(I)> value_type;
+ };
+
+ template <unsigned n, typename I>
+ struct single_vtype< morpher::stack<n, I>, typedef_::rvalue_type >
+ {
+ typedef xtd::vec<n, oln_value(I)> ret;
+ };
+
+
+ namespace morpher
+ {
+ /// "Stack of images" morpher.
+ template <unsigned n, typename I>
+ class stack : public internal::image_value_morpher< I, stack<n, I> >
+ {
+ private:
+
+ typedef stack<n, I> self_t;
+ typedef internal::image_value_morpher<I, self_t> super_t;
+
+ typedef oln_psite(self_t) psite_t;
+ typedef oln_rvalue(self_t) rvalue_t;
+
+ public:
+
+ stack(const xtd::vec<n, I>& images);
+
+ xtd::vec<n, oln_value(I)> impl_op_read(const psite_t& p) const;
+
+ const I& image(unsigned i) const;
+
+ protected:
+ 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
+
+
+ template <typename I>
+ morpher::stack<2, I>
+ stack(const abstract::image<I>& image_0,
+ const abstract::image<I>& image_1);
+
+ 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);
+
+ 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);
+
+
+# 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;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHER_STACK_HH
1
0
2006-10-23 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
* xtd/vec.hh (ops): Move outside of class.
(vec_base_): New specialization for <4, T>.
(mk_vec): New overloading for 4 args.
Index: xtd/vec.hh
===================================================================
--- xtd/vec.hh (revision 664)
+++ xtd/vec.hh (working copy)
@@ -25,7 +25,6 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-
#ifndef XTD_VEC_HH
# define XTD_VEC_HH
@@ -89,7 +88,22 @@
T data_[3];
};
+ template <typename T>
+ class vec_base_ <4, T>
+ {
+ public:
+ void set(const T& val0, const T& val1, const T& val2, const T& val3)
+ {
+ data_[0] = val0;
+ data_[1] = val1;
+ data_[2] = val2;
+ data_[3] = val3;
+ }
+ protected:
+ T data_[4];
+ };
+
} // end of namespace xtd::internal
@@ -124,7 +138,7 @@
return *this;
}
- const T operator[](unsigned i) const
+ const T& operator[](unsigned i) const
{
precondition(i < n);
return data_[i];
@@ -147,123 +161,134 @@
return n;
}
- // eq
+ };
- bool operator==(const vec& rhs) const
- {
- for (unsigned i = 0; i < n; ++i)
- if (data_[i] != rhs[i])
- return false;
- return true;
- }
- bool operator!=(const vec& rhs) const
- {
- return not (*this == rhs);
- }
- // +
- template <typename U>
- vec& operator+=(const vec<n,U>& rhs)
- {
- for (unsigned i = 0; i < n; ++i)
- data_[i] += rhs[i];
- return *this;
- }
+ // eq
- template <typename U>
- vec<n, xtd_op_plus_trait(T, U)>
- operator+(const vec<n,U>& rhs) const
- {
- vec<n, xtd_op_plus_trait(T, U)> tmp;
- for (unsigned i = 0; i < n; ++i)
- tmp[i] = data_[i] + rhs[i];
- return tmp;
- }
+ template <unsigned n, typename T, typename U>
+ bool operator==(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ if (lhs[i] != rhs[i])
+ return false;
+ return true;
+ }
- // -
+ template <unsigned n, typename T, typename U>
+ bool operator!=(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ return not (lhs == rhs);
+ }
- template <typename U>
- vec& operator-=(const vec<n,U>& rhs)
- {
- for (unsigned i = 0; i < n; ++i)
- data_[i] -= rhs[i];
- return *this;
- }
- template <typename U>
- vec<n, xtd_op_minus_trait(T, U)>
- operator-(const vec<n,U>& rhs) const
- {
- vec<n, xtd_op_plus_trait(T, U)> tmp;
- for (unsigned i = 0; i < n; ++i)
- tmp[i] = data_[i] - rhs[i];
- return tmp;
- }
+ // +
- vec<n, xtd_op_uminus_trait(T)>
- operator-() const
- {
- vec<n, xtd_op_uminus_trait(T)> tmp;
- for (unsigned i = 0; i < n; ++i)
- tmp[i] = - data_[i];
- return tmp;
- }
+ template <unsigned n, typename T, typename U>
+ vec<n,T>&
+ operator+=(vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ lhs[i] += rhs[i];
+ return lhs;
+ }
- // *
+ template <unsigned n, typename T, typename U>
+ vec<n, xtd_op_plus_trait(T, U)>
+ operator+(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ vec<n, xtd_op_plus_trait(T, U)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] + rhs[i];
+ return tmp;
+ }
- template <typename U> void operator*=(const vec<n,U>& rhs);
- template <typename U> void operator*(const vec<n,U>& rhs) const;
- template <typename S>
- vec& operator*=(const S& scalar)
- {
- for (unsigned i = 0; i < n; ++i)
- data_[i] *= scalar;
- return *this;
- }
+ // -
- template <typename S>
- vec<n, xtd_op_mult_trait(T, S)>
- operator*(const S& scalar) const
- {
- vec<n, xtd_op_mult_trait(T, S)> tmp;
- for (unsigned i = 0; i < n; ++i)
- tmp[i] = data_[i] * scalar;
- return tmp;
- }
+ template <unsigned n, typename T, typename U>
+ vec<n,T>&
+ operator-=(vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ lhs[i] -= rhs[i];
+ return lhs;
+ }
- // /
-
- template <typename U> void operator/=(const vec<n,U>& rhs);
- template <typename U> void operator/(const vec<n,U>& rhs) const;
+ template <unsigned n, typename T, typename U>
+ vec<n, xtd_op_minus_trait(T, U)>
+ operator-(const vec<n,T>& lhs, const vec<n,U>& rhs)
+ {
+ vec<n, xtd_op_plus_trait(T, U)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] - rhs[i];
+ return tmp;
+ }
- template <typename S>
- vec& operator/=(const S& scalar)
- {
- precondition(scalar != 0);
- for (unsigned i = 0; i < n; ++i)
- data_[i] /= scalar;
- return *this;
- }
+ template <unsigned n, typename T>
+ vec<n, xtd_op_uminus_trait(T)>
+ operator-(const vec<n,T>& lhs)
+ {
+ vec<n, xtd_op_uminus_trait(T)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = - lhs[i];
+ return tmp;
+ }
- template <typename S>
- vec<n, xtd_op_div_trait(T, S)>
- operator/(const S& scalar) const
- {
- precondition(scalar != 0);
- vec<n, xtd_op_div_trait(T, S)> tmp;
- for (unsigned i = 0; i < n; ++i)
- tmp[i] = data_[i] / scalar;
- return tmp;
- }
- };
+ // *
+ template <unsigned n, typename T, typename S>
+ vec<n,T>&
+ operator*=(vec<n,T>& lhs, const S& scalar)
+ {
+ for (unsigned i = 0; i < n; ++i)
+ lhs[i] *= scalar;
+ return lhs;
+ }
+ template <unsigned n, typename T, typename S>
+ vec<n, xtd_op_mult_trait(T, S)>
+ operator*(const vec<n,T>& lhs, const S& scalar)
+ {
+ vec<n, xtd_op_mult_trait(T, S)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] * scalar;
+ return tmp;
+ }
+
+
+ // /
+
+ template <unsigned n, typename T, typename S>
+ vec<n,T>&
+ operator/=(vec<n,T>& lhs, const S& scalar)
+ {
+ precondition(scalar != 0);
+ for (unsigned i = 0; i < n; ++i)
+ lhs[i] /= scalar;
+ return lhs;
+ }
+
+ template <unsigned n, typename T, typename S>
+ vec<n, xtd_op_div_trait(T, S)>
+ operator/(const vec<n,T>& lhs, const S& scalar)
+ {
+ precondition(scalar != 0);
+ vec<n, xtd_op_div_trait(T, S)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = lhs[i] / scalar;
+ return tmp;
+ }
+
+
+ // <<
+
template <unsigned n, typename T>
- std::ostream& operator<<(std::ostream& ostr, const vec<n,T>& v)
+ std::ostream&
+ operator<<(std::ostream& ostr, const vec<n,T>& v)
{
ostr << '(';
for (unsigned i = 0; i < n; ++i)
@@ -272,7 +297,8 @@
}
template <unsigned n>
- std::ostream& operator<<(std::ostream& ostr, const vec<n,unsigned char>& v)
+ std::ostream&
+ operator<<(std::ostream& ostr, const vec<n,unsigned char>& v)
{
ostr << '(';
for (unsigned i = 0; i < n; ++i)
@@ -281,7 +307,8 @@
}
template <unsigned n>
- std::ostream& operator<<(std::ostream& ostr, const vec<n,signed char>& v)
+ std::ostream&
+ operator<<(std::ostream& ostr, const vec<n,signed char>& v)
{
ostr << '(';
for (unsigned i = 0; i < n; ++i)
@@ -359,7 +386,18 @@
return tmp;
}
+ template <typename T>
+ vec<4, T> mk_vec(const T& v_0, const T& v_1, const T& v_2, const T& v_3)
+ {
+ vec<4, T> tmp;
+ tmp[0] = v_0;
+ tmp[1] = v_1;
+ tmp[2] = v_2;
+ tmp[3] = v_3;
+ return tmp;
+ }
+
} // end of namespace xtd
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add files for oln::window[123]d.
* oln/core/1d/window1d.hh: New file.
* oln/basics1d.hh: Include it.
* oln/core/2d/window2d.hh: New file.
* oln/basics2d.hh: Include it.
* oln/core/3d/window3d.hh: New file.
* oln/basics3d.hh: Include it.
* oln/Makefile.am (nobase_oln_HEADERS): Add core/1d/window1d.hh,
core/2d/window2d.hh and core/3d/window3d.hh
* tests/morphers/slice_morpher.cc: Remove FIXME.
oln/Makefile.am | 3 +++
oln/basics1d.hh | 5 ++---
oln/basics2d.hh | 5 ++---
oln/basics3d.hh | 5 ++---
oln/core/1d/window1d.hh | 37 +++++++++++++++++++++++++++++++++++++
oln/core/2d/window2d.hh | 37 +++++++++++++++++++++++++++++++++++++
oln/core/3d/window3d.hh | 37 +++++++++++++++++++++++++++++++++++++
tests/morphers/slice_morpher.cc | 3 ---
8 files changed, 120 insertions(+), 12 deletions(-)
Index: tests/morphers/slice_morpher.cc
--- tests/morphers/slice_morpher.cc (revision 667)
+++ tests/morphers/slice_morpher.cc (working copy)
@@ -32,9 +32,6 @@
#include <mlc/assert.hh>
#include <mlc/is_a.hh>
-// FIXME: We should not include oln/basics2d.hh and oln/basics3d.hh,
-// but only oln/core/3d/image3d.hh and oln/core/2d/image2d.hh,
-// oln/core/2d/window2d.
#include <oln/basics2d.hh>
#include <oln/basics3d.hh>
#include <oln/morpher/slice.hh>
Index: oln/basics1d.hh
--- oln/basics1d.hh (revision 667)
+++ oln/basics1d.hh (working copy)
@@ -37,13 +37,12 @@
# include <oln/core/1d/point1d.hh>
# include <oln/core/1d/dpoint1d.hh>
-# include <oln/core/gen/bbox.hh>
-# include <oln/core/gen/topo_lbbox.hh>
+# include <oln/core/1d/topo1d.hh>
# include <oln/core/gen/fwd_piter_bbox.hh>
# include <oln/core/gen/bkd_piter_bbox.hh>
-# include <oln/core/gen/window.hh>
+# include <oln/core/1d/window1d.hh>
# include <oln/core/gen/fwd_qiter_win.hh>
# include <oln/core/gen/bkd_qiter_win.hh>
Index: oln/core/1d/window1d.hh
--- oln/core/1d/window1d.hh (revision 0)
+++ oln/core/1d/window1d.hh (revision 0)
@@ -0,0 +1,37 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_1D_WINDOW1D_HH
+# define OLN_CORE_1D_WINDOW1D_HH
+
+// Headers required for the complete definition of oln::window1d
+// (i.e., oln::window_<dpoint1d>).
+# include <oln/core/1d/aliases.hh>
+# include <oln/core/1d/dpoint1d.hh>
+# include <oln/core/gen/window.hh>
+
+#endif // ! OLN_CORE_1D_WINDOW1D_HH
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 0)
+++ oln/core/2d/window2d.hh (revision 0)
@@ -0,0 +1,37 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_2D_WINDOW2D_HH
+# define OLN_CORE_2D_WINDOW2D_HH
+
+// Headers required for the complete definition of oln::window2d
+// (i.e., oln::window_<dpoint2d>).
+# include <oln/core/2d/aliases.hh>
+# include <oln/core/2d/dpoint2d.hh>
+# include <oln/core/gen/window.hh>
+
+#endif // ! OLN_CORE_2D_WINDOW2D_HH
Index: oln/core/3d/window3d.hh
--- oln/core/3d/window3d.hh (revision 0)
+++ oln/core/3d/window3d.hh (revision 0)
@@ -0,0 +1,37 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_3D_WINDOW3D_HH
+# define OLN_CORE_3D_WINDOW3D_HH
+
+// Headers required for the complete definition of oln::window3d
+// (i.e., oln::window_<dpoint3d>).
+# include <oln/core/3d/aliases.hh>
+# include <oln/core/3d/dpoint3d.hh>
+# include <oln/core/gen/window.hh>
+
+#endif // ! OLN_CORE_3D_WINDOW3D_HH
Index: oln/basics2d.hh
--- oln/basics2d.hh (revision 667)
+++ oln/basics2d.hh (working copy)
@@ -37,13 +37,12 @@
# include <oln/core/2d/point2d.hh>
# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/gen/bbox.hh>
-# include <oln/core/gen/topo_lbbox.hh>
+# include <oln/core/2d/topo2d.hh>
# include <oln/core/gen/fwd_piter_bbox.hh>
# include <oln/core/gen/bkd_piter_bbox.hh>
-# include <oln/core/gen/window.hh>
+# include <oln/core/2d/window2d.hh>
# include <oln/core/gen/fwd_qiter_win.hh>
# include <oln/core/gen/bkd_qiter_win.hh>
Index: oln/Makefile.am
--- oln/Makefile.am (revision 667)
+++ oln/Makefile.am (working copy)
@@ -13,6 +13,7 @@
core/1d/neighb1d.hh \
core/1d/point1d.hh \
core/1d/topo1d.hh \
+ core/1d/window1d.hh \
\
core/2d/aliases.hh \
core/2d/array2d.hh \
@@ -22,6 +23,7 @@
core/2d/neighb2d.hh \
core/2d/point2d.hh \
core/2d/topo2d.hh \
+ core/2d/window2d.hh \
\
core/3d/aliases.hh \
core/3d/array3d.hh \
@@ -31,6 +33,7 @@
core/3d/neighb3d.hh \
core/3d/point3d.hh \
core/3d/topo3d.hh \
+ core/3d/window3d.hh \
\
core/abstract/image/accessibility/hierarchy.hh \
\
Index: oln/basics3d.hh
--- oln/basics3d.hh (revision 667)
+++ oln/basics3d.hh (working copy)
@@ -37,13 +37,12 @@
# include <oln/core/3d/point3d.hh>
# include <oln/core/3d/dpoint3d.hh>
-# include <oln/core/gen/bbox.hh>
-# include <oln/core/gen/topo_lbbox.hh>
+# include <oln/core/3d/topo3d.hh>
# include <oln/core/gen/fwd_piter_bbox.hh>
# include <oln/core/gen/bkd_piter_bbox.hh>
-# include <oln/core/gen/window.hh>
+# include <oln/core/3d/window3d.hh>
# include <oln/core/gen/fwd_qiter_win.hh>
# include <oln/core/gen/bkd_qiter_win.hh>
1
0