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
858: Move the responsibility of iteration on window points from images to windows.
by Thierry Geraud 08 Mar '07
by Thierry Geraud 08 Mar '07
08 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Move the responsibility of iteration on window points from
images to windows.
* ChangeLog: Add missing former entry.
* core/concept/image.hh (value): Add missing code.
(qiter, fwd_qiter, bkd_qiter): Move to...
* core/concept/window.hh: ...here.
(point): New virtual type.
* core/concept/neighborhood.hh (point): Likewise.
* core/2d/aliases.hh,
* core/2d/neighb2d.hh,
* core/2d/dpoint2d.hh,
* core/2d/window2d.hh,
* core/2d/box2d.hh: Update.
* core/gen/dpoints_piter.hh (include): Remove useless ones.
* oln/core/internal/neighborhood_base.hh: New.
* core/gen/neighb.hh: Update inheritance.
* oln/core/internal/window_base.hh: New.
* core/gen/window.hh: Update inheritance.
(vtypes): Update.
* core/internal/point_set_std_based.hh: Fix missing return.
* core/internal/image_base.hh: Update.
* core/internal/point2d.hh: Fix wrong visibility.
2d/aliases.hh | 35 ++++++++------
2d/box2d.hh | 3 -
2d/dpoint2d.hh | 4 +
2d/neighb2d.hh | 3 -
2d/point2d.hh | 4 +
2d/window2d.hh | 5 +-
concept/image.hh | 4 -
concept/neighborhood.hh | 1
concept/window.hh | 6 ++
gen/dpoints_piter.hh | 6 --
gen/neighb.hh | 8 +--
gen/single_value_image.hh | 2
gen/window.hh | 11 ++--
internal/image_base.hh | 4 -
internal/neighborhood_base.hh | 92 ++++++++++++++++++++++++++++++++++++++
internal/point2d.hh | 2
internal/point_set_std_based.hh | 1
internal/window_base.hh | 96 ++++++++++++++++++++++++++++++++++++++++
18 files changed, 249 insertions(+), 38 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 857)
+++ oln/core/concept/image.hh (working copy)
@@ -195,9 +195,6 @@
{
stc_using_from(Image, point);
- stc_typename(qiter);
- stc_typename(fwd_qiter);
- stc_typename(bkd_qiter);
bool has(const point& p) const;
protected:
@@ -454,6 +451,7 @@
typename Value_Wise_Mutable_Image<Exact>::lvaluep
Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
{
+ return exact(this)->impl_value_read_write(v);
}
template <typename Exact>
Index: oln/core/concept/window.hh
--- oln/core/concept/window.hh (revision 857)
+++ oln/core/concept/window.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_CORE_CONCEPT_WINDOW_HH
# include <oln/core/equipment.hh>
+# include <oln/core/concept/point.hh>
namespace oln
@@ -40,6 +41,11 @@
struct Window : public Any<Exact>
{
stc_typename(grid);
+ stc_typename(point);
+
+ stc_typename(qiter);
+ stc_typename(fwd_qiter);
+ stc_typename(bkd_qiter);
protected:
Window();
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 857)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -40,6 +40,7 @@
struct Neighborhood : public Any<Exact>
{
stc_typename(grid);
+ stc_typename(point);
protected:
Neighborhood();
Index: oln/core/2d/aliases.hh
--- oln/core/2d/aliases.hh (revision 857)
+++ oln/core/2d/aliases.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -35,29 +35,36 @@
/// Forward declarations.
/// \{
+
+ template <typename P> class box_;
+ template <typename P> class box_fwd_piter_;
+ template <typename P> class box_bkd_piter_;
+
template <typename D> class neighb_;
template <typename D> class window_;
- template <typename P> class topo_lbbox_;
- template <typename P> class fwd_piter_bbox_;
- template <typename P> class bkd_piter_bbox_;
- template <typename P> class fwd_qiter_win_;
- template <typename P> class bkd_qiter_win_;
+ template <typename P> class dpoints_fwd_piter_;
+ template <typename P> class dpoints_bkd_piter_;
+
/// \}
/// Aliases.
/// \{
- typedef neighb_<dpoint2d> neighb2d;
- typedef window_<dpoint2d> window2d;
-
- typedef topo_lbbox_<point2d> topo2d;
+ typedef box_<point2d> box2d;
+ typedef box_fwd_piter_<point2d> piter2d;
+ typedef box_fwd_piter_<point2d> fwd_piter2d;
+ typedef box_bkd_piter_<point2d> bkd_piter2d;
- typedef fwd_piter_bbox_<point2d> fwd_piter2d;
- typedef bkd_piter_bbox_<point2d> bkd_piter2d;
+ typedef neighb_<dpoint2d> neighb2d;
+ typedef dpoints_fwd_piter_<point2d> niter2d;
+ typedef dpoints_fwd_piter_<point2d> fwd_niter2d;
+ typedef dpoints_bkd_piter_<point2d> bkd_niter2d;
- typedef fwd_qiter_win_<point2d> fwd_qiter2d;
- typedef bkd_qiter_win_<point2d> bkd_qiter2d;
+ typedef window_<dpoint2d> window2d;
+ typedef dpoints_fwd_piter_<point2d> qiter2d;
+ typedef dpoints_fwd_piter_<point2d> fwd_qiter2d;
+ typedef dpoints_bkd_piter_<point2d> bkd_qiter2d;
/// \}
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 857)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -31,12 +31,13 @@
# include <oln/core/gen/neighb.hh>
# include <oln/core/2d/dpoint2d.hh>
+# include <oln/core/2d/aliases.hh>
namespace oln
{
- typedef neighb_<dpoint2d> neighb2d;
+ // FIXME: neighb2d should be an actual type, not an alias...
namespace internal
Index: oln/core/2d/dpoint2d.hh
--- oln/core/2d/dpoint2d.hh (revision 857)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -88,4 +88,8 @@
} // end of namespace oln
+// dpoint2d goes with point2d so:
+# include <oln/core/2d/point2d.hh>
+
+
#endif // ! OLN_CORE_2D_DPOINT2D_HH
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 857)
+++ oln/core/2d/window2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -30,12 +30,13 @@
# include <oln/core/gen/window.hh>
# include <oln/core/2d/dpoint2d.hh>
+# include <oln/core/2d/aliases.hh>
namespace oln
{
- typedef window_<dpoint2d> window2d;
+ // FIXME: window2d should be an actual type, not an alias...
window2d mk_square(unsigned odd_len);
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 857)
+++ oln/core/2d/box2d.hh (working copy)
@@ -30,12 +30,13 @@
# include <oln/core/gen/box.hh>
# include <oln/core/2d/point2d.hh>
+# include <oln/core/2d/aliases.hh>
namespace oln
{
- typedef box_<point2d> box2d;
+ // FIXME: box2d should be an actual type, not an alias...
} // end of namespace oln
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 857)
+++ oln/core/2d/point2d.hh (working copy)
@@ -88,4 +88,8 @@
} // end of namespace oln
+// point2d goes with dpoint2d so:
+# include <oln/core/2d/dpoint2d.hh>
+
+
#endif // ! OLN_CORE_2D_POINT2D_HH
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 857)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -29,8 +29,6 @@
# define OLN_CORE_GEN_DPOINTS_PITER_HH
# include <oln/core/concept/iterator_on_points.hh>
-# include <oln/core/concept/window.hh>
-# include <oln/core/concept/neighborhood.hh>
# include <oln/core/internal/dpoints_impl.hh>
@@ -39,8 +37,8 @@
/// Fwd decls.
- template <typename P> struct dpoints_fwd_piter_;
- template <typename P> struct dpoints_bkd_piter_;
+ template <typename P> class dpoints_fwd_piter_;
+ template <typename P> class dpoints_bkd_piter_;
// Super types.
Index: oln/core/gen/neighb.hh
--- oln/core/gen/neighb.hh (revision 857)
+++ oln/core/gen/neighb.hh (working copy)
@@ -30,7 +30,7 @@
# define OLN_CORE_GEN_NEIGHB_HH
# include <oln/core/internal/dpoints_impl.hh>
-# include <oln/core/concept/neighborhood.hh>
+# include <oln/core/internal/neighborhood_base.hh>
namespace oln
@@ -46,7 +46,7 @@
struct super_trait_< neighb_<Dp> >
{
typedef neighb_<Dp> current__;
- typedef Neighborhood<current__> ret;
+ typedef internal::neighborhood_base_<current__> ret;
};
@@ -54,14 +54,14 @@
template <typename Dp>
struct vtypes< neighb_<Dp> >
{
- typedef stc_type(Dp, grid) grid;
+ typedef stc_type(Dp, point) point;
};
/// Generic classical neighborhood class.
template <typename Dp>
- class neighb_ : public Neighborhood< neighb_<Dp> >,
+ class neighb_ : public internal::neighborhood_base_< neighb_<Dp> >,
public internal::dpoints_impl_<Dp>
{
public:
Index: oln/core/gen/window.hh
--- oln/core/gen/window.hh (revision 857)
+++ oln/core/gen/window.hh (working copy)
@@ -28,8 +28,9 @@
#ifndef OLN_CORE_GEN_WINDOW_HH
# define OLN_CORE_GEN_WINDOW_HH
+# include <oln/core/internal/window_base.hh>
# include <oln/core/internal/dpoints_impl.hh>
-# include <oln/core/concept/window.hh>
+# include <oln/core/gen/dpoints_piter.hh>
namespace oln
@@ -45,7 +46,7 @@
struct super_trait_< window_<Dp> >
{
typedef window_<Dp> current__;
- typedef Window<current__> ret;
+ typedef internal::window_base_<current__> ret;
};
@@ -53,14 +54,16 @@
template <typename Dp>
struct vtypes< window_<Dp> >
{
- typedef stc_type(Dp, grid) grid;
+ typedef stc_type(Dp, point) point;
+ typedef dpoints_fwd_piter_<point> fwd_qiter;
+ typedef dpoints_bkd_piter_<point> bkd_qiter;
};
/// Generic classical windoworhood class.
template <typename Dp>
- class window_ : public Window< window_<Dp> >,
+ class window_ : public internal::window_base_< window_<Dp> >,
public internal::dpoints_impl_<Dp>
{
public:
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 857)
+++ oln/core/gen/single_value_image.hh (working copy)
@@ -48,6 +48,8 @@
typedef point psite;
typedef Ps pset;
+ typedef typename point::coord coord;
+
typedef T value;
typedef const T& rvalue;
Index: oln/core/internal/window_base.hh
--- oln/core/internal/window_base.hh (revision 0)
+++ oln/core/internal/window_base.hh (revision 0)
@@ -0,0 +1,96 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_WINDOW_BASE_HH
+# define OLN_CORE_INTERNAL_WINDOW_BASE_HH
+
+# include <oln/core/concept/window.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ namespace internal { template <typename Exact> class window_base_; }
+
+
+ // Super type.
+ template <typename Exact>
+ struct super_trait_< internal::window_base_<Exact> >
+ {
+ typedef Window<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::window_base_<Exact> >
+ {
+ typedef stc::abstract point;
+ typedef stc::abstract fwd_qiter;
+ typedef stc::abstract bkd_qiter;
+
+ typedef stc_deferred(point) point__;
+ typedef stc_deferred(fwd_qiter) fwd_qiter__;
+
+ typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< fwd_qiter__ > qiter;
+ };
+
+
+ namespace internal
+ {
+
+ /// Base class for implementation of windows class.
+
+ template <typename Exact>
+ class window_base_ : public Window<Exact>
+ {
+ protected:
+ window_base_();
+
+ }; // end of class oln::window_base_<Exact>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ window_base_<Exact>::window_base_()
+ {
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_WINDOW_BASE_HH
Index: oln/core/internal/neighborhood_base.hh
--- oln/core/internal/neighborhood_base.hh (revision 0)
+++ oln/core/internal/neighborhood_base.hh (revision 0)
@@ -0,0 +1,92 @@
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
+// Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
+# define OLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
+
+# include <oln/core/concept/neighborhood.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ namespace internal { template <typename Exact> class neighborhood_base_; }
+
+
+ // Super type.
+ template <typename Exact>
+ struct super_trait_< internal::neighborhood_base_<Exact> >
+ {
+ typedef Neighborhood<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::neighborhood_base_<Exact> >
+ {
+ typedef stc::abstract point;
+
+ typedef stc_deferred(point) point__;
+ typedef stc::final< stc_type(point__, grid) > grid;
+ };
+
+
+ namespace internal
+ {
+
+ /// Base class for implementation of neighborhoods class.
+
+ template <typename Exact>
+ class neighborhood_base_ : public Neighborhood< neighb_<Exact> >
+ {
+ protected:
+ neighborhood_base_();
+
+ }; // end of class oln::neighborhood_base_<Exact>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ neighborhood_base_<Exact>::neighborhood_base_()
+ {
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_NEIGHBORHOOD_BASE_HH
Index: oln/core/internal/point_set_std_based.hh
--- oln/core/internal/point_set_std_based.hh (revision 857)
+++ oln/core/internal/point_set_std_based.hh (working copy)
@@ -109,6 +109,7 @@
for_all(i)
ostr << i.to_point() << ' ';
ostr << "}";
+ return ostr;
}
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 857)
+++ oln/core/internal/image_base.hh (working copy)
@@ -33,7 +33,6 @@
# include <oln/core/internal/utils.hh>
# include <oln/core/gen/box.hh>
# include <oln/core/gen/image_pset_piter.hh>
-# include <oln/core/gen/dpoints_piter.hh>
@@ -140,9 +139,6 @@
typedef stc_deferred(point) point__;
typedef stc::final< point__ > psite;
- typedef stc::final< dpoints_fwd_piter_<point__> > fwd_qiter;
- typedef stc::final< dpoints_bkd_piter_<point__> > bkd_qiter;
- typedef fwd_qiter qiter;
};
template <typename Exact>
Index: oln/core/internal/point2d.hh
--- oln/core/internal/point2d.hh (revision 857)
+++ oln/core/internal/point2d.hh (working copy)
@@ -64,9 +64,9 @@
class point2d_ : public point_base_<Exact>
{
typedef point_base_<Exact> super;
- stc_using(coord);
public:
+ stc_using(coord);
coord row() const;
coord& row();
1
0
Ce patch permet � g++ 4.1 de compiler le code enregistr� par Th�o hier
(qui devait compiler avec g++ 3.3). Il y a a probablement d'autres endroits
� modifier de la sorte dans Olena, car le test qui a permis de rep�rer ces
erreurs �tait relativement petit.
Index: ChangeLog
from Ugo Jardonnet <ugo.jardonnet(a)lrde.epita.fr>
Fix name lookup for attribute of super classes.
* olena/oln/core/concept/image.hh,
* olena/oln/core/gen/dpoints_piter.hh,
* olena/oln/core/internal/point_base.hh,
* olena/oln/core/internal/dpoint_base.hh: Fix name lookup
for attribute of super classes.
concept/image.hh | 13 ++++++-------
gen/dpoints_piter.hh | 12 ++++++------
internal/dpoint_base.hh | 2 ++
internal/point_base.hh | 2 ++
4 files changed, 16 insertions(+), 13 deletions(-)
Index: olena/oln/core/concept/image.hh
--- olena/oln/core/concept/image.hh (revision 856)
+++ olena/oln/core/concept/image.hh (working copy)
@@ -412,21 +412,21 @@
typename Fast_Image<Exact>::rvalue
Fast_Image<Exact>::operator[](typename Fast_Image<Exact>::index i) const
{
- return exact(this)->impl_index_read(p);
+ return exact(this)->impl_index_read(i);
}
template <typename Exact>
typename Fast_Image<Exact>::lvalue
Fast_Image<Exact>::operator[](typename Fast_Image<Exact>::index i)
{
- return exact(this)->impl_index_read_write(p);
+ return exact(this)->impl_index_read_write(i);
}
template <typename Exact>
std::size_t
Fast_Image<Exact>::npoints() const
{
- return exact(this)->impl_npoints(p);
+ return exact(this)->impl_npoints();
}
template <typename Exact>
@@ -454,7 +454,6 @@
typename Value_Wise_Mutable_Image<Exact>::lvaluep
Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
{
- return exact(this)->impl_value_read_write(p);
}
template <typename Exact>
@@ -503,7 +502,7 @@
bool
Point_Wise_Accessible_Image_2D<Exact>::impl_has_at(coord row, coord col) const
{
- Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ typename Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
return this->has(p);
}
@@ -511,7 +510,7 @@
typename Point_Wise_Accessible_Image_2D<Exact>::rvalue
Point_Wise_Accessible_Image_2D<Exact>::impl_at(coord row, coord col) const
{
- Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ typename Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
return this->at(p);
}
@@ -533,7 +532,7 @@
typename Point_Wise_Mutable_Image_2D<Exact>::lvalue
Point_Wise_Mutable_Image_2D<Exact>::impl_at(coord row, coord col)
{
- Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
+ typename Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
return this->at(p);
}
Index: olena/oln/core/gen/dpoints_piter.hh
--- olena/oln/core/gen/dpoints_piter.hh (revision 856)
+++ olena/oln/core/gen/dpoints_piter.hh (working copy)
@@ -228,7 +228,7 @@
void
dpoints_fwd_piter_<P>::impl_start()
{
- i_ = 0;
+ this->i_ = 0;
this->update_p_();
}
@@ -236,7 +236,7 @@
void
dpoints_fwd_piter_<P>::impl_next()
{
- if (++i_ == n_)
+ if (++this->i_ == this->n_)
return;
this->update_p_();
}
@@ -256,7 +256,7 @@
void
dpoints_bkd_piter_<P>::impl_start()
{
- i_ = n_ - 1;
+ this->i_ = this->n_ - 1;
this->update_p_();
}
@@ -264,12 +264,12 @@
void
dpoints_bkd_piter_<P>::impl_next()
{
- if (i_ == 0)
+ if (this->i_ == 0)
{
- i_ = n_;
+ this->i_ = this->n_;
return;
}
- --i_;
+ --this->i_;
this->update_p_();
}
Index: olena/oln/core/internal/point_base.hh
--- olena/oln/core/internal/point_base.hh (revision 856)
+++ olena/oln/core/internal/point_base.hh (working copy)
@@ -75,6 +75,8 @@
stc_using(dim);
stc_using(dpoint);
+ using super::n;
+
coord operator[](unsigned i) const;
coord& operator[](unsigned i);
Index: olena/oln/core/internal/dpoint_base.hh
--- olena/oln/core/internal/dpoint_base.hh (revision 856)
+++ olena/oln/core/internal/dpoint_base.hh (working copy)
@@ -76,6 +76,8 @@
stc_using(dim);
stc_using(point);
+ using super::n;
+
coord operator[](unsigned i) const;
coord& operator[](unsigned i);
1
0
06 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update windows and neighborhoods + remove obsolete files.
* oln/core/abstract/window.hh: Rename as...
* oln/core/concept/window.hh: ...this and update.
* oln/core/abstract/neighborhood.hh: Rename as...
* oln/core/concept/neighborhood.hh: ...this and update.
* oln/core/gen/fwd_qiter_win.hh: Rename as...
* oln/core/gen/dpoints_piter.hh: ...this and update.
* oln/core/internal/dpoints_impl.hh: New.
* oln/core/2d/neighb2d.hh: Update.
* oln/core/internal/image_base.hh (plain_primitive_image_): New.
* oln/core/2d/image2d.hh (image2d): Inherit from plain_primitive_image_.
* oln/core/2d/window2d.hh: Update
(mk_square): New.
* oln/core/gen/neighb.hh: Update.
* oln/core/internal/image_selectors.hh: Fix.
* oln/core/internal/dpoint_base.hh (include): Fix.
* oln/core/type.hh,
* oln/core/typedefs.hh,
* oln/core/macros.hh,
* oln/core/neighborhood_entry.hh,
* oln/core/gen/bkd_qiter_win.hh,
* oln/core/gen/grid.hh,
* oln/core/gen/topo_add_isubset.hh,
* oln/core/gen/topo_bbox.hh,
* oln/core/gen/fwd_niter_neighb.hh,
* oln/core/gen/topo_lbbox.hh,
* oln/core/gen/bkd_niter_neighb.hh,
* oln/core/gen/topo_add_nbh.hh,
* oln/core/internal/topology_morpher.hh: Remove.
2d/image2d.hh | 7 -
2d/neighb2d.hh | 42 +++---
2d/window2d.hh | 47 +++++++
concept/neighborhood.hh | 66 ++--------
concept/window.hh | 71 ++---------
gen/dpoints_piter.hh | 267 +++++++++++++++++++++++++++++---------------
gen/neighb.hh | 106 ++++-------------
gen/window.hh | 117 ++++++-------------
internal/dpoint_base.hh | 1
internal/dpoints_impl.hh | 125 ++++++++------------
internal/image_base.hh | 47 ++++++-
internal/image_selectors.hh | 2
12 files changed, 431 insertions(+), 467 deletions(-)
Index: oln/core/concept/window.hh
--- oln/core/concept/window.hh (revision 854)
+++ oln/core/concept/window.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,84 +25,39 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_WINDOW_HH
-# define OLN_CORE_ABSTRACT_WINDOW_HH
+#ifndef OLN_CORE_CONCEPT_WINDOW_HH
+# define OLN_CORE_CONCEPT_WINDOW_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
- namespace abstract { template <typename E> class window; }
+ /// Concept-class "Window".
-
- template <typename E>
- struct set_super_type< abstract::window<E> >
- {
- typedef mlc::none ret;
- };
-
-
- namespace abstract
- {
-
-
- /// Abstract window class.
- template <typename E>
- class window : public virtual stc::any__simple<E>,
- public virtual oln::type
- {
- public:
-
- bool is_valid() const;
-
- struct decl
+ template <typename Exact>
+ struct Window : public Any<Exact>
{
- oln_virtual_typedef(grid);
-
- decl();
- };
+ stc_typename(grid);
protected:
+ Window();
- window();
- ~window();
-
- }; // end of class oln::abstract::window<E>
+ }; // end of oln::Window<Exact>
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool window<E>::is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
- template <typename E>
- window<E>::window()
- {
- }
-
- template <typename E>
- window<E>::~window()
- {
- decl();
- }
-
- template <typename E>
- window<E>::decl::decl()
+ template <typename Exact>
+ Window<Exact>::Window()
{
}
# endif
-
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_WINDOW_HH
+#endif // ! OLN_CORE_CONCEPT_WINDOW_HH
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 854)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,79 +25,39 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
-# define OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
+#ifndef OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
+# define OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
- namespace abstract
- {
-
-
- /// Abstract neighborhood class.
- template <typename E>
- class neighborhood : public virtual stc::any__simple<E>,
- public virtual oln::type
- {
- public:
-
- bool is_valid() const;
+ /// Concept-class "Neighborhood".
- struct decl
+ template <typename Exact>
+ struct Neighborhood : public Any<Exact>
{
- oln_virtual_typedef(grid);
-
- decl();
- };
+ stc_typename(grid);
protected:
+ Neighborhood();
- neighborhood();
- ~neighborhood();
-
- }; // end of class oln::abstract::neighborhood<E>
+ }; // end of oln::Neighborhood<Exact>
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool neighborhood<E>::is_valid() const
- {
- return this->exact().impl_is_valid();
- }
-
- template <typename E>
- neighborhood<E>::neighborhood()
- {
- }
-
- template <typename E>
- neighborhood<E>::~neighborhood()
- {
- decl();
- }
-
- template <typename E>
- neighborhood<E>::decl::decl()
+ template <typename Exact>
+ Neighborhood<Exact>::Neighborhood()
{
}
# endif
-
- } // end of namespace oln::abstract
-
} // end of namespace oln
-
-// # include <oln/core/abstract/neighborhood_hierarchies.hh>
-
-
-
-#endif // ! OLN_CORE_ABSTRACT_NEIGHBORHOOD_HH
+#endif // ! OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 854)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -52,38 +52,38 @@
neighb2d mk_c4()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1, 0));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1))
+ .take(dpoint2d(1, 0));
+ return tmp;
}
neighb2d mk_c8()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1))
- .add(dpoint2d(1,-1))
- .add(dpoint2d(1, 0))
- .add(dpoint2d(1, 1));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1))
+ .take(dpoint2d(1,-1))
+ .take(dpoint2d(1, 0))
+ .take(dpoint2d(1, 1));
+ return tmp;
}
neighb2d mk_c2_row()
{
- neighb2d the_;
- the_
- .add(dpoint2d(0, 1));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(0, 1));
+ return tmp;
}
neighb2d mk_c2_col()
{
- neighb2d the_;
- the_
- .add(dpoint2d(1, 0));
- return the_;
+ neighb2d tmp;
+ tmp
+ .take(dpoint2d(1, 0));
+ return tmp;
}
# endif
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 854)
+++ oln/core/2d/image2d.hh (working copy)
@@ -46,7 +46,6 @@
struct vtypes< image2d<T> >
{
typedef point2d point;
- typedef point psite;
typedef int coord;
typedef unsigned index;
@@ -65,17 +64,17 @@
struct super_trait_< image2d<T> >
{
typedef image2d<T> current;
- typedef internal::image_base_<current> ret;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 2D image class.
template <typename T>
- class image2d : public internal::image_base_< image2d<T> >
+ class image2d : public internal::plain_primitive_image_< image2d<T> >
{
typedef image2d<T> current;
- typedef internal::image_base_<current> super;
+ typedef internal::plain_primitive_image_<current> super;
public:
stc_using(data);
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 854)
+++ oln/core/2d/window2d.hh (working copy)
@@ -28,10 +28,49 @@
#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>
+# include <oln/core/2d/dpoint2d.hh>
+
+
+namespace oln
+{
+
+ typedef window_<dpoint2d> window2d;
+
+
+ window2d mk_square(unsigned odd_len);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ window2d mk_square(unsigned odd_len)
+ {
+ precondition(odd_len % 2 = 1);
+ window2d tmp;
+ int half_len = odd_len / 2;
+ for (int drow = - half_len; drow <= half_len; ++drow)
+ for (int dcol = - half_len; dcol <= half_len; ++dcol)
+ tmp.take(dpoint2d(drow, dcol));
+ return tmp;
+ }
+
+# endif
+
+
+ extern const window2d win3x3;
+ extern const window2d win5x5;
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ const window2d win3x3 = mk_square(3);
+ const window2d win5x5 = mk_square(5);
+
+# endif
+
+
+} // end of namespace oln
+
#endif // ! OLN_CORE_2D_WINDOW2D_HH
Index: oln/core/gen/dpoints_piter.hh
--- oln/core/gen/dpoints_piter.hh (revision 854)
+++ oln/core/gen/dpoints_piter.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,154 +25,252 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_FWD_QITER_WIN_HH
-# define OLN_CORE_GEN_FWD_QITER_WIN_HH
+#ifndef OLN_CORE_GEN_DPOINTS_PITER_HH
+# define OLN_CORE_GEN_DPOINTS_PITER_HH
-# include <oln/core/abstract/iterator_on_points.hh>
-# include <oln/core/abstract/window.hh>
-# include <oln/core/gen/window.hh>
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/concept/window.hh>
+# include <oln/core/concept/neighborhood.hh>
+# include <oln/core/internal/dpoints_impl.hh>
namespace oln
{
- // Forward declaration.
- template <typename point_t> class fwd_qiter_win_;
+ /// Fwd decls.
+ template <typename P> struct dpoints_fwd_piter_;
+ template <typename P> struct dpoints_bkd_piter_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< fwd_qiter_win_<point_t> >
+ // Super types.
+ template <typename P>
+ struct super_trait_< dpoints_fwd_piter_<P> >
{
- typedef fwd_qiter_win_<point_t> self_t;
- typedef abstract::iterator_on_points<self_t> ret;
+ typedef dpoints_fwd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+ template <typename P>
+ struct super_trait_< dpoints_bkd_piter_<P> >
+ {
+ typedef dpoints_bkd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
};
- /// Virtual types associated to oln::fwd_qiter_win_<point_t>.
- template <typename point_t>
- struct vtypes< fwd_qiter_win_<point_t> >
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< dpoints_fwd_piter_<P> >
{
- typedef point_t point_type;
- typedef oln_grid(point_t) grid_type;
+ typedef P point;
+ };
+ template <typename P>
+ struct vtypes< dpoints_bkd_piter_<P> >
+ {
+ typedef P point;
};
- /// Abstract forward point iterator class.
- template <typename point_t>
- class fwd_qiter_win_ : public abstract::iterator_on_points< fwd_qiter_win_<point_t> >
+ namespace internal
{
- typedef fwd_qiter_win_<point_t> self_t;
- typedef abstract::iterator_on_points<self_t> super_t;
- typedef oln_dpoint(point_t) dpoint_t;
+ /// Class to factor some code.
+
+ template <typename P>
+ class dpoints_piter_impl_ : private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ public:
+
+ void impl_invalidate();
+
+ bool impl_is_valid() const;
+
+ P impl_to_point() const;
+
+ const P* impl_point_adr() const;
+
+ protected:
+
+ const P* p_ref_;
+ const std::vector<typename P::dpoint>* dps_;
+ unsigned n_, i_;
+ P p_;
+
+ // Ctor.
+ template <typename Pl>
+ dpoints_piter_impl_(const Pl& ref,
+ const internal::dpoints_impl_<typename P::dpoint>& data);
+
+ void update_p_();
+ };
+
+ } // end of namespace oln::internal
+
+
+ /// Forward point iterator class on a set of dpoints.
+
+ template <typename P>
+ class dpoints_fwd_piter_ : public Iterator_on_Points< dpoints_fwd_piter_<P> >,
+ public internal::dpoints_piter_impl_<P>
+ {
public:
- template <typename P, typename W>
- fwd_qiter_win_(const abstract::iterator_on_points<P>& it,
- const abstract::window<W>& win);
-
- template <typename P, typename W>
- fwd_qiter_win_(const abstract::point<P>& p,
- const abstract::window<W>& win);
+ template <typename Pl, typename X>
+ dpoints_fwd_piter_(const Pl& p, const X& win_or_nbh);
void impl_start();
void impl_next();
- void impl_invalidate();
+ }; // end of class oln::dpoints_fwd_piter_<P>
- bool impl_is_valid() const;
- point_t impl_to_point() const;
- const point_t* impl_point_adr() const;
+ /// Backward point iterator class on a set of dpoints.
- protected:
+ template <typename P>
+ class dpoints_bkd_piter_ : public Iterator_on_Points< dpoints_bkd_piter_<P> >,
+ public internal::dpoints_piter_impl_<P>
+ {
+ public:
+
+ template <typename Pl, typename X>
+ dpoints_bkd_piter_(const Pl& p, const X& win_or_nbh);
- const point_t* p_ref_;
- window_<dpoint_t> win_;
- int i_;
- point_t p_;
+ void impl_start();
+
+ void impl_next();
- }; // end of class oln::fwd_qiter_win_<point_t>
+ }; // end of class oln::dpoints_bkd_piter_<P>
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- template <typename P, typename W>
- fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::iterator_on_points<P>& it,
- const abstract::window<W>& win)
- : p_ref_(it.point_adr()),
- win_(win.exact())
+ namespace internal
{
- precondition(win_.card() > 0);
- this->invalidate();
+
+ template <typename Pl>
+ const Pl* point_adr_(const Point<Pl>& p)
+ {
+ return exact(&p);
}
- template <typename point_t>
- template <typename P, typename W>
- fwd_qiter_win_<point_t>::fwd_qiter_win_(const abstract::point<P>& p,
- const abstract::window<W>& win)
- : p_ref_(&(p.exact())),
- win_(win.exact())
+ template <typename Pl>
+ const typename Pl::point* point_adr_(const Iterator_on_Points<Pl>& p)
{
- precondition(win_.card() > 0);
- this->invalidate();
+ return p.point_adr();
+ }
+
+ template <typename P>
+ template <typename Pl>
+ dpoints_piter_impl_<P>::dpoints_piter_impl_(const Pl& ref,
+ const internal::dpoints_impl_<typename P::dpoint>& data)
+ {
+ p_ref_ = point_adr_(ref);
+ dps_ = &(data.dpoints());
+ n_ = data.size();
+ i_ = n_;
+ postcondition(n_ != 0);
}
- template <typename point_t>
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_start()
+ dpoints_piter_impl_<P>::impl_invalidate()
{
- i_ = 0;
- p_ = *p_ref_+ win_.dp(i_);
+ i_ = n_;
+ }
+
+ template <typename P>
+ bool
+ dpoints_piter_impl_<P>::impl_is_valid() const
+ {
+ return i_ != n_;
+ }
+
+ template <typename P>
+ P
+ dpoints_piter_impl_<P>::impl_to_point() const
+ {
+ return p_;
}
- template <typename point_t>
+ template <typename P>
+ const P*
+ dpoints_piter_impl_<P>::impl_point_adr() const
+ {
+ return &p_;
+ }
+
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_next()
+ dpoints_piter_impl_<P>::update_p_()
{
- ++i_;
- if (i_ = int(win_.card()))
+ p_ = *p_ref_+ (*dps_)[i_];
+ }
+
+ } // end of namespace oln::internal
+
+
+ // fwd
+
+ template <typename P>
+ template <typename Pl, typename X>
+ dpoints_fwd_piter_<P>::dpoints_fwd_piter_(const Pl& p, const X& win_or_nbh)
+ :
+ internal::dpoints_piter_impl_<P>(p, exact(win_or_nbh))
{
- this->invalidate();
- return;
}
- p_ = *p_ref_ + win_.dp(i_);
+
+ template <typename P>
+ void
+ dpoints_fwd_piter_<P>::impl_start()
+ {
+ i_ = 0;
+ this->update_p_();
}
- template <typename point_t>
+ template <typename P>
void
- fwd_qiter_win_<point_t>::impl_invalidate()
+ dpoints_fwd_piter_<P>::impl_next()
{
- i_ = -1;
+ if (++i_ = n_)
+ return;
+ this->update_p_();
}
- template <typename point_t>
- bool
- fwd_qiter_win_<point_t>::impl_is_valid() const
+
+ // bkd
+
+ template <typename P>
+ template <typename Pl, typename X>
+ dpoints_bkd_piter_<P>::dpoints_bkd_piter_(const Pl& p, const X& win_or_nbh)
+ :
+ internal::dpoints_piter_impl_<P>(p, exact(win_or_nbh))
{
- return i_ != -1;
}
- template <typename point_t>
- point_t
- fwd_qiter_win_<point_t>::impl_to_point() const
+ template <typename P>
+ void
+ dpoints_bkd_piter_<P>::impl_start()
{
- return p_;
+ i_ = n_ - 1;
+ this->update_p_();
}
- template <typename point_t>
- const point_t*
- fwd_qiter_win_<point_t>::impl_point_adr() const
+ template <typename P>
+ void
+ dpoints_bkd_piter_<P>::impl_next()
{
- return &p_;
+ if (i_ = 0)
+ {
+ i_ = n_;
+ return;
+ }
+ --i_;
+ this->update_p_();
}
# endif
@@ -180,5 +278,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_FWD_QITER_WIN_HH
-
+#endif // ! OLN_CORE_GEN_DPOINTS_PITER_HH
Index: oln/core/gen/neighb.hh
--- oln/core/gen/neighb.hh (revision 854)
+++ oln/core/gen/neighb.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,120 +29,66 @@
#ifndef OLN_CORE_GEN_NEIGHB_HH
# define OLN_CORE_GEN_NEIGHB_HH
-# include <set>
-# include <vector>
-# include <oln/core/neighborhood_entry.hh>
-# include <oln/core/abstract/dpoint.hh>
+# include <oln/core/internal/dpoints_impl.hh>
+# include <oln/core/concept/neighborhood.hh>
namespace oln
{
- // Forward declaration.
- template <typename dpoint> class neighb_;
+ // Fwd decl.
+ template <typename Dp> class neighb_;
- // Super type declaration.
- template <typename dpoint>
- struct set_super_type< neighb_<dpoint> >
+ // Super type.
+ template <typename Dp>
+ struct super_trait_< neighb_<Dp> >
{
- typedef neighb_<dpoint> self_t;
- typedef neighborhood_entry<self_t> ret;
+ typedef neighb_<Dp> current__;
+ typedef Neighborhood<current__> ret;
};
- /// Virtual types associated to oln::neighb_<dpoint>.
- template <typename dpoint>
- struct vtypes< neighb_<dpoint> >
+ /// Virtual types.
+ template <typename Dp>
+ struct vtypes< neighb_<Dp> >
{
- typedef oln_vtype(dpoint, grid) grid_type;
+ typedef stc_type(Dp, grid) grid;
};
- struct FIXME_ERR;
+ /// Generic classical neighborhood class.
-
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class neighb_ : public neighborhood_entry< neighb_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint), FIXME_ERR >
+ template <typename Dp>
+ class neighb_ : public Neighborhood< neighb_<Dp> >,
+ public internal::dpoints_impl_<Dp>
{
- typedef neighb_<dpoint> self_t;
- typedef neighborhood_entry<self_t> super_t;
-
public:
neighb_();
- neighb_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- neighb_<dpoint>& add(const abstract::dpoint<D>& dp);
-
- unsigned card() const;
-
- dpoint dp(unsigned i) const;
-
- // void print(std::ostream& ostr) const;
- // friend std::ostream& operator<<(std::ostream& ostr, const neighb_<dpoint>& nbh);
+ neighb_<Dp>& take(const Dp& dp);
- protected:
-
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
-
- void update_();
-
- }; // end of class oln::neighb_<dpoint>
+ }; // end of class oln::neighb_<Dp>
# ifndef OLN_INCLUDE_ONLY
-
- template <typename dpoint>
- neighb_<dpoint>::neighb_()
+ template <typename Dp>
+ neighb_<Dp>::neighb_()
{
}
- template <typename dpoint>
- neighb_<dpoint>& neighb_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ neighb_<Dp>& neighb_<Dp>::take(const Dp& dp)
{
- s_.insert(dp);
- s_.insert(-dp);
- update_();
+ this->take_( dp);
+ this->take_(-dp);
return *this;
}
- template <typename dpoint>
- template <typename D>
- neighb_<dpoint>& neighb_<dpoint>::add(const abstract::dpoint<D>& dp)
- {
- return this->add(dp.exact());
- }
-
- template <typename dpoint>
- unsigned neighb_<dpoint>::card() const
- {
- return v_.size();
- }
-
- template <typename dpoint>
- dpoint neighb_<dpoint>::dp(unsigned i) const
- {
- precondition(i < v_.size());
- return v_[i];
- }
-
- template <typename dpoint>
- void neighb_<dpoint>::update_()
- {
- v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
- }
-
# endif
Index: oln/core/gen/window.hh
--- oln/core/gen/window.hh (revision 854)
+++ oln/core/gen/window.hh (working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,123 +28,81 @@
#ifndef OLN_CORE_GEN_WINDOW_HH
# define OLN_CORE_GEN_WINDOW_HH
-# include <set>
-# include <vector>
-# include <mlc/assert.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/window.hh>
+# include <oln/core/internal/dpoints_impl.hh>
+# include <oln/core/concept/window.hh>
namespace oln
{
+
// Fwd decl.
- template <typename dpoint> class window_;
+ template <typename Dp> class window_;
- template <typename dpoint>
- struct set_super_type< window_<dpoint> >
+ // Super type.
+ template <typename Dp>
+ struct super_trait_< window_<Dp> >
{
- typedef abstract::window< window_<dpoint> > ret;
+ typedef window_<Dp> current__;
+ typedef Window<current__> ret;
};
- template <typename dpoint>
- struct vtypes< window_<dpoint> >
+ /// Virtual types.
+ template <typename Dp>
+ struct vtypes< window_<Dp> >
{
- typedef oln_vtype(dpoint, grid) grid_type;
+ typedef stc_type(Dp, grid) grid;
};
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class window_ : public abstract::window< window_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint) >
- {
- typedef window_<dpoint> self_t;
+ /// Generic classical windoworhood class.
+ template <typename Dp>
+ class window_ : public Window< window_<Dp> >,
+ public internal::dpoints_impl_<Dp>
+ {
public:
window_();
- window_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- window_<dpoint>& add(const abstract::dpoint<D>& dp);
-
- dpoint dp(unsigned i) const;
-
- unsigned card() const;
+ window_<Dp>& take(const Dp& dp);
- bool impl_is_valid() const;
+ window_<Dp> impl_op_unary_minus_() const;
- protected:
+ }; // end of class oln::window_<Dp>
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
-
- void update_();
-
- }; // end of class oln::window_<dpoint>
# ifndef OLN_INCLUDE_ONLY
- template <typename dpoint>
- window_<dpoint>::window_()
+ template <typename Dp>
+ window_<Dp>::window_()
{
}
- template <typename dpoint>
- window_<dpoint>&
- window_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ window_<Dp>&
+ window_<Dp>::take(const Dp& dp)
{
- s_.insert(dp);
- update_();
+ this->take_( dp);
return *this;
}
- template <typename dpoint>
- template <typename D>
- window_<dpoint>&
- window_<dpoint>::add(const abstract::dpoint<D>& dp)
- {
- return this->add(dp.exact());
- }
-
- template <typename dpoint>
- unsigned
- window_<dpoint>::card() const
- {
- return v_.size();
- }
-
- template <typename dpoint>
- dpoint
- window_<dpoint>::dp(unsigned i) const
- {
- precondition(i < v_.size());
- return v_[i];
- }
-
- template <typename dpoint>
- bool
- window_<dpoint>::impl_is_valid() const
- {
- return v_.size() != 0;
- }
-
- template <typename dpoint>
- void
- window_<dpoint>::update_()
- {
- v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
+ template <typename Dp>
+ window_<Dp>
+ window_<Dp>::impl_op_unary_minus_() const
+ {
+ window_<Dp> tmp;
+ for (unsigned i = 0; i < this->size(); ++i)
+ tmp.take(- this->v_[i]);
+ return tmp;
}
# endif
+
} // end of namespace oln
Index: oln/core/internal/dpoints_impl.hh
--- oln/core/internal/dpoints_impl.hh (revision 854)
+++ oln/core/internal/dpoints_impl.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,127 +26,104 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_WINDOW_HH
-# define OLN_CORE_GEN_WINDOW_HH
+#ifndef OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
+# define OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
# include <set>
# include <vector>
-# include <mlc/assert.hh>
-# include <oln/core/abstract/dpoint.hh>
-# include <oln/core/abstract/window.hh>
+# include <iterator>
+# include <oln/core/concept/dpoint.hh>
namespace oln
{
- // Fwd decl.
- template <typename dpoint> class window_;
-
-
- template <typename dpoint>
- struct set_super_type< window_<dpoint> >
- {
- typedef abstract::window< window_<dpoint> > ret;
- };
-
-
- template <typename dpoint>
- struct vtypes< window_<dpoint> >
+ namespace internal
{
- typedef oln_vtype(dpoint, grid) grid_type;
- };
+ /// Implementation for classes storing a set of dpoints.
- /// Abstract forward dpoint iterator class.
- template <typename dpoint>
- class window_ : public abstract::window< window_<dpoint> >,
- private mlc::assert_< mlc_is_a(dpoint, abstract::dpoint) >
+ template <typename Dp>
+ class dpoints_impl_
+ : private mlc::assert_< mlc_is_a(Dp, Dpoint) >
{
- typedef window_<dpoint> self_t;
-
public:
- window_();
-
- window_<dpoint>& add(const dpoint& dp);
-
- template <typename D>
- window_<dpoint>& add(const abstract::dpoint<D>& dp);
+ unsigned size() const;
+ const Dp& operator[](unsigned i) const;
+ const std::vector<Dp>& dpoints() const;
- dpoint dp(unsigned i) const;
-
- unsigned card() const;
+ protected:
- bool impl_is_valid() const;
+ dpoints_impl_();
+ void take_(const Dp& dp);
- protected:
+ std::vector<Dp> v_;
- std::set<dpoint> s_;
- std::vector<dpoint> v_;
+ private:
void update_();
+ std::set<Dp> s_;
- }; // end of class oln::window_<dpoint>
+ }; // end of class oln::internal::dpoints_impl_<Dp>
# ifndef OLN_INCLUDE_ONLY
- template <typename dpoint>
- window_<dpoint>::window_()
- {
- }
+ // public:
- template <typename dpoint>
- window_<dpoint>&
- window_<dpoint>::add(const dpoint& dp)
+ template <typename Dp>
+ unsigned
+ dpoints_impl_<Dp>::size() const
{
- s_.insert(dp);
- update_();
- return *this;
+ return v_.size();
}
- template <typename dpoint>
- template <typename D>
- window_<dpoint>&
- window_<dpoint>::add(const abstract::dpoint<D>& dp)
+ template <typename Dp>
+ const Dp&
+ dpoints_impl_<Dp>::operator[](unsigned i) const
{
- return this->add(dp.exact());
+ precondition(i < v_.size());
+ return v_[i];
}
- template <typename dpoint>
- unsigned
- window_<dpoint>::card() const
+ template <typename Dp>
+ const std::vector<Dp>&
+ dpoints_impl_<Dp>::dpoints() const
{
- return v_.size();
+ return v_;
}
- template <typename dpoint>
- dpoint
- window_<dpoint>::dp(unsigned i) const
+ // protected:
+
+ template <typename Dp>
+ dpoints_impl_<Dp>::dpoints_impl_()
{
- precondition(i < v_.size());
- return v_[i];
}
- template <typename dpoint>
- bool
- window_<dpoint>::impl_is_valid() const
+ template <typename Dp>
+ void
+ dpoints_impl_<Dp>::take_(const Dp& dp)
{
- return v_.size() != 0;
+ s_.insert(dp);
+ update_();
}
- template <typename dpoint>
+ // private:
+
+ template <typename Dp>
void
- window_<dpoint>::update_()
+ dpoints_impl_<Dp>::update_()
{
v_.clear();
- std::copy(s_.begin(), s_.end(),
- std::back_inserter(v_));
+ std::copy(s_.begin(), s_.end(), std::back_inserter(v_));
}
# endif
+ } // end of namespace oln::internal
+
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_WINDOW_HH
+#endif // ! OLN_CORE_INTERNAL_DPOINTS_IMPL_HH
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 854)
+++ oln/core/internal/image_selectors.hh (working copy)
@@ -102,7 +102,7 @@
// FIXME: ...
template <typename Exact>
- struct default_case_< Image_pw_accessibility, Exact >
+ struct case_< Image_pw_accessibility, Exact, 3 >
:
where_< mlc::eq_< stc_get_type(psite), stc_get_type(point) > >
{
Index: oln/core/internal/dpoint_base.hh
--- oln/core/internal/dpoint_base.hh (revision 854)
+++ oln/core/internal/dpoint_base.hh (working copy)
@@ -31,6 +31,7 @@
# include <xtd/vec.hh>
# include <mlc/int.hh>
+# include <oln/core/internal/point_base.hh>
# include <oln/core/concept/dpoint.hh>
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 854)
+++ oln/core/internal/image_base.hh (working copy)
@@ -33,6 +33,7 @@
# include <oln/core/internal/utils.hh>
# include <oln/core/gen/box.hh>
# include <oln/core/gen/image_pset_piter.hh>
+# include <oln/core/gen/dpoints_piter.hh>
@@ -44,7 +45,10 @@
namespace internal
{
template <typename Exact> struct image_base_;
+
template <typename Exact> struct primitive_image_;
+ template <typename Exact> struct plain_primitive_image_;
+
template <typename Exact> struct image_morpher_;
template <typename Exact> struct single_image_morpher_;
template <typename Exact> struct multiple_image_morpher_;
@@ -66,6 +70,12 @@
};
template <typename Exact>
+ struct super_trait_< internal::plain_primitive_image_<Exact> >
+ {
+ typedef internal::primitive_image_<Exact> ret;
+ };
+
+ template <typename Exact>
struct super_trait_< internal::image_morpher_<Exact> >
{
typedef internal::image_base_<Exact> ret;
@@ -100,12 +110,8 @@
// FIXME: Uncomment below!
// typedef stc::abstract output;
- typedef stc::abstract data;
- // FIXME: Temporary hack:
- typedef mlc::none qiter;
- typedef mlc::none fwd_qiter;
- typedef mlc::none bkd_qiter;
+ typedef stc::abstract data;
// Deferred.
@@ -119,8 +125,7 @@
typedef stc::final< stc_type(point__, grid) > grid;
typedef stc::final< typename pset__::fwd_piter > fwd_piter;
typedef stc::final< typename pset__::bkd_piter > bkd_piter;
- typedef stc::final< fwd_piter > piter;
-
+ typedef fwd_piter piter;
};
@@ -130,6 +135,17 @@
};
template <typename Exact>
+ struct vtypes< internal::plain_primitive_image_<Exact> >
+ {
+ typedef stc_deferred(point) point__;
+
+ typedef stc::final< point__ > psite;
+ typedef stc::final< dpoints_fwd_piter_<point__> > fwd_qiter;
+ typedef stc::final< dpoints_bkd_piter_<point__> > bkd_qiter;
+ typedef fwd_qiter qiter;
+ };
+
+ template <typename Exact>
struct vtypes< internal::image_morpher_<Exact> >
{
typedef stc::abstract delegatee;
@@ -185,6 +201,16 @@
};
+ /// plain_primitive_image_<Exact>
+
+ template <typename Exact>
+ class plain_primitive_image_ : public primitive_image_<Exact>
+ {
+ protected:
+ plain_primitive_image_();
+ };
+
+
/// image_morpher_<Exact>
template <typename Exact>
@@ -261,6 +287,13 @@
{
}
+ /// plain_primitive_image_<Exact>
+
+ template <typename Exact>
+ plain_primitive_image_<Exact>::plain_primitive_image_()
+ {
+ }
+
// image_morpher_<Exact>
template <typename Exact>
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Extend image selectors and add image2d type.
* core/concept/image.hh (doc): New.
(Fast_Image): New.
(Random_Accessible_Image, Random_Mutable_Image): Merge into
Fast_Image.
* core/concept/point_set.hh (include): Update.
* core/concept/point.hh: Likewise.
* core/2d/array2d.hh (include): Remove abstract/array.
(array2d): Rename as...
(array2d_): ...this.
(imin, jmin, imax, jmax, buffer, ncells): New methods.
* core/2d/image2d.hh: Update.
* core/2d/image2d_b.hh: New.
* core/2d/grid2d.hh (Grid_2D): New.
(grid2d_rec, grid2d_hex, grid2d_tri): New.
* core/equipment.hh (ch_value, output): New.
* core/gen/box.hh: Fix.
* core/internal/image_selectors.hh: Update.
* core/internal/image_base.hh (qiter, fwd_qiter, bkd_qiter): New.
* stc/scoop.hh (stc_get_type_, stc_get_type, stc_is_a): New.
core/2d/array2d.hh | 132 ++++++++++++++++++++--------
core/2d/grid2d.hh | 75 +++++++++++++---
core/2d/image2d.hh | 178 +++++++++++++++++++++------------------
core/2d/image2d_b.hh | 50 +++++-----
core/concept/image.hh | 141 +++++++++++++++++++++---------
core/concept/point.hh | 1
core/concept/point_set.hh | 3
core/equipment.hh | 4
core/gen/box.hh | 4
core/internal/image_base.hh | 7 +
core/internal/image_selectors.hh | 72 ++++++++++++++-
stc/scoop.hh | 11 ++
12 files changed, 471 insertions(+), 207 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 853)
+++ oln/core/concept/image.hh (working copy)
@@ -29,9 +29,74 @@
#ifndef OLN_CORE_CONCEPT_IMAGE_HH
# define OLN_CORE_CONCEPT_IMAGE_HH
+# include <cstddef>
# include <oln/core/equipment.hh>
+/*
+
+
+Image
+ |
+ |
+ |
+ o -- Mutable_Image
+ | |
+ | + -- Fast_Image
+ |
+ |
+ |
+ o -- + -- Image_1D
+ | |
+ | + -- Image_2D
+ | | |
+ | | + -- Image_2D_rec
+ | | |
+ | | + -- Image_2D_hex
+ | | |
+ | | + -- Image_2D_tri
+ | |
+ | + -- Image_3D
+ |
+ |
+ |
+ o -- Point_Wise_Accessible_Image
+ | |
+ | | Image_2D
+ | | |
+ | | |
+ | + -- Point_Wise_Accessible_Image_2D
+ | | |
+ | | | Mutable_Image
+ | | | |
+ | | | |
+ | | + -- Point_Wise_Mutable_Image_2D
+ | |
+ | + ...
+ |
+ |
+ |
+ o -- + -- Gray_Level_Image
+ | |
+ | + -- Color_Image
+ | |
+ | + -- Label_Image
+ | | |
+ | | + -- Binary_Image
+ | | |
+ | | + -- String_Image
+ | |
+ | + -- Deformation_Field_Image
+ | |
+ | + -- Data_Image
+ |
+ |
+ |
+ ...
+
+*/
+
+
namespace oln
{
@@ -57,6 +122,8 @@
stc_typename(box);
stc_typename(pset);
+ // stc_typename(output); // FIXME: Uncomment!
+
bool owns_(const psite& p) const;
rvalue operator()(const psite& p) const;
@@ -99,55 +166,42 @@
};
- /// Concept-class "Point_Wise_Accessible_Image".
+ /// Concept-class "Fast_Image".
template <typename Exact>
- struct Point_Wise_Accessible_Image : public virtual Image<Exact>,
- public automatic::get_impl<Point_Wise_Accessible_Image, Exact>
- {
- stc_using_from(Image, point);
-
- stc_typename(qiter);
- stc_typename(fwd_qiter);
- stc_typename(bkd_qiter);
- bool has(const point& p) const;
-
- protected:
- Point_Wise_Accessible_Image();
- };
-
-
- /// Concept-class "Random_Accessible_Image".
-
- template <typename Exact>
- struct Random_Accessible_Image : public virtual Image<Exact>,
- public automatic::get_impl<Random_Accessible_Image, Exact>
+ struct Fast_Image : public virtual Mutable_Image<Exact>,
+ public automatic::get_impl<Fast_Image, Exact>
{
stc_using_from(Image, rvalue);
+ stc_using_from(Image, lvalue);
stc_typename(index);
+
rvalue operator[](index i) const;
+ lvalue operator[](index i);
+ std::size_t npoints() const;
+ // FIXME: ...
protected:
- Random_Accessible_Image();
+ Fast_Image();
};
- /// Concept-class "Random_Mutable_Image".
+ /// Concept-class "Point_Wise_Accessible_Image".
template <typename Exact>
- struct Random_Mutable_Image : public virtual Random_Accessible_Image<Exact>,
- public virtual Mutable_Image<Exact>,
- public automatic::get_impl<Random_Mutable_Image, Exact>
+ struct Point_Wise_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Point_Wise_Accessible_Image, Exact>
{
- stc_using_from(Random_Accessible_Image, index);
- stc_using_from(Mutable_Image, lvalue);
- using Random_Accessible_Image<Exact>::operator[];
+ stc_using_from(Image, point);
- lvalue operator[](index i);
+ stc_typename(qiter);
+ stc_typename(fwd_qiter);
+ stc_typename(bkd_qiter);
+ bool has(const point& p) const;
protected:
- Random_Mutable_Image();
+ Point_Wise_Accessible_Image();
};
@@ -352,31 +406,31 @@
{
}
- // ----------------------------------- Random_Accessible_Image<Exact>
+ // ----------------------------------- Fast_Image<Exact>
template <typename Exact>
- typename Random_Accessible_Image<Exact>::rvalue
- Random_Accessible_Image<Exact>::operator[](typename Random_Accessible_Image<Exact>::index i) const
+ typename Fast_Image<Exact>::rvalue
+ Fast_Image<Exact>::operator[](typename Fast_Image<Exact>::index i) const
{
return exact(this)->impl_index_read(p);
}
template <typename Exact>
- Random_Accessible_Image<Exact>::Random_Accessible_Image()
+ typename Fast_Image<Exact>::lvalue
+ Fast_Image<Exact>::operator[](typename Fast_Image<Exact>::index i)
{
+ return exact(this)->impl_index_read_write(p);
}
- // ----------------------------------- Random_Mutable_Image<Exact>
-
template <typename Exact>
- typename Random_Mutable_Image<Exact>::lvalue
- Random_Mutable_Image<Exact>::operator[](typename Random_Accessible_Image<Exact>::index i)
+ std::size_t
+ Fast_Image<Exact>::npoints() const
{
- return exact(this)->impl_index_read_write(p);
+ return exact(this)->impl_npoints(p);
}
template <typename Exact>
- Random_Mutable_Image<Exact>::Random_Mutable_Image()
+ Fast_Image<Exact>::Fast_Image()
{
}
@@ -483,6 +537,11 @@
return this->at(p);
}
+ template <typename Exact>
+ Point_Wise_Mutable_Image_2D<Exact>::Point_Wise_Mutable_Image_2D()
+ {
+ }
+
# endif
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 853)
+++ oln/core/concept/point_set.hh (working copy)
@@ -29,8 +29,7 @@
# define OLN_CORE_CONCEPT_POINT_SET_HH
# include <ostream>
-# include <oln/core/equipment.hh>
-# include <oln/core/point.hh>
+# include <oln/core/concept/point.hh>
namespace oln
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 853)
+++ oln/core/concept/point.hh (working copy)
@@ -30,7 +30,6 @@
# define OLN_CORE_CONCEPT_POINT_HH
# include <mlc/value.hh>
-# include <oln/core/equipment.hh>
# include <oln/core/concept/operators.hh>
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 853)
+++ oln/core/2d/array2d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2003, 2004, 2006 EPITA Research and Development
-// Laboratory
+// Copyright (C) 2001, 2003, 2004, 2006, 2007 EPITA Research and
+// Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,39 +31,49 @@
# include <cstddef>
# include <mlc/contract.hh>
-# include <oln/core/abstract/array.hh>
namespace oln
{
/// General 2D array class.
- template <typename value_t, typename coord_t = int>
- class array2d : public abstract::array
+
+ template <typename T, typename C = int>
+ class array2d_
{
public:
/// Ctor.
- array2d(coord_t imin, coord_t jmin, coord_t imax, coord_t jmax);
+ array2d_(C imin, C jmin, C imax, C jmax);
+
/// Ctor.
- array2d(coord_t ilen, coord_t jlen);
+ array2d_(C ilen, C jlen);
/// Dtor.
- ~array2d();
+ ~array2d_();
- value_t operator()(coord_t i, coord_t j) const;
- value_t& operator()(coord_t i, coord_t j);
+ const T& operator()(C i, C j) const;
+ T& operator()(C i, C j);
- bool has(coord_t i, coord_t j) const;
+ bool has(C i, C j) const;
std::size_t memsize() const;
+ std::size_t ncells() const;
+
+ C imin() const;
+ C jmin() const;
+ C imax() const;
+ C jmax() const;
+
+ const T* buffer() const;
+ T* buffer();
protected:
- coord_t imin_, jmin_, imax_, jmax_;
- coord_t ilen_, jlen_;
- value_t* buffer_;
- value_t** array_;
+ C imin_, jmin_, imax_, jmax_;
+ C ilen_, jlen_;
+ T* buffer_;
+ T** array_;
private:
@@ -75,9 +85,8 @@
# ifndef OLN_INCLUDE_ONLY
- template <typename value_t, typename coord_t>
- array2d<value_t, coord_t>::array2d(coord_t imin, coord_t jmin,
- coord_t imax, coord_t jmax) :
+ template <typename T, typename C>
+ array2d_<T, C>::array2d_(C imin, C jmin, C imax, C jmax) :
imin_(imin),
jmin_(jmin),
imax_(imax),
@@ -89,8 +98,8 @@
allocate_();
}
- template <typename value_t, typename coord_t>
- array2d<value_t, coord_t>::array2d(coord_t ilen, coord_t jlen) :
+ template <typename T, typename C>
+ array2d_<T, C>::array2d_(C ilen, C jlen) :
imin_(0),
jmin_(0),
ilen_(ilen),
@@ -102,52 +111,95 @@
allocate_();
}
- template <typename value_t, typename coord_t>
- array2d<value_t, coord_t>::~array2d()
+ template <typename T, typename C>
+ array2d_<T, C>::~array2d_()
{
deallocate_();
}
- template <typename value_t, typename coord_t>
- value_t array2d<value_t, coord_t>::operator()(coord_t i, coord_t j) const
+ template <typename T, typename C>
+ const T& array2d_<T, C>::operator()(C i, C j) const
{
precondition(has(i, j));
return array_[i][j];
}
- template <typename value_t, typename coord_t>
- value_t& array2d<value_t, coord_t>::operator()(coord_t i, coord_t j)
+ template <typename T, typename C>
+ T& array2d_<T, C>::operator()(C i, C j)
{
precondition(has(i, j));
return array_[i][j];
}
- template <typename value_t, typename coord_t>
- bool array2d<value_t, coord_t>::has(coord_t i, coord_t j) const
+ template <typename T, typename C>
+ bool array2d_<T, C>::has(C i, C j) const
{
return
i >= imin_ and i <= imax_ and
j >= jmin_ and j <= jmax_;
}
- template <typename value_t, typename coord_t>
- size_t array2d<value_t, coord_t>::memsize() const
+
+ template <typename T, typename C>
+ C array2d_<T, C>::imin() const
+ {
+ return imin_;
+ }
+
+ template <typename T, typename C>
+ C array2d_<T, C>::jmin() const
+ {
+ return jmin_;
+ }
+
+ template <typename T, typename C>
+ C array2d_<T, C>::imax() const
+ {
+ return imax_;
+ }
+
+ template <typename T, typename C>
+ C array2d_<T, C>::jmax() const
+ {
+ return jmax_;
+ }
+
+ template <typename T, typename C>
+ const T* array2d_<T, C>::buffer() const
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ T* array2d_<T, C>::buffer()
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ std::size_t array2d_<T, C>::ncells() const
+ {
+ return std::size_t(ilen_) * std::size_t(jlen_);
+ }
+
+ template <typename T, typename C>
+ std::size_t array2d_<T, C>::memsize() const
{
return
// buffer_
- size_t(ilen_) * size_t(jlen_) * sizeof(value_t)
+ std::size_t(ilen_) * std::size_t(jlen_) * sizeof(T)
+
// array_
- size_t(ilen_) * sizeof(value_t*);
+ std::size_t(ilen_) * sizeof(T*);
}
- template <typename value_t, typename coord_t>
- void array2d<value_t, coord_t>::allocate_()
+ template <typename T, typename C>
+ void array2d_<T, C>::allocate_()
{
- buffer_ = new value_t[size_t(ilen_) * size_t(jlen_)];
- array_ = new value_t*[size_t(ilen_)];
- value_t* buf = buffer_ - jmin_;
- for (coord_t i = 0; i < ilen_; ++i)
+ buffer_ = new T[std::size_t(ilen_) * std::size_t(jlen_)];
+ array_ = new T*[std::size_t(ilen_)];
+ T* buf = buffer_ - jmin_;
+ for (C i = 0; i < ilen_; ++i)
{
array_[i] = buf;
buf += jlen_;
@@ -155,8 +207,8 @@
array_ -= imin_;
}
- template <typename value_t, typename coord_t>
- void array2d<value_t, coord_t>::deallocate_()
+ template <typename T, typename C>
+ void array2d_<T, C>::deallocate_()
{
precondition(buffer_ != 0 and array_ != 0);
delete[] buffer_;
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 853)
+++ oln/core/2d/image2d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
+// Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,79 +29,77 @@
#ifndef OLN_CORE_2D_IMAGE2D_HH
# define OLN_CORE_2D_IMAGE2D_HH
-# include <oln/core/image_entry.hh>
-# include <oln/core/gen/grid.hh>
-# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/image_base.hh>
# include <oln/core/2d/array2d.hh>
-# include <oln/core/2d/point2d.hh>
-# include <oln/core/2d/topo2d.hh>
-// For fwd_piter and bkd_piter virtual types.
-# include <oln/core/iterator_vtypes.hh>
+# include <oln/core/2d/box2d.hh>
namespace oln
{
- // Forward declaration.
+ // Fwd decl.
template <typename T> class image2d;
- /// Virtual types associated to oln::image2d<T>.
+ /// Virtual types.
template <typename T>
struct vtypes< image2d<T> >
{
- typedef topo2d topo_type;
+ typedef point2d point;
+ typedef point psite;
- typedef point2d point_type;
+ typedef int coord;
+ typedef unsigned index;
- typedef mlc::false_ is_computed_type;
- typedef T value_type;
- typedef T& lvalue_type;
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box2d pset;
+ typedef array2d_<value, coord> data;
};
- /// Super type declaration.
+ /// Super type.
template <typename T>
- struct set_super_type< image2d<T> >
+ struct super_trait_< image2d<T> >
{
- typedef image2d<T> self_t;
- typedef image_entry<self_t> ret;
+ typedef image2d<T> current;
+ typedef internal::image_base_<current> ret;
};
/// General 2D image class.
+
template <typename T>
- class image2d : public image_entry< image2d<T> >
+ class image2d : public internal::image_base_< image2d<T> >
{
- typedef image2d<T> self_t;
- typedef array2d<T> array_t;
-
+ typedef image2d<T> current;
+ typedef internal::image_base_<current> super;
public:
+ stc_using(data);
- /// Ctor without info.
image2d();
+ image2d(const box2d& b);
+ image2d(unsigned nrows, unsigned ncols);
- /// Ctor using sizes.
- image2d(unsigned nrows, unsigned ncols, unsigned border = 2);
+ bool impl_owns_(const point2d& p) const;
- /// Ctor using an existing topology.
- image2d(const topo2d& topo);
+ bool impl_has(const point2d& p) const;
+ bool impl_has_at(int row, int col) const;
- const topo2d& impl_topo() const;
+ const T& impl_read(const point2d& p) const;
+ const T& impl_index_read(unsigned i) const;
+ const T& impl_at(int row, int col) const;
- T impl_op_read(const point2d& p) const;
- T impl_at(int row, int col) const;
-
- T& impl_op_readwrite(const point2d& p);
+ T& impl_read_write(const point2d& p);
+ T& impl_index_read_write(unsigned i);
T& impl_at(int row, int col);
- T* adr_at(int row, int col);
- const T* adr_at(int row, int col) const;
-
- private:
+ std::size_t npoints() const;
- topo2d topo_;
- internal::tracked_ptr<array_t> data_;
+ box2d impl_bbox() const;
+ box2d impl_points() const;
};
@@ -110,86 +108,110 @@
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)),
- border),
- data_(new array_t(0 - border, 0 - border,
- nrows - 1 + border, ncols - 1 + border))
+ image2d<T>::image2d(const box2d& b)
{
+ this->data_ = new data(b.pmin().row(), b.pmin().col(),
+ b.pmax().row(), b.pmax().col());
}
template <typename T>
- image2d<T>::image2d(const topo2d& topo)
- : topo_(topo),
- data_(new array_t(topo.bbox().pmin().row(),
- topo.bbox().pmin().col(),
- topo.bbox().pmax().row(),
- topo.bbox().pmax().col()))
+ image2d<T>::image2d(unsigned nrows, unsigned ncols)
{
+ precondition(nrows != 0 and ncols != 0);
+ this->data_ = new data(0, 0, nrows - 1, ncols - 1);
}
+ template <typename T>
+ bool image2d<T>::impl_owns_(const point2d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->has(p.row(), p.col());
+ }
template <typename T>
- const topo2d& image2d<T>::impl_topo() const
+ bool image2d<T>::impl_has(const point2d& p) const
{
- return topo_;
+ assert(this->has_data());
+ return this->data_->has(p.row(), p.col());
}
+ template <typename T>
+ bool image2d<T>::impl_has_at(int row, int col) const
+ {
+ assert(this->has_data());
+ return this->data_->has(row, col);
+ }
template <typename T>
- T image2d<T>::impl_op_read(const point2d& p) const
+ const T& image2d<T>::impl_read(const point2d& p) const
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
+ assert(this->has_data());
+ return this->data_->operator()(p.row(), p.col());
}
template <typename T>
- T image2d<T>::impl_at(int row, int col) const
+ const T& image2d<T>::impl_index_read(unsigned i) const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return data_->operator()(row, col);
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->buffer()[i];
}
+ template <typename T>
+ const T& image2d<T>::impl_at(int row, int col) const
+ {
+ assert(this->has_data());
+ return this->data_->operator()(row, col);
+ }
+
+ template <typename T>
+ T& image2d<T>::impl_read_write(const point2d& p)
+ {
+ assert(this->has_data());
+ return this->data_->operator()(p.row(), p.col());
+ }
template <typename T>
- T& image2d<T>::impl_op_readwrite(const point2d& p)
+ T& image2d<T>::impl_index_read_write(unsigned i)
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.row(), p.col());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->buffer()[i];
}
template <typename T>
T& image2d<T>::impl_at(int row, int col)
{
- precondition(data_->has(row, col));
- return data_->operator()(row, col);
+ assert(this->has_data());
+ return this->data_->operator()(row, col);
}
+ template <typename T>
+ std::size_t image2d<T>::npoints() const
+ {
+ assert(this->has_data());
+ return this->data_->ncells();
+ }
template <typename T>
- T* image2d<T>::adr_at(int row, int col)
+ box2d image2d<T>::impl_bbox() const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return &(data_->operator()(row, col));
+ assert(this->has_data());
+ point2d
+ pmin(this->data_->imin(), this->data_->jmin()),
+ pmax(this->data_->imax(), this->data_->jmax());
+ box2d b(pmin, pmax);
+ return b;
}
template <typename T>
- const T* image2d<T>::adr_at(int row, int col) const
+ box2d image2d<T>::impl_points() const
{
- precondition(data_ != 0);
- precondition(data_->has(row, col));
- return &(data_->operator()(row, col));
+ return this->bbox();
}
# endif
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 850)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
+// Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -26,8 +26,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_2D_IMAGE2D_HH
-# define OLN_CORE_2D_IMAGE2D_HH
+#ifndef OLN_CORE_2D_IMAGE2D_B_HH
+# define OLN_CORE_2D_IMAGE2D_B_HH
# include <oln/core/image_entry.hh>
# include <oln/core/gen/grid.hh>
@@ -43,12 +43,12 @@
{
// Forward declaration.
- template <typename T> class image2d;
+ template <typename T> class image2d_b;
- /// Virtual types associated to oln::image2d<T>.
+ /// Virtual types associated to oln::image2d_b<T>.
template <typename T>
- struct vtypes< image2d<T> >
+ struct vtypes< image2d_b<T> >
{
typedef topo2d topo_type;
@@ -62,30 +62,30 @@
/// Super type declaration.
template <typename T>
- struct set_super_type< image2d<T> >
+ struct set_super_type< image2d_b<T> >
{
- typedef image2d<T> self_t;
+ typedef image2d_b<T> self_t;
typedef image_entry<self_t> ret;
};
/// General 2D image class.
template <typename T>
- class image2d : public image_entry< image2d<T> >
+ class image2d_b : public image_entry< image2d_b<T> >
{
- typedef image2d<T> self_t;
+ typedef image2d_b<T> self_t;
typedef array2d<T> array_t;
public:
/// Ctor without info.
- image2d();
+ image2d_b();
/// Ctor using sizes.
- image2d(unsigned nrows, unsigned ncols, unsigned border = 2);
+ image2d_b(unsigned nrows, unsigned ncols, unsigned border = 2);
/// Ctor using an existing topology.
- image2d(const topo2d& topo);
+ image2d_b(const topo2d& topo);
const topo2d& impl_topo() const;
@@ -109,14 +109,14 @@
# ifndef OLN_INCLUDE_ONLY
template <typename T>
- image2d<T>::image2d()
+ image2d_b<T>::image2d_b()
: topo_(),
data_()
{
}
template <typename T>
- image2d<T>::image2d(unsigned nrows, unsigned ncols, unsigned border)
+ image2d_b<T>::image2d_b(unsigned nrows, unsigned ncols, unsigned border)
: topo_(bbox2d(point2d(0, 0 ),
point2d(nrows - 1, ncols - 1)),
border),
@@ -126,7 +126,7 @@
}
template <typename T>
- image2d<T>::image2d(const topo2d& topo)
+ image2d_b<T>::image2d_b(const topo2d& topo)
: topo_(topo),
data_(new array_t(topo.bbox().pmin().row(),
topo.bbox().pmin().col(),
@@ -137,14 +137,14 @@
template <typename T>
- const topo2d& image2d<T>::impl_topo() const
+ const topo2d& image2d_b<T>::impl_topo() const
{
return topo_;
}
template <typename T>
- T image2d<T>::impl_op_read(const point2d& p) const
+ T image2d_b<T>::impl_op_read(const point2d& p) const
{
precondition(data_ != 0);
precondition(topo_.has_large(p));
@@ -152,7 +152,7 @@
}
template <typename T>
- T image2d<T>::impl_at(int row, int col) const
+ T image2d_b<T>::impl_at(int row, int col) const
{
precondition(data_ != 0);
precondition(data_->has(row, col));
@@ -161,7 +161,7 @@
template <typename T>
- T& image2d<T>::impl_op_readwrite(const point2d& p)
+ T& image2d_b<T>::impl_op_readwrite(const point2d& p)
{
precondition(data_ != 0);
precondition(topo_.has_large(p));
@@ -169,7 +169,7 @@
}
template <typename T>
- T& image2d<T>::impl_at(int row, int col)
+ T& image2d_b<T>::impl_at(int row, int col)
{
precondition(data_->has(row, col));
return data_->operator()(row, col);
@@ -177,7 +177,7 @@
template <typename T>
- T* image2d<T>::adr_at(int row, int col)
+ T* image2d_b<T>::adr_at(int row, int col)
{
precondition(data_ != 0);
precondition(data_->has(row, col));
@@ -185,7 +185,7 @@
}
template <typename T>
- const T* image2d<T>::adr_at(int row, int col) const
+ const T* image2d_b<T>::adr_at(int row, int col) const
{
precondition(data_ != 0);
precondition(data_->has(row, col));
@@ -198,4 +198,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_2D_IMAGE2D_HH
+#endif // ! OLN_CORE_2D_IMAGE2D_B_HH
Index: oln/core/2d/grid2d.hh
--- oln/core/2d/grid2d.hh (revision 853)
+++ oln/core/2d/grid2d.hh (working copy)
@@ -35,33 +35,82 @@
namespace oln
{
- struct grid2d;
+ /// \{
+ /// Fwd decls.
- /// Super type.
- template<>
- struct super_trait_< grid2d >
+ template <typename Exact> struct Grid_2D;
+ struct grid2d_rec;
+ struct grid2d_hex;
+ struct grid2d_tri;
+
+ /// \}
+
+
+ /// \{
+ /// Grid_2D.
+
+ template <typename Exact>
+ struct vtypes< Grid_2D<Exact> >
{
- typedef Grid< grid2d > ret;
+ typedef mlc::uint_<2> dim;
};
+ template <typename Exact>
+ struct Grid_2D : public Grid<Exact>
+ {
+ protected:
+ Grid_2D() {}
+ };
+
+ /// \}
+
+
+ /// \{
+ /// Super types.
- /// Virtual types.
template <>
- struct vtypes< grid2d >
+ struct super_trait_< grid2d_rec >
{
- typedef mlc::uint_<2> dim;
+ typedef Grid_2D< grid2d_rec > ret;
};
+ template<>
+ struct super_trait_< grid2d_hex >
+ {
+ typedef Grid_2D< grid2d_hex > ret;
+ };
- /// Rectangular grid class.
- class grid2d : public Grid< grid2d >
+ template<>
+ struct super_trait_< grid2d_tri >
{
- public:
- /// Ctor.
- grid2d() {}
+ typedef Grid_2D< grid2d_tri > ret;
};
+ /// \}
+
+
+
+
+ /// Rectangular grid struct.
+
+ struct grid2d_rec : public Grid_2D< grid2d_rec >
+ {};
+
+ typedef grid2d_rec grid2d; // for short
+
+
+ /// Hexagonal grid struct.
+
+ struct grid2d_hex : public Grid_2D< grid2d_hex >
+ {};
+
+
+ /// Triangular grid struct.
+
+ struct grid2d_tri : public Grid_2D< grid2d_tri >
+ {};
+
} // end of namespace oln
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 853)
+++ oln/core/equipment.hh (working copy)
@@ -47,6 +47,7 @@
// c
stc_decl_associated_type( coord );
+ stc_decl_associated_type( ch_value );
// d
stc_decl_associated_type( data );
@@ -73,6 +74,9 @@
stc_decl_associated_type( nbh );
stc_decl_associated_type( niter );
+ // o
+ stc_decl_associated_type( output );
+
// p
stc_decl_associated_type( piter );
stc_decl_associated_type( point );
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 853)
+++ oln/core/gen/box.hh (working copy)
@@ -240,7 +240,7 @@
box_<P>::pmin() const
{
for (unsigned i = 0; i < n; ++i)
- invariant(pmin[i] <= pmax[i]);
+ invariant(this->pmin_[i] <= this->pmax_[i]);
return this->pmin_;
}
@@ -249,7 +249,7 @@
box_<P>::pmax() const
{
for (unsigned i = 0; i < n; ++i)
- invariant(pmax[i] >= pmin[i]);
+ invariant(this->pmax_[i] >= this->pmin_[i]);
return this->pmax_;
}
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 853)
+++ oln/core/internal/image_selectors.hh (working copy)
@@ -29,6 +29,7 @@
# define OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
# include <oln/core/concept/image.hh>
+# include <oln/core/2d/grid2d.hh>
namespace oln
@@ -43,24 +44,85 @@
typedef selector<Image, 1> Image_mutability;
template <typename Exact>
- struct case_< Image_mutability, Exact, 1 > : where_< stc_type_is_found(lvalue) >
+ struct case_< Image_mutability, Exact, 1 >
+ :
+ where_< stc_type_is_found(lvalue) >
{
typedef Mutable_Image<Exact> ret;
};
+ template <typename Exact>
+ struct case_< Image_mutability, Exact, 2 >
+ :
+ where_< mlc::and_< stc_type_is_found(lvalue),
+ stc_type_is_found(index) > >
+ {
+ typedef Fast_Image<Exact> ret;
+ };
+
+
+ // 2. dimension
+
+ typedef selector<Image, 2> Image_dimension;
+
+ template <typename Exact>
+ struct case_< Image_dimension, Exact, 1 >
+ :
+ where_< stc_is_a(grid, Grid_2D) >
+ {
+ typedef Image_2D<Exact> ret;
+ };
+
+ // FIXME: ...
+
+
+ // 3. point-wise accessibility
+
+ typedef selector<Image, 3> Image_pw_accessibility;
- // 2. point-wise accessibility
+ template <typename Exact>
+ struct case_< Image_pw_accessibility, Exact, 1 >
+ :
+ where_< mlc::and_list_< mlc::eq_< stc_get_type(psite), stc_get_type(point) >,
+ stc_type_is_found(lvalue),
+ stc_is_a(grid, Grid_2D) > >
+ {
+ typedef Point_Wise_Mutable_Image_2D<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct case_< Image_pw_accessibility, Exact, 2 >
+ :
+ where_< mlc::and_< mlc::eq_< stc_get_type(psite), stc_get_type(point) >,
+ stc_is_a(grid, Grid_2D) > >
+ {
+ typedef Point_Wise_Accessible_Image_2D<Exact> ret;
+ };
- typedef selector<Image, 2> Image_pw_accessibility;
+ // FIXME: ...
template <typename Exact>
- struct case_< Image_pw_accessibility, Exact, 1 > : where_< mlc::eq_< stc_type(Exact, psite),
- stc_type(Exact, point) > >
+ struct default_case_< Image_pw_accessibility, Exact >
+ :
+ where_< mlc::eq_< stc_get_type(psite), stc_get_type(point) > >
{
typedef Point_Wise_Accessible_Image<Exact> ret;
};
+ // 4. nbh
+
+ typedef selector<Image, 4> Image_nbh;
+
+ template <typename Exact>
+ struct case_< Image_nbh, Exact, 1 >
+ :
+ where_< stc_type_is_found(nbh) >
+ {
+ typedef Image_with_Nbh<Exact> ret;
+ };
+
+
} // end of namespace oln::internal
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 853)
+++ oln/core/internal/image_base.hh (working copy)
@@ -98,8 +98,15 @@
typedef stc::abstract value;
typedef stc::abstract rvalue;
+ // FIXME: Uncomment below!
+ // typedef stc::abstract output;
typedef stc::abstract data;
+ // FIXME: Temporary hack:
+ typedef mlc::none qiter;
+ typedef mlc::none fwd_qiter;
+ typedef mlc::none bkd_qiter;
+
// Deferred.
typedef stc_deferred(point) point__;
Index: oln/stc/scoop.hh
--- oln/stc/scoop.hh (revision 853)
+++ oln/stc/scoop.hh (working copy)
@@ -99,6 +99,11 @@
# define stc_type_(From, Type) vtype<From, typedef_::Type>::ret
# define stc_type(From, Type) typename stc_type_(From, Type)
+# define stc_get_type_(Type) vtype<Exact, typedef_::Type>::ret
+# define stc_get_type(Type) typename stc_get_type_(Type)
+
+// FIXME: Swap name of stc_type and stc_get_type?
+
// below the more tolerant version is used, namely stc_deferred,
// yet it sometimes can be replaced by "stc_find_type(E, Name)"
@@ -111,6 +116,11 @@
+# define stc_is_a(T, U) \
+mlc::wrap_< \
+ typename mlc::is_a_< sizeof(mlc::form::of< U >()) >::template ret< typename mlc::basic_< stc_deferred(T) >::ret, U > \
+>
+
@@ -134,6 +144,7 @@
+
// the macro below was called stc_prop which was ambiguous
// (that lets us think that it is true_ or false_) but the
// result is a mlc::bexpr_!
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update image concepts and add single_value_image.
* core/abstract/image.hh: Rename as...
* core/concept/image.hh: ...this.
Update.
Add some code from files in core/abstract/image/.
* core/image_entry.hh: Rename as...
* core/internal/image_base.hh: ...this.
Update.
Add some code from files in core/internal/.
* core/gen/image_pset_piter.hh,
* core/gen/single_value_image.hh,
* core/internal/utils.hh,
* core/internal/image_selectors.hh: New.
* core/topology_entry.hh: Remove this residue.
* core/concept/point_set.hh (has): Fix typo.
* core/concept/point.hh (oln/core/concept/operators):
Include.
* core/equipment.hh: Update.
* stc/scoop.hxx (internal::top): Rename as...
(internal::top__): ...this to disambiguate.
core/concept/image.hh | 498 +++++++++++++++++++++++++++++----------
core/concept/point.hh | 1
core/concept/point_set.hh | 3
core/equipment.hh | 23 +
core/gen/image_pset_piter.hh | 252 +++++++++++++++++++
core/gen/single_value_image.hh | 162 ++++++++++++
core/internal/image_base.hh | 297 +++++++++++++++++++----
core/internal/image_selectors.hh | 70 +++++
core/internal/utils.hh | 74 +++++
stc/scoop.hxx | 14 -
10 files changed, 1222 insertions(+), 172 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 845)
+++ oln/core/concept/image.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,197 +26,461 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_IMAGE_HH
-# define OLN_CORE_ABSTRACT_IMAGE_HH
+#ifndef OLN_CORE_CONCEPT_IMAGE_HH
+# define OLN_CORE_CONCEPT_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>
+# include <oln/core/equipment.hh>
namespace oln
{
- // Fwd decl.
- static unsigned& current_image_id();
+ /// Concept-class "Image".
+
+ template <typename Exact>
+ struct Image : public virtual Any<Exact>,
+ public automatic::get_impl<Image, Exact>
+ {
+ stc_typename(grid);
+
+ stc_typename(point);
+ stc_typename(psite);
+
+ stc_typename(value);
+ stc_typename(rvalue);
+
+ stc_typename(piter);
+ stc_typename(fwd_piter);
+ stc_typename(bkd_piter);
+
+ stc_typename(box);
+ stc_typename(pset);
+
+ bool owns_(const psite& p) const;
+ rvalue operator()(const psite& p) const;
+
+ box bbox() const;
+ pset points() const;
+
+ protected:
+ Image();
+ };
+
+
+ /// Concept-class "Image_with_Nbh".
+
+ template <typename Exact>
+ struct Image_with_Nbh : public virtual Image<Exact>,
+ public automatic::get_impl<Image_with_Nbh, Exact>
+ {
+ stc_typename(nbh);
+ nbh nbhood() const;
+
+ protected:
+ Image_with_Nbh();
+ };
+
+ /// Concept-class "Mutable_Image".
+ template <typename Exact>
+ struct Mutable_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Mutable_Image, Exact>
+ {
+ stc_using_from(Image, psite);
+ using Image<Exact>::operator();
- /*! \namespace oln::abstract
- ** \brief oln::abstract namespace.
- */
- namespace abstract {
+ stc_typename(lvalue);
+ lvalue operator()(const psite& p);
+
+ protected:
+ Mutable_Image();
+ };
- /*! \class abstract::image<E>
- **
- ** The abstract::image class is the base class from whom derives
- ** every concrete image class. Basically, an image is a set of
- ** points and a set of values associated with those points.
- **
- ** Parameter E is the exact type of image.
- */
+ /// Concept-class "Point_Wise_Accessible_Image".
+ template <typename Exact>
+ struct Point_Wise_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Point_Wise_Accessible_Image, Exact>
+ {
+ stc_using_from(Image, point);
+
+ stc_typename(qiter);
+ stc_typename(fwd_qiter);
+ stc_typename(bkd_qiter);
+ bool has(const point& p) const;
- template <typename E>
- struct image : public virtual stc::any__simple<E>,
- public virtual oln::type,
- public automatic::get_impl<image, E>
+ protected:
+ Point_Wise_Accessible_Image();
+ };
+
+
+ /// Concept-class "Random_Accessible_Image".
+
+ template <typename Exact>
+ struct Random_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Random_Accessible_Image, Exact>
{
+ stc_using_from(Image, rvalue);
+
+ stc_typename(index);
+ rvalue operator[](index i) const;
+
+ protected:
+ Random_Accessible_Image();
+ };
+
- public:
+ /// Concept-class "Random_Mutable_Image".
- struct decl
+ template <typename Exact>
+ struct Random_Mutable_Image : public virtual Random_Accessible_Image<Exact>,
+ public virtual Mutable_Image<Exact>,
+ public automatic::get_impl<Random_Mutable_Image, Exact>
+ {
+ stc_using_from(Random_Accessible_Image, index);
+ stc_using_from(Mutable_Image, lvalue);
+ using Random_Accessible_Image<Exact>::operator[];
+
+ lvalue operator[](index i);
+
+ protected:
+ Random_Mutable_Image();
+ };
+
+
+ /// Concept-class "Value_Wise_Accessible_Image".
+
+ template <typename Exact>
+ struct Value_Wise_Accessible_Image : public virtual Image<Exact>,
+ public automatic::get_impl<Value_Wise_Accessible_Image, Exact>
+ {
+ stc_typename(vsite);
+ stc_typename(rvaluep);
+ rvaluep value(const vsite& v) const;
+
+ protected:
+ Value_Wise_Accessible_Image();
+ };
+
+
+ /// Concept-class "Value_Wise_Mutable_Image".
+
+ template <typename Exact>
+ struct Value_Wise_Mutable_Image : public virtual Value_Wise_Accessible_Image<Exact>,
+ public automatic::get_impl<Value_Wise_Mutable_Image, Exact>
{
- oln_virtual_typedef(topo);
- oln_virtual_typedef(grid);
- oln_virtual_typedef(coord);
- oln_virtual_typedef(psite);
- oln_virtual_typedef(point);
+ stc_using_from(Value_Wise_Accessible_Image, vsite);
+ using Value_Wise_Accessible_Image<Exact>::value;
+
+ stc_typename(lvaluep);
+ lvaluep value(const vsite& v);
+
+ protected:
+ Value_Wise_Mutable_Image();
+ };
- // FIXME: Rec?
- oln_virtual_typedef(fwd_piter);
- oln_virtual_typedef(bkd_piter);
- oln_virtual_typedef(is_computed);
- oln_virtual_typedef(value);
- oln_virtual_typedef(rvalue);
+ /// Concept-class "Image_1D".
- oln_virtual_typedef(morpher);
+ template <typename Exact>
+ struct Image_1D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_1D, Exact>
+ {
+ stc_typename(coord);
- decl();
+ protected:
+ Image_1D();
};
- public:
- /*------------------*
- ! abstract methods !
- *------------------*/
+ /// Concept-class "Image_2D".
- /*! \brief Return the topological information about the current
- ** image. Nota bene: this method is abstract-like.it is a
- ** pseudo-abstract method.
- **
- ** \return An object deriving from abstract::topo. Ex: if the
- ** image is an image2d<something>, the returned object is a
- ** topo2d.
- */
+ template <typename Exact>
+ struct Image_2D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_2D, Exact>
+ {
+ stc_typename(coord);
- const oln_topo(E)& topo() const;
+ protected:
+ Image_2D();
+ };
- /*! \brief Gives access to the value stored at \a p in the
- ** current image.
- */
+ /// Concept-class "Image_3D".
- oln_rvalue(E) operator()(const oln_psite(E)& p) const;
+ template <typename Exact>
+ struct Image_3D : public virtual Image<Exact>,
+ public automatic::get_impl<Image_3D, Exact>
+ {
+ stc_typename(coord);
+
+ protected:
+ Image_3D();
+ };
- unsigned id() const;
+
+ /// Concept-class "Point_Wise_Accessible_Image_2D".
+
+ template <typename Exact>
+ struct Point_Wise_Accessible_Image_2D : public virtual Point_Wise_Accessible_Image<Exact>,
+ public virtual Image_2D<Exact>,
+ public automatic::get_impl<Point_Wise_Accessible_Image_2D, Exact>
+ {
+ stc_using_from(Point_Wise_Accessible_Image, point);
+ stc_using_from(Point_Wise_Accessible_Image, rvalue);
+ stc_using_from(Image_2D, coord);
+
+ bool has_at(coord row, coord col) const;
+ rvalue at(coord row, coord col) const;
+
+ // default
+ bool impl_has_at(coord row, coord col) const;
+ rvalue impl_at(coord row, coord col) const;
protected:
+ Point_Wise_Accessible_Image_2D();
+ };
+
- /*! \brief Constructors (protected).
- */
- image();
- image(const image& rhs);
+ /// Concept-class "Point_Wise_Mutable_Image_2D".
- /*! \brief Assignment (protected).
- */
- E& operator=(const image& rhs);
+ template <typename Exact>
+ struct Point_Wise_Mutable_Image_2D : public virtual Point_Wise_Accessible_Image_2D<Exact>,
+ public virtual Mutable_Image<Exact>,
+ public automatic::get_impl<Point_Wise_Mutable_Image_2D, Exact>
+ {
+ stc_using_from(Point_Wise_Accessible_Image_2D, point);
+ stc_using_from(Point_Wise_Accessible_Image_2D, coord);
+ stc_using_from(Mutable_Image, lvalue);
+ using Point_Wise_Accessible_Image_2D<Exact>::at;
- /*! \brief Destructor.
- */
- virtual ~image();
+ lvalue at(coord row, coord col);
- private:
+ // default
+ lvalue impl_at(coord row, coord col);
- unsigned id_;
+ protected:
+ Point_Wise_Mutable_Image_2D();
};
+
+
+
+
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- image<E>::decl::decl()
+ // ----------------------------------- Image<Exact>
+
+ template <typename Exact>
+ bool
+ Image<Exact>::owns_(const typename Image<Exact>::psite& p) const
{
- // FIXME: Rec?
- mlc::assert_< mlc_is_a(topo, abstract::topology) >::check();
- mlc::assert_< mlc_is_a(grid, abstract::grid) >::check();
- mlc::assert_< mlc_is_a(point, abstract::point) >::check();
- mlc::assert_< mlc_is_a(fwd_piter, abstract::iterator_on_points) >::check();
- mlc::assert_< mlc_is_a(bkd_piter, abstract::iterator_on_points) >::check();
+ return exact(this)->impl_owns_(p);
+ }
- // FIXME: Rec?
- // mlc::assert_< mlc_is_a(plain, abstract::image) >::check();
+ template <typename Exact>
+ typename Image<Exact>::rvalue
+ Image<Exact>::operator()(const typename Image<Exact>::psite& p) const
+ {
+ precondition(this->owns_(p));
+ return exact(this)->impl_read(p);
}
- template <typename E>
- image<E>::image()
- : id_(++current_image_id())
+ template <typename Exact>
+ typename Image<Exact>::box
+ Image<Exact>::bbox() const
{
- ++debug::n_images;
+ return exact(this)->impl_bbox();
}
- template <typename E>
- image<E>::image(const image& rhs)
- : id_(rhs.id_)
+ template <typename Exact>
+ typename Image<Exact>::pset
+ Image<Exact>::points() const
{
- ++debug::n_images;
+ return exact(this)->impl_points();
}
- template <typename E>
- E& image<E>::operator=(const image<E>& rhs)
+ template <typename Exact>
+ Image<Exact>::Image()
{
- this->id_ = rhs.id_;
- return this->exact();
}
- template <typename E>
- image<E>::~image()
+ // ----------------------------------- Image_with_Nbh<Exact>
+
+ template <typename Exact>
+ typename Image_with_Nbh<Exact>::nbh
+ Image_with_Nbh<Exact>::nbhood() const
{
- decl();
- --debug::n_images;
+ return exact(this)->impl_nbhood();
}
- template <typename E>
- unsigned
- image<E>::id() const
+ template <typename Exact>
+ Image_with_Nbh<Exact>::Image_with_Nbh()
{
- return id_;
}
- template <typename E>
- const oln_topo(E)&
- image<E>::topo() const
+ // ----------------------------------- Mutable_Image<Exact>
+
+ template <typename Exact>
+ typename Mutable_Image<Exact>::lvalue
+ Mutable_Image<Exact>::operator()(const typename Mutable_Image<Exact>::psite& p)
{
- return this->exact().impl_topo();
+ precondition(this->owns_(p));
+ return exact(this)->impl_read_write(p);
}
- template <typename E>
- oln_rvalue(E)
- image<E>::operator()(const oln_psite(E)& p) const
+ template <typename Exact>
+ Mutable_Image<Exact>::Mutable_Image()
{
- return this->exact().impl_op_read(p);
}
-# endif
+ // ----------------------------------- Point_Wise_Accessible_Image<Exact>
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image<Exact>::has(const typename Point_Wise_Accessible_Image<Exact>::point& p) const
+ {
+ return exact(this)->impl_has(p);
+ }
+ template <typename Exact>
+ Point_Wise_Accessible_Image<Exact>::Point_Wise_Accessible_Image()
+ {
+ }
- } // end of namespace oln::abstract
+ // ----------------------------------- Random_Accessible_Image<Exact>
+
+ template <typename Exact>
+ typename Random_Accessible_Image<Exact>::rvalue
+ Random_Accessible_Image<Exact>::operator[](typename Random_Accessible_Image<Exact>::index i) const
+ {
+ return exact(this)->impl_index_read(p);
+ }
+ template <typename Exact>
+ Random_Accessible_Image<Exact>::Random_Accessible_Image()
+ {
+ }
+ // ----------------------------------- Random_Mutable_Image<Exact>
-# ifndef OLN_INCLUDE_ONLY
+ template <typename Exact>
+ typename Random_Mutable_Image<Exact>::lvalue
+ Random_Mutable_Image<Exact>::operator[](typename Random_Accessible_Image<Exact>::index i)
+ {
+ return exact(this)->impl_index_read_write(p);
+ }
+
+ template <typename Exact>
+ Random_Mutable_Image<Exact>::Random_Mutable_Image()
+ {
+ }
+
+ // ----------------------------------- Value_Wise_Accessible_Image<Exact>
+
+ template <typename Exact>
+ typename Value_Wise_Accessible_Image<Exact>::rvaluep
+ Value_Wise_Accessible_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v) const
+ {
+ return exact(this)->impl_value_read(v);
+ }
+
+ template <typename Exact>
+ Value_Wise_Accessible_Image<Exact>::Value_Wise_Accessible_Image()
+ {
+ }
+
+ // ----------------------------------- Value_Wise_Mutable_Image<Exact>
+
+ template <typename Exact>
+ typename Value_Wise_Mutable_Image<Exact>::lvaluep
+ Value_Wise_Mutable_Image<Exact>::value(const typename Value_Wise_Accessible_Image<Exact>::vsite& v)
+ {
+ return exact(this)->impl_value_read_write(p);
+ }
+
+ template <typename Exact>
+ Value_Wise_Mutable_Image<Exact>::Value_Wise_Mutable_Image()
+ {
+ }
+
+ // ----------------------------------- Image_1D<Exact>
+
+ template <typename Exact>
+ Image_1D<Exact>::Image_1D()
+ {
+ }
+
+ // ----------------------------------- Image_2D<Exact>
+
+ template <typename Exact>
+ Image_2D<Exact>::Image_2D()
+ {
+ }
+
+ // ----------------------------------- Image_3D<Exact>
+
+ template <typename Exact>
+ Image_3D<Exact>::Image_3D()
+ {
+ }
+
+ // ----------------------------------- Point_Wise_Accessible_Image_2D<Exact>
+
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image_2D<Exact>::has_at(coord row, coord col) const
+ {
+ return exact(this)->impl_has_at(row, col);
+ }
+
+ template <typename Exact>
+ typename Point_Wise_Accessible_Image_2D<Exact>::rvalue
+ Point_Wise_Accessible_Image_2D<Exact>::at(coord row, coord col) const
+ {
+ return exact(this)->impl_at(row, col);
+ }
+
+ template <typename Exact>
+ bool
+ Point_Wise_Accessible_Image_2D<Exact>::impl_has_at(coord row, coord col) const
+ {
+ Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ return this->has(p);
+ }
+
+ template <typename Exact>
+ typename Point_Wise_Accessible_Image_2D<Exact>::rvalue
+ Point_Wise_Accessible_Image_2D<Exact>::impl_at(coord row, coord col) const
+ {
+ Point_Wise_Accessible_Image_2D<Exact>::point p(row, col);
+ return this->at(p);
+ }
+
+ template <typename Exact>
+ Point_Wise_Accessible_Image_2D<Exact>::Point_Wise_Accessible_Image_2D()
+ {
+ }
+
+ // ----------------------------------- Point_Wise_Mutable_Image_2D<Exact>
+
+ template <typename Exact>
+ typename Point_Wise_Mutable_Image_2D<Exact>::lvalue
+ Point_Wise_Mutable_Image_2D<Exact>::at(coord row, coord col)
+ {
+ return exact(this)->impl_at(row, col);
+ }
- static unsigned& current_image_id()
+ template <typename Exact>
+ typename Point_Wise_Mutable_Image_2D<Exact>::lvalue
+ Point_Wise_Mutable_Image_2D<Exact>::impl_at(coord row, coord col)
{
- static unsigned id_ = 0;
- return id_;
+ Point_Wise_Mutable_Image_2D<Exact>::point p(row, col);
+ return this->at(p);
}
# endif
@@ -225,4 +489,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_IMAGE_HH
+#endif // ! OLN_CORE_CONCEPT_IMAGE_HH
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 849)
+++ oln/core/concept/point_set.hh (working copy)
@@ -30,6 +30,7 @@
# include <ostream>
# include <oln/core/equipment.hh>
+# include <oln/core/point.hh>
namespace oln
@@ -77,7 +78,7 @@
bool
Point_Set<Exact>::has(const typename Point_Set<Exact>::point& p) const
{
- return exact(this)->impl_has();
+ return exact(this)->impl_has(p);
}
template <typename Exact>
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 849)
+++ oln/core/concept/point.hh (working copy)
@@ -31,6 +31,7 @@
# include <mlc/value.hh>
# include <oln/core/equipment.hh>
+# include <oln/core/concept/operators.hh>
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 849)
+++ oln/core/equipment.hh (working copy)
@@ -40,35 +40,58 @@
# include <oln/stc/scoop.hxx> // FIXME: Remove "oln/" later.
// b
+ stc_decl_associated_type( bkd_niter );
stc_decl_associated_type( bkd_piter );
+ stc_decl_associated_type( bkd_qiter );
stc_decl_associated_type( box );
+
// c
stc_decl_associated_type( coord );
+
// d
stc_decl_associated_type( data );
stc_decl_associated_type( dim );
stc_decl_associated_type( dpoint );
+
// f
+ stc_decl_associated_type( fwd_niter );
stc_decl_associated_type( fwd_piter );
+ stc_decl_associated_type( fwd_qiter );
+
// g
stc_decl_associated_type( grid );
+
// i
stc_decl_associated_type( index );
+
// l
stc_decl_associated_type( lvalue );
+ stc_decl_associated_type( lvaluep );
+
// n
stc_decl_associated_type( n );
+ stc_decl_associated_type( nbh );
+ stc_decl_associated_type( niter );
+
// p
stc_decl_associated_type( piter );
stc_decl_associated_type( point );
stc_decl_associated_type( pset );
stc_decl_associated_type( psite );
+
+ // q
+ stc_decl_associated_type( qiter );
+
// r
stc_decl_associated_type( rvalue );
+ stc_decl_associated_type( rvaluep );
+
// s
stc_decl_associated_type( std_container );
+
// v
stc_decl_associated_type( value );
+ stc_decl_associated_type( vsite );
} // end of namespace oln
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 0)
+++ oln/core/gen/single_value_image.hh (revision 0)
@@ -0,0 +1,162 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_SINGLE_VALUE_IMAGE_HH
+# define OLN_CORE_GEN_SINGLE_VALUE_IMAGE_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/utils.hh>
+
+
+namespace oln
+{
+
+
+ // Fwd decl.
+ template <typename Ps, typename T> class single_value_image;
+
+
+ /// Virtual types.
+ template <typename Ps, typename T>
+ struct vtypes< single_value_image<Ps, T> >
+ {
+ typedef typename Ps::point point;
+ typedef point psite;
+ typedef Ps pset;
+
+ typedef T value;
+ typedef const T& rvalue;
+
+ typedef internal::pair<Ps, T> data;
+
+ // FIXME: To be defined...
+ typedef mlc::none qiter;
+ typedef mlc::none fwd_qiter;
+ typedef mlc::none bkd_qiter;
+ };
+
+
+ /// Super type.
+ template <typename Ps, typename T>
+ struct super_trait_< single_value_image<Ps, T> >
+ {
+ typedef single_value_image<Ps, T> current;
+ typedef internal::primitive_image_<current> ret;
+ };
+
+
+ /// Class for images defined by a point set and a single value.
+
+ template <typename Ps, typename T>
+ class single_value_image : public internal::image_base_< single_value_image<Ps, T> >
+ {
+ typedef single_value_image<Ps, T> current;
+ typedef internal::image_base_<current> super;
+ public:
+
+
+ stc_using(point);
+ stc_using(rvalue);
+ stc_using(data);
+
+ single_value_image();
+
+ single_value_image(const Ps& ps, const T& val);
+
+ bool impl_owns_(const point& p) const;
+ bool impl_has (const point& p) const;
+
+ rvalue impl_read(const point&) const;
+
+ const Ps& impl_points() const;
+
+ void change_value(const T& new_value);
+
+ }; // end of single_value_image<Ps, T>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Ps, typename T>
+ single_value_image<Ps, T>::single_value_image()
+ {
+ }
+
+ template <typename Ps, typename T>
+ single_value_image<Ps, T>::single_value_image(const Ps& pts,
+ const T& val)
+ {
+ this->data_ = new data(pts, val);
+ }
+
+ template <typename Ps, typename T>
+ bool
+ single_value_image<Ps, T>::impl_owns_(const typename single_value_image<Ps, T>::point& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p);
+ }
+
+ template <typename Ps, typename T>
+ bool
+ single_value_image<Ps, T>::impl_has(const typename single_value_image<Ps, T>::point& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p);
+ }
+
+ template <typename Ps, typename T>
+ typename single_value_image<Ps, T>::rvalue
+ single_value_image<Ps, T>::impl_read(const typename single_value_image<Ps, T>::point&) const
+ {
+ assert(this->has_data());
+ return this->data_->value2;
+ }
+
+ template <typename Ps, typename T>
+ const Ps&
+ single_value_image<Ps, T>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->value1;
+ }
+
+ template <typename Ps, typename T>
+ void
+ single_value_image<Ps, T>::change_value(const T& new_value)
+ {
+ assert(this->has_data());
+ this->data_->value2 = new_value;
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_SINGLE_VALUE_IMAGE_HH
Index: oln/core/gen/image_pset_piter.hh
--- oln/core/gen/image_pset_piter.hh (revision 0)
+++ oln/core/gen/image_pset_piter.hh (revision 0)
@@ -0,0 +1,252 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_GEN_IMAGE_PSET_PITER_HH
+# define OLN_CORE_GEN_IMAGE_PSET_PITER_HH
+
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/concept/point_set.hh>
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ /// Fwd decls.
+
+ template <typename Ps> struct image_pset_fwd_piter_;
+ template <typename Ps> struct image_pset_bkd_piter_;
+
+
+ /// Super types.
+
+ template <typename Ps>
+ struct super_trait_< image_pset_fwd_piter_<Ps> >
+ {
+ typedef image_pset_fwd_piter_<Ps> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+ template <typename Ps>
+ struct super_trait_< image_pset_bkd_piter_<Ps> >
+ {
+ typedef image_pset_bkd_piter_<Ps> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+
+ /// Virtual types.
+
+ template <typename Ps>
+ struct vtypes< image_pset_fwd_piter_<Ps> >
+ {
+ typedef typename Ps::point point;
+ };
+
+ template <typename Ps>
+ struct vtypes< image_pset_bkd_piter_<Ps> >
+ {
+ typedef typename Ps::point point;
+ };
+
+
+ /// Class image_pset_fwd_piter_<Ps>.
+
+ template <typename Ps>
+ class image_pset_fwd_piter_ : public Iterator_on_Points< image_pset_fwd_piter_<Ps> >,
+ private mlc::assert_< mlc_is_a(Ps, Point_Set) >
+ {
+ typedef image_pset_fwd_piter_<Ps> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+
+ stc_using(point);
+
+ image_pset_fwd_piter_();
+
+ template <typename I>
+ image_pset_fwd_piter_(const Image<I>& ima);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+ typename Ps::fwd_piter i_;
+ };
+
+
+ /// Class image_pset_bkd_piter_<Ps>.
+
+ template <typename Ps>
+ class image_pset_bkd_piter_ : public Iterator_on_Points< image_pset_bkd_piter_<Ps> >,
+ private mlc::assert_< mlc_is_a(Ps, Point_Set) >
+ {
+ typedef image_pset_fwd_piter_<Ps> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+
+ stc_using(point);
+
+ image_pset_bkd_piter_();
+
+ template <typename I>
+ image_pset_bkd_piter_(const Image<I>& ima);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+ typename Ps::bkd_piter i_;
+ };
+
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ // -------------------- image_pset_fwd_piter_<Ps>
+
+
+ template <typename Ps>
+ image_pset_fwd_piter_<Ps>::image_pset_fwd_piter_()
+ {
+ }
+
+ template <typename Ps>
+ template <typename I>
+ image_pset_fwd_piter_<Ps>::image_pset_fwd_piter_(const Image<I>& ima)
+ : i_(ima.points())
+ {
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_start()
+ {
+ i_.start();
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_next()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ void image_pset_fwd_piter_<Ps>::impl_invalidate()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ bool image_pset_fwd_piter_<Ps>::impl_is_valid() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename Ps>
+ typename image_pset_fwd_piter_<Ps>::point
+ image_pset_fwd_piter_<Ps>::impl_to_point() const
+ {
+ return i_;
+ }
+
+ template <typename Ps>
+ const typename image_pset_fwd_piter_<Ps>::point*
+ image_pset_fwd_piter_<Ps>::impl_point_adr() const
+ {
+ return i_.point_adr();
+ }
+
+
+ // -------------------- image_pset_bkd_piter_<Ps>
+
+
+ template <typename Ps>
+ image_pset_bkd_piter_<Ps>::image_pset_bkd_piter_()
+ {
+ }
+
+ template <typename Ps>
+ template <typename I>
+ image_pset_bkd_piter_<Ps>::image_pset_bkd_piter_(const Image<I>& ima)
+ : i_(ima.points())
+ {
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_start()
+ {
+ i_.start();
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_next()
+ {
+ i_.next();
+ }
+
+ template <typename Ps>
+ void image_pset_bkd_piter_<Ps>::impl_invalidate()
+ {
+ i_.invalidate();
+ }
+
+ template <typename Ps>
+ bool image_pset_bkd_piter_<Ps>::impl_is_valid() const
+ {
+ return i_.is_valid();
+ }
+
+ template <typename Ps>
+ typename image_pset_bkd_piter_<Ps>::point
+ image_pset_bkd_piter_<Ps>::impl_to_point() const
+ {
+ return i_;
+ }
+
+ template <typename Ps>
+ const typename image_pset_bkd_piter_<Ps>::point*
+ image_pset_bkd_piter_<Ps>::impl_point_adr() const
+ {
+ return i_.point_adr();
+ }
+
+# endif
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_IMAGE_PSET_PITER_HH
Index: oln/core/internal/image_selectors.hh
--- oln/core/internal/image_selectors.hh (revision 0)
+++ oln/core/internal/image_selectors.hh (revision 0)
@@ -0,0 +1,70 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
+# define OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
+
+# include <oln/core/concept/image.hh>
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+
+ // 1. mutability
+
+ typedef selector<Image, 1> Image_mutability;
+
+ template <typename Exact>
+ struct case_< Image_mutability, Exact, 1 > : where_< stc_type_is_found(lvalue) >
+ {
+ typedef Mutable_Image<Exact> ret;
+ };
+
+
+ // 2. point-wise accessibility
+
+ typedef selector<Image, 2> Image_pw_accessibility;
+
+ template <typename Exact>
+ struct case_< Image_pw_accessibility, Exact, 1 > : where_< mlc::eq_< stc_type(Exact, psite),
+ stc_type(Exact, point) > >
+ {
+ typedef Point_Wise_Accessible_Image<Exact> ret;
+ };
+
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_IMAGE_SELECTORS_HH
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 845)
+++ oln/core/internal/image_base.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,95 +25,298 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_IMAGE_ENTRY_HH
-# define OLN_CORE_IMAGE_ENTRY_HH
+#ifndef OLN_CORE_INTERNAL_IMAGE_BASE_HH
+# define OLN_CORE_INTERNAL_IMAGE_BASE_HH
-# include <oln/core/abstract/entry.hh>
-# include <oln/core/abstract/image/all.hh>
-
-# include <oln/core/type_fun/plain.hh>
+# include <oln/core/internal/image_selectors.hh>
+# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/utils.hh>
+# include <oln/core/gen/box.hh>
+# include <oln/core/gen/image_pset_piter.hh>
namespace oln
{
- /// Fwd decl.
- template <typename E> struct image_entry;
+ /// Fwd decls.
+
+ namespace internal
+ {
+ template <typename Exact> struct image_base_;
+ template <typename Exact> struct primitive_image_;
+ template <typename Exact> struct image_morpher_;
+ template <typename Exact> struct single_image_morpher_;
+ template <typename Exact> struct multiple_image_morpher_;
+ }
+
+
+ /// Super types.
+
+ template <typename Exact>
+ struct super_trait_< internal::image_base_<Exact> >
+ {
+ typedef top<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct super_trait_< internal::primitive_image_<Exact> >
+ {
+ typedef internal::image_base_<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct super_trait_< internal::image_morpher_<Exact> >
+ {
+ typedef internal::image_base_<Exact> ret;
+ };
+ template <typename Exact>
+ struct super_trait_< internal::single_image_morpher_<Exact> >
+ {
+ typedef internal::image_morpher_<Exact> ret;
+ };
- template <typename E>
- struct set_super_type< image_entry<E> >
+ template <typename Exact>
+ struct super_trait_< internal::multiple_image_morpher_<Exact> >
{
- typedef mlc::none ret;
+ typedef internal::image_morpher_<Exact> ret;
};
- /// Virtual types associated to image_entry<E>.
+ /// Virtual types.
- template <typename E>
- struct vtypes< image_entry<E> >
+ template <typename Exact>
+ struct vtypes< internal::image_base_<Exact> >
{
- typedef stc::abstract topo_type;
+ // Abstract.
+
+ typedef stc::abstract point;
+ typedef stc::abstract psite;
+ typedef stc::abstract pset;
+
+ typedef stc::abstract value;
+ typedef stc::abstract rvalue;
+
+ typedef stc::abstract data;
+
+ // Deferred.
+
+ typedef stc_deferred(point) point__;
+ typedef stc_deferred(pset) pset__;
+
+ // Final.
+
+ typedef stc::final< stc::is<Image> > category;
+ typedef stc::final< box_<point__> > box;
+ typedef stc::final< stc_type(point__, grid) > grid;
+ typedef stc::final< typename pset__::fwd_piter > fwd_piter;
+ typedef stc::final< typename pset__::bkd_piter > bkd_piter;
+ typedef stc::final< fwd_piter > piter;
+
+ };
+
+
+ template <typename Exact>
+ struct vtypes< internal::primitive_image_<Exact> >
+ {
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::image_morpher_<Exact> >
+ {
+ typedef stc::abstract delegatee;
+ typedef stc::not_delegated data;
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::single_image_morpher_<Exact> >
+ {
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::multiple_image_morpher_<Exact> >
+ {
+ typedef stc::abstract n;
+ };
+
+
+
+ /// Implementation base classes.
+
+
+ namespace internal
+ {
+
+
+ /// image_base_<Exact>
+
+ template <typename Exact>
+ class image_base_ : public top<Exact>
+ {
+ typedef top<Exact> super;
+ public:
+
+ stc_typename(data);
+
+ bool has_data() const;
+
+ protected:
+ image_base_();
+
+ tracked_ptr<data> data_;
+ };
- typedef stc::abstract point_type;
- typedef stc::final<oln_deduce_deferred_vtype(E, point, grid)> grid_type;
- typedef stc::final<oln_deduce_deferred_vtype(E, point, coord)> coord_type;
- typedef stc::abstract is_computed_type;
- typedef stc::abstract value_type;
+ /// primitive_image_<Exact>
- typedef stc::abstract fwd_piter_type;
- typedef stc::abstract bkd_piter_type;
+ template <typename Exact>
+ class primitive_image_ : public image_base_<Exact>
+ {
+ protected:
+ primitive_image_();
+ };
- // FIXME: final definitions:
- typedef oln_fwd_piter(E) piter_type;
- // FIXME: default definitions:
- typedef oln_point(E) psite_type;
-# ifndef OLENA_USE_SCOOP_ALT
- typedef oln_value(E) rvalue_type;
-# endif // !OLENA_USE_SCOOP_ALT
+ /// image_morpher_<Exact>
- /// \brief Morpher type.
- ///
- /// Optionally contains a tag indicating a kind of morpher.
- typedef mlc::none morpher_type;
+ template <typename Exact>
+ class image_morpher_ : public image_base_<Exact>
+ {
+ public:
+
+ stc_typename(delegatee);
+
+ protected:
+ image_morpher_();
};
-# ifdef OLENA_USE_SCOOP_ALT
- template <typename E>
- struct single_vtype< image_entry<E>, typedef_::rvalue_type >
+
+ /// single_image_morpher_<Exact>
+
+ template <typename Exact>
+ class single_image_morpher_ : public image_morpher_<Exact>
{
- typedef oln_value(E) ret;
+ typedef image_morpher_<Exact> super;
+ public:
+ stc_using(delegatee);
+
+ // Abstract.
+ delegatee& image();
+ const delegatee& image() const;
+
+ protected:
+ single_image_morpher_();
};
-# endif // OLENA_USE_SCOOP_ALT
- /// Entry class for point sets: image_entry<E> is an alias for
- /// entry< abstract::image, E>.
+ /// multiple_image_morpher_<Exact>
- template <typename E>
- struct image_entry : public entry<abstract::image, E>
+ template <typename Exact>
+ class multiple_image_morpher_ : public image_morpher_<Exact>
{
+ typedef image_morpher_<Exact> super;
+ public:
+ stc_using(delegatee);
+ stc_typename(n);
+ enum { n_ = mlc_value(n) };
+
+ // Abstract.
+ delegatee& image(unsigned i = 0);
+ const delegatee& image(unsigned i = 0) const;
+
protected:
- image_entry();
+ multiple_image_morpher_();
};
+
+
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- image_entry<E>::image_entry()
+ /// image_base_<Exact>
+
+ template <typename Exact>
+ bool image_base_<Exact>::has_data() const
+ {
+ return this->data_ != 0;
+ }
+
+ template <typename Exact>
+ image_base_<Exact>::image_base_()
+ {
+ }
+
+ /// primitive_image_<Exact>
+
+ template <typename Exact>
+ primitive_image_<Exact>::primitive_image_()
{
}
+ // image_morpher_<Exact>
+
+ template <typename Exact>
+ image_morpher_<Exact>::image_morpher_()
+ {
+ }
+
+ // single_image_morpher_<Exact>
+
+ template <typename Exact>
+ typename single_image_morpher_<Exact>::delegatee&
+ single_image_morpher_<Exact>::image()
+ {
+ precondition(this->has_data());
+ return exact(this)->impl_image();
+ }
+
+ template <typename Exact>
+ const typename single_image_morpher_<Exact>::delegatee&
+ single_image_morpher_<Exact>::image() const
+ {
+ precondition(this->has_data());
+ return exact(this)->impl_image();
+ }
+
+ template <typename Exact>
+ single_image_morpher_<Exact>::single_image_morpher_()
+ {
+ }
+
+ // multiple_image_morpher_<Exact>
+
+ template <typename Exact>
+ typename multiple_image_morpher_<Exact>::delegatee&
+ multiple_image_morpher_<Exact>::image(unsigned i)
+ {
+ precondition(i < n_);
+ precondition(this->has_data());
+ return exact(this)->impl_image(i);
+ }
+
+ template <typename Exact>
+ const typename multiple_image_morpher_<Exact>::delegatee&
+ multiple_image_morpher_<Exact>::image(unsigned i) const
+ {
+ precondition(i < n_);
+ precondition(this->has_data());
+ return exact(this)->impl_image(i);
+ }
+
+ template <typename Exact>
+ multiple_image_morpher_<Exact>::multiple_image_morpher_()
+ {
+ }
+
+
# endif
+ } // end of namespace oln::internal
} // end of namespace oln
-#endif // ! OLN_CORE_IMAGE_ENTRY_HH
+#endif // ! OLN_CORE_INTERNAL_IMAGE_BASE_HH
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 0)
+++ oln/core/internal/utils.hh (revision 0)
@@ -0,0 +1,74 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_UTILS_HH
+# define OLN_CORE_INTERNAL_UTILS_HH
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ /// Simple singleton class.
+
+ template <typename T>
+ struct singleton
+ {
+ singleton()
+ {}
+ singleton(T val)
+ : value(val)
+ {}
+ T value;
+ };
+
+
+ /// Simple pair class.
+
+ template <typename T1, typename T2>
+ struct pair
+ {
+ pair()
+ {}
+ pair(T1 val1, T2 val2)
+ : value1(val1),
+ value2(val2)
+ {}
+ T1 value1;
+ T2 value2;
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_UTILS_HH
+
Index: oln/stc/scoop.hxx
--- oln/stc/scoop.hxx (revision 849)
+++ oln/stc/scoop.hxx (working copy)
@@ -867,22 +867,22 @@
};
template <typename abstraction, typename E>
- struct top;
+ struct top__;
template <template<class> class abstraction, typename E>
- struct top < stc::is<abstraction>, E > : public plug< abstraction, E >
+ struct top__ < stc::is<abstraction>, E > : public plug< abstraction, E >
{
- protected: top() {}
+ protected: top__() {}
};
template <typename E>
- struct top < mlc::none, E > : public Any<E>
+ struct top__ < mlc::none, E > : public Any<E>
{
- protected: top() {}
+ protected: top__() {}
};
template <typename E>
- struct top < mlc::not_found, E >; /* FIXME: Error msg here */
+ struct top__ < mlc::not_found, E >; /* FIXME: Error msg here */
} /* end of namespace internal */
@@ -900,7 +900,7 @@
};
template <typename E>
-struct top : public internal::top< stc_find_type(E, category), E >
+struct top : public internal::top__< stc_find_type(E, category), E >
{
protected:
top() {}
1
0
05 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update some abstractions and remove topology-related classes.
* oln/core/abstract/value.hh: Rename as...
* oln/core/concept/value.hh: ...this and update.
* oln/core/abstract/iterator_on_values.hh: Rename as...
* oln/core/concept/iterator_on_values.hh: ...this and update.
* oln/core/abstract/topology/topology_having_bbox.hh,
* oln/core/abstract/topology/hierarchies.hh,
* oln/core/abstract/topology/all.hh,
* oln/core/abstract/topology/topology_being_random_accessible.hh,
* oln/core/abstract/topology/topology_having_subset.hh,
* oln/core/abstract/topology/topology_having_neighborhood.hh:
Remove.
iterator_on_values.hh | 93 +++++++++++++++-----------------------------------
value.hh | 27 ++++++--------
2 files changed, 41 insertions(+), 79 deletions(-)
Index: oln/core/concept/iterator_on_values.hh
--- oln/core/concept/iterator_on_values.hh (revision 844)
+++ oln/core/concept/iterator_on_values.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,109 +26,72 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
-# define OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
+#ifndef OLN_CORE_CONCEPT_ITERATOR_ON_VALUES_HH
+# define OLN_CORE_CONCEPT_ITERATOR_ON_VALUES_HH
-# include <oln/core/abstract/iterator.hh>
+# include <ostream>
+# include <oln/core/concept/iterator.hh>
namespace oln
{
+ /// Concept-class "Iterator_on_Values".
- // Forward declaration.
- namespace abstract { template <typename E> class iterator_on_values; }
-
-
- // Super type declaration.
- template <typename E>
- struct set_super_type< abstract::iterator_on_values<E> >
- {
- typedef abstract::iterator<E> ret;
- };
-
-
- /// Virtual types associated to abstract::iterator_on_values<E>.
- template <typename E>
- struct vtypes< abstract::iterator_on_values<E> >
- {
- typedef stc::abstract value_type;
- };
-
-
- namespace abstract
+ template <typename Exact>
+ struct Iterator_on_Values : public Iterator<Exact>
{
+ stc_typename(value);
- /// Abstract value iterator class.
- template <typename E>
- class iterator_on_values : public abstract::iterator<E>
- {
- public:
- typedef oln_vtype(E, value) value_type;
-
- value_type to_value() const;
+ value to_value() const;
- // Concrete method.
- operator value_type() const;
+ // Default.
+ operator value() const;
protected:
+ Iterator_on_Values();
- iterator_on_values();
+ }; // end of class oln::Iterator_on_Values<Exact>
- ~iterator_on_values();
- }; // end of class oln::abstract::iterator_on_values<E>
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Values<Exact>& vit);
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr,
- const iterator_on_values<E>& vit);
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- typename iterator_on_values<E>::value_type
- iterator_on_values<E>::to_value() const
+ template <typename Exact>
+ typename Iterator_on_Values<Exact>::value
+ Iterator_on_Values<Exact>::to_value() const
{
precondition(this->is_valid());
- return this->exact().impl_to_value();
+ return exact(this)->impl_to_value();
}
- template <typename E>
- // Concrete method.
- iterator_on_values<E>::operator typename iterator_on_values<E>::value_type() const
+ template <typename Exact>
+ Iterator_on_Values<Exact>::operator typename Iterator_on_Values<Exact>::value() const
{
precondition(this->is_valid());
return this->to_value();
}
- template <typename E>
- iterator_on_values<E>::iterator_on_values()
- {
- }
-
- template <typename E>
- iterator_on_values<E>::~iterator_on_values()
+ template <typename Exact>
+ Iterator_on_Values<Exact>::Iterator_on_Values()
{
- mlc::assert_defined_< typename iterator_on_values<E>::value_type >::check();
}
-
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr,
- const iterator_on_values<E>& vit)
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Values<Exact>& vit)
{
- return ostr << vit.to_value();
+ return ostr << vit.to_point();
}
-
# endif
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_ITERATOR_ON_VALUES_HH
+#endif // ! OLN_CORE_CONCEPT_ITERATOR_ON_VALUES_HH
Index: oln/core/concept/value.hh
--- oln/core/concept/value.hh (revision 844)
+++ oln/core/concept/value.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2005, 2006, 2007 EPITA Research and Development
+// Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,36 +26,34 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_VALUE_HH
-# define OLN_CORE_ABSTRACT_VALUE_HH
+#ifndef OLN_CORE_CONCEPT_VALUE_HH
+# define OLN_CORE_CONCEPT_VALUE_HH
-# include <oln/core/type.hh>
+# include <oln/core/equipment.hh>
-namespace oln {
+namespace oln
+{
- namespace abstract {
+ /// Concept-class "Value".
- // A value is not an oln::type. As a consequence,
- // traits are basically defined.
- struct value
+ template <typename Exact>
+ struct Value : public Any<Exact>
{
protected:
- value();
+ Value();
};
# ifndef OLN_INCLUDE_ONLY
- value::value()
+ Value::Value()
{
}
# endif
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_VALUE_HH
+#endif // ! OLN_CORE_CONCEPT_VALUE_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleaning point set classes.
* oln/core/point_set_entry.hh: Rename as...
* oln/core/internal/point_set_base.hh: ...this and update.
* oln/core/abstract/point_set.hh: Rename as...
* oln/core/concept/point_set.hh: ...this and update.
* oln/core/abstract/iterator.hh: Rename as...
* oln/core/concept/iterator.hh: ...this and update.
* oln/core/abstract/iterator_on_points.hh: Rename as...
* oln/core/concept/iterator_on_points.hh: ...this and update.
* oln/core/abstract/point_set/point_set_being_random_accessible.hh,
* oln/core/abstract/point_set/point_set_having_known_size.hh,
* oln/core/abstract/point_set/hierarchies.hh,
* oln/core/abstract/point_set/all.hh,
* oln/core/abstract/point_set/point_set_being_connected.hh,
* oln/core/abstract/point_set/point_set_having_bbox.hh: Remove.
* oln/core/gen/bbox.hh: Split and rename as...
* oln/core/gen/box.hh: ...this and update...
* oln/core/gen/fbbox.hh: ...and this and update.
* oln/core/gen/bbox_fwd_piter.hh,
* oln/core/gen/bbox_bkd_piter.hh: Remove because merge with...
* oln/core/gen/box.hh: ...this.
* oln/core/gen/pset_.hh: Rename as...
* oln/core/gen/pset.hh: ...this and update.
* oln/core/gen/pset_list.hh: Rename as...
* oln/core/gen/plist.hh: ...this and update.
* oln/core/gen/pset_vec.hh: Rename as...
* oln/core/gen/pvec.hh: ...this and update.
* oln/core/gen/piter_on_std_based_pset.hh: Rename as...
* oln/core/internal/point_set_std_based.hh: ...this and update.
* oln/core/2d/aliases.hh: Update.
* oln/core/equipment.hh: Update.
* oln/core/2d/box2d.hh: New.
2d/aliases.hh | 11 -
2d/box2d.hh | 44 ++++
concept/iterator.hh | 74 ++-----
concept/iterator_on_points.hh | 120 +++--------
concept/point_set.hh | 107 ++++------
equipment.hh | 34 ++-
gen/box.hh | 420 ++++++++++++++++++++++++++--------------
gen/fbbox.hh | 127 ++++++++++++
gen/plist.hh | 149 +++-----------
gen/pset.hh | 129 ++----------
gen/pvec.hh | 144 ++++---------
internal/point_set_base.hh | 72 +++---
internal/point_set_std_based.hh | 343 +++++++++++++++++++++-----------
13 files changed, 951 insertions(+), 823 deletions(-)
Index: oln/core/concept/iterator_on_points.hh
--- oln/core/concept/iterator_on_points.hh (revision 843)
+++ oln/core/concept/iterator_on_points.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,131 +26,79 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_ITERATOR_ON_POINTS_HH
-# define OLN_CORE_ABSTRACT_ITERATOR_ON_POINTS_HH
+#ifndef OLN_CORE_CONCEPT_ITERATOR_ON_POINTS_HH
+# define OLN_CORE_CONCEPT_ITERATOR_ON_POINTS_HH
-# include <oln/core/abstract/iterator.hh>
-# include <oln/core/abstract/point.hh>
+# include <ostream>
+# include <oln/core/concept/iterator.hh>
+# include <oln/core/concept/point.hh>
namespace oln
{
+ /// Concept-class "Iterator_on_Points".
- // Forward declaration.
- namespace abstract { template <typename E> class iterator_on_points; }
-
-
- // Super type declaration.
- template <typename E>
- struct set_super_type< abstract::iterator_on_points<E> >
- {
- typedef abstract::iterator<E> ret;
- };
-
-
- /// Virtual types associated to abstract::iterator_on_points<E>.
- template <typename E>
- struct vtypes< abstract::iterator_on_points<E> >
- {
- typedef stc::abstract point_type;
-# ifndef OLENA_USE_SCOOP_ALT
- typedef oln_deduce_deferred_vtype(E, point, coord) coord_type;
-# endif // !OLENA_USE_SCOOP_ALT
- };
-
-# ifdef OLENA_USE_SCOOP_ALT
- template <typename E>
- struct single_vtype< abstract::iterator_on_points<E>,
- typedef_::coord_type >
- {
- typedef oln_deduce_deferred_vtype(E, point, coord) ret;
- };
-# endif // OLENA_USE_SCOOP_ALT
-
-
- namespace abstract
- {
-
- /// Abstract point iterator class.
- template <typename E>
- class iterator_on_points : public abstract::iterator<E>
+ template <typename Exact>
+ struct Iterator_on_Points : public Iterator<Exact>
{
- typedef oln_point(E) point_t;
+ stc_typename(point);
- public:
+ point to_point() const;
+ const point* point_adr() const;
- point_t to_point() const;
-
- const point_t* point_adr() const;
-
- // Concrete method.
- operator point_t() const;
+ // Default.
+ operator point() const;
protected:
+ Iterator_on_Points();
- iterator_on_points();
-
- ~iterator_on_points();
+ }; // end of class oln::Iterator_on_Points<Exact>
- }; // end of class oln::abstract::iterator_on_points<E>
-
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr, const iterator_on_points<E>& pit);
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Points<Exact>& pit);
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- typename iterator_on_points<E>::point_t
- iterator_on_points<E>::to_point() const
+ template <typename Exact>
+ typename Iterator_on_Points<Exact>::point
+ Iterator_on_Points<Exact>::to_point() const
{
precondition(this->is_valid());
- return this->exact().impl_to_point();
+ return exact(this)->impl_to_point();
}
- template <typename E>
- const typename iterator_on_points<E>::point_t*
- iterator_on_points<E>::point_adr() const
+ template <typename Exact>
+ const typename Iterator_on_Points<Exact>::point*
+ Iterator_on_Points<Exact>::point_adr() const
{
- return this->exact().impl_point_adr();
+ return exact(this)->impl_point_adr();
}
- template <typename E>
- // Concrete method.
- iterator_on_points<E>::operator typename iterator_on_points<E>::point_t() const
+ template <typename Exact>
+ Iterator_on_Points<Exact>::operator typename Iterator_on_Points<Exact>::point() const
{
precondition(this->is_valid());
return this->to_point();
}
- template <typename E>
- iterator_on_points<E>::iterator_on_points()
+ template <typename Exact>
+ Iterator_on_Points<Exact>::Iterator_on_Points()
{
+ mlc::assert_< mlc_is_a(typename Iterator_on_Points<Exact>::point, Point) >::check();
}
- template <typename E>
- iterator_on_points<E>::~iterator_on_points()
- {
- mlc::assert_defined_< typename iterator_on_points<E>::point_t >::check();
- mlc::assert_< mlc_is_a(typename iterator_on_points<E>::point_t, abstract::point) >::check();
- }
-
-
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr, const iterator_on_points<E>& pit)
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const Iterator_on_Points<Exact>& pit)
{
return ostr << pit.to_point();
}
-
# endif
- } // end of namespace oln::abstract
-
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_ITERATOR_ON_POINTS_HH
+#endif // ! OLN_CORE_CONCEPT_ITERATOR_ON_POINTS_HH
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 843)
+++ oln/core/concept/point_set.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,92 +25,89 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_POINT_SET_HH
-# define OLN_CORE_ABSTRACT_POINT_SET_HH
+#ifndef OLN_CORE_CONCEPT_POINT_SET_HH
+# define OLN_CORE_CONCEPT_POINT_SET_HH
-# include <oln/core/typedefs.hh>
+# include <ostream>
+# include <oln/core/equipment.hh>
namespace oln
{
- namespace abstract
- {
-
-
- /// Abstract point class.
- template <typename E>
- class point_set : public virtual stc::any__simple<E>,
- public virtual oln::type
- {
- public:
- bool is_valid() const;
+ /// Concept-class "Point_Set".
- struct decl
+ template <typename Exact>
+ struct Point_Set : public Any<Exact>
{
- oln_virtual_typedef(point);
-
- oln_virtual_typedef(piter);
- oln_virtual_typedef(fwd_piter);
- oln_virtual_typedef(bkd_piter);
-
- oln_virtual_typedef(bbox); // provides .bbox()
- oln_virtual_typedef(is_random_accessible); // provides .has(p)
- oln_virtual_typedef(has_known_size); // provides .npoints()
- oln_virtual_typedef(is_connected); // provides, e.g., .nrows()
-
- // derived from point:
- oln_virtual_typedef(coord);
- oln_virtual_typedef(grid);
- oln_virtual_typedef(dim);
-
- decl();
- };
-
- ~point_set();
+ stc_typename(point);
+ stc_typename(grid);
+ stc_typename(piter);
+ stc_typename(fwd_piter);
+ stc_typename(bkd_piter);
+ stc_typename(box);
+
+ // FIXME: Add coord and dim?
+
+ unsigned npoints() const;
+ bool has(const point& p) const;
+ const box& bbox() const;
protected:
+ Point_Set();
+
+ }; // end of oln::Point_Set<Exact>
- point_set();
- }; // end of class oln::abstract::point_set<E>
+ template <typename Ps>
+ std::ostream& operator<<(std::ostream& ostr, const Point_Set<Ps>& pts);
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool point_set<E>::is_valid() const
+ template <typename Exact>
+ unsigned
+ Point_Set<Exact>::npoints() const
{
- return this->exact().impl_is_valid();
+ return exact(this)->impl_npoints();
}
- template <typename E>
- point_set<E>::decl::decl()
+ template <typename Exact>
+ bool
+ Point_Set<Exact>::has(const typename Point_Set<Exact>::point& p) const
{
- // coherence check:
- // FIXME: Rec?
-// mlc::assert_equal_< oln_grid(fwd_piter), oln_grid(point) >::check();
-// mlc::assert_equal_< oln_grid(bkd_piter), oln_grid(point) >::check();
+ return exact(this)->impl_has();
}
- template <typename E>
- point_set<E>::point_set()
+ template <typename Exact>
+ const typename Point_Set<Exact>::box&
+ Point_Set<Exact>::bbox() const
{
+ return exact(this)->impl_bbox();
}
- template <typename E>
- point_set<E>::~point_set()
+ template <typename Exact>
+ Point_Set<Exact>::Point_Set()
{
- decl();
}
-# endif
+ template <typename Ps>
+ std::ostream& operator<<(std::ostream& ostr, const Point_Set<Ps>& pts)
+ {
+ ostr << "{ ";
+ typename Ps::piter p(pts);
+ for_all(p)
+ ostr << p << ' '; // FIXME: Add ','?
+ return ostr << " }";
+ }
+
+
+# endif
- } // end of namespace oln::abstract
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_POINT_SET_HH
+#endif // ! OLN_CORE_CONCEPT_POINT_SET_HH
Index: oln/core/concept/iterator.hh
--- oln/core/concept/iterator.hh (revision 843)
+++ oln/core/concept/iterator.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,92 +26,74 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_ITERATOR_HH
-# define OLN_CORE_ABSTRACT_ITERATOR_HH
+#ifndef OLN_CORE_CONCEPT_ITERATOR_HH
+# define OLN_CORE_CONCEPT_ITERATOR_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
-namespace oln
-{
-
- namespace abstract { template <typename E> class iterator; }
+/// Macro for_all.
+# define for_all(i) for (i.start(); i.is_valid(); i.next())
- template <typename E>
- struct set_super_type< abstract::iterator<E> >
- {
- typedef mlc::none ret;
- };
- namespace abstract
+namespace oln
{
- /// Abstract iterator class.
- template <typename E>
- class iterator : public stc::any__best_memory<E>,
- public oln::type
- {
- public:
+ /// Concept-class "Iterator".
+ template <typename Exact>
+ struct Iterator : public Any<Exact>
+ {
void start();
-
void next();
-
void invalidate();
-
bool is_valid() const;
protected:
+ Iterator();
- iterator();
-
- }; // end of class oln::abstract::iterator<E>
+ }; // end of class oln::Iterator<Exact>
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- void iterator<E>::start()
+ template <typename Exact>
+ void Iterator<Exact>::start()
{
- this->exact().impl_start();
+ exact(this)->impl_start();
}
- template <typename E>
- void iterator<E>::next()
+ template <typename Exact>
+ void Iterator<Exact>::next()
{
precondition(this->is_valid());
- this->exact().impl_next();
+ exact(this)->impl_next();
}
- template <typename E>
- void iterator<E>::invalidate()
+ template <typename Exact>
+ void Iterator<Exact>::invalidate()
{
- this->exact().impl_invalidate();
+ exact(this)->impl_invalidate();
}
- template <typename E>
- bool iterator<E>::is_valid() const
+ template <typename Exact>
+ bool Iterator<Exact>::is_valid() const
{
- return this->exact().impl_is_valid();
+ return exact(this)->impl_is_valid();
}
- template <typename E>
- iterator<E>::iterator()
+ template <typename Exact>
+ Iterator<Exact>::Iterator()
{
}
# endif
- } // end of namespace oln::abstract
-
-
} // end of namespace oln
-#define for_all(i) for (i.start(); i.is_valid(); i.next())
-
-#endif // ! OLN_CORE_ABSTRACT_ITERATOR_HH
+#endif // ! OLN_CORE_CONCEPT_ITERATOR_HH
Index: oln/core/2d/aliases.hh
--- oln/core/2d/aliases.hh (revision 843)
+++ oln/core/2d/aliases.hh (working copy)
@@ -35,12 +35,8 @@
/// Forward declarations.
/// \{
- template <unsigned D> struct grid_;
- template <typename C> class point2d_;
- template <typename C> class dpoint2d_;
template <typename D> class neighb_;
template <typename D> class window_;
- template <typename P> class bbox_;
template <typename P> class topo_lbbox_;
template <typename P> class fwd_piter_bbox_;
template <typename P> class bkd_piter_bbox_;
@@ -51,15 +47,10 @@
/// Aliases.
/// \{
- typedef grid_<2> grid2d;
-
- typedef point2d_<int> point2d;
- typedef dpoint2d_<int> dpoint2d;
typedef neighb_<dpoint2d> neighb2d;
typedef window_<dpoint2d> window2d;
- typedef bbox_<point2d> bbox2d;
typedef topo_lbbox_<point2d> topo2d;
typedef fwd_piter_bbox_<point2d> fwd_piter2d;
@@ -68,8 +59,6 @@
typedef fwd_qiter_win_<point2d> fwd_qiter2d;
typedef bkd_qiter_win_<point2d> bkd_qiter2d;
- typedef point2d_<float> point2df;
- typedef dpoint2d_<float> dpoint2df;
/// \}
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 0)
+++ oln/core/2d/box2d.hh (revision 0)
@@ -0,0 +1,44 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_2D_BOX2D_HH
+# define OLN_CORE_2D_BOX2D_HH
+
+# include <oln/core/gen/box.hh>
+# include <oln/core/2d/point2d.hh>
+
+
+namespace oln
+{
+
+ typedef box_<point2d> box2d;
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_2D_BOX2D_HH
+
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 843)
+++ oln/core/equipment.hh (working copy)
@@ -39,22 +39,36 @@
# include <oln/stc/scoop.hxx> // FIXME: Remove "oln/" later.
-
- stc_decl_associated_type(grid);
+ // b
+ stc_decl_associated_type( bkd_piter );
+ stc_decl_associated_type( box );
+ // c
stc_decl_associated_type(coord);
+ // d
+ stc_decl_associated_type( data );
stc_decl_associated_type(dim);
- stc_decl_associated_type(point);
stc_decl_associated_type(dpoint);
- stc_decl_associated_type(psite);
+ // f
+ stc_decl_associated_type( fwd_piter );
+ // g
+ stc_decl_associated_type( grid );
+ // i
stc_decl_associated_type(index);
- stc_decl_associated_type(value);
- stc_decl_associated_type(rvalue);
+ // l
stc_decl_associated_type(lvalue);
- stc_decl_associated_type(iter);
- stc_decl_associated_type(data);
- stc_decl_associated_type(box);
- stc_decl_associated_type(pset);
+ // n
stc_decl_associated_type(n);
+ // p
+ stc_decl_associated_type( piter );
+ stc_decl_associated_type( point );
+ stc_decl_associated_type( pset );
+ stc_decl_associated_type( psite );
+ // r
+ stc_decl_associated_type( rvalue );
+ // s
+ stc_decl_associated_type( std_container );
+ // v
+ stc_decl_associated_type( value );
} // end of namespace oln
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 843)
+++ oln/core/gen/box.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2003, 2004, 2005, 2006 EPITA Research and
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,239 +26,385 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_BBOX_HH
-# define OLN_CORE_GEN_BBOX_HH
+#ifndef OLN_CORE_GEN_BOX_HH
+# define OLN_CORE_GEN_BOX_HH
-# include <oln/core/point_set_entry.hh>
-# include <oln/core/abstract/point.hh>
+# include <oln/core/concept/point.hh>
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/internal/point_set_base.hh>
namespace oln
{
// Forward declarations.
- template <typename point_t> class bbox_;
- template <typename point_t> class bbox_fwd_piter_;
- template <typename point_t> class bbox_bkd_piter_;
+ template <typename P> class box_;
+ template <typename P> class box_fwd_piter_;
+ template <typename P> class box_bkd_piter_;
// Super type declaration.
- template <typename point_t>
- struct set_super_type< bbox_<point_t> >
+ template <typename P>
+ struct super_trait_< box_<P> >
{
- typedef bbox_<point_t> self_t;
- typedef point_set_entry<self_t> ret;
+ typedef box_<P> current__;
+ typedef internal::point_set_base_<current__> ret;
};
- /// Virtual types associated to oln::bbox_<point_t>.
- template <typename point_t>
- struct vtypes< bbox_<point_t> >
- {
- typedef point_t point_type;
- typedef bbox_fwd_piter_<point_t> fwd_piter_type;
- typedef bbox_bkd_piter_<point_t> bkd_piter_type;
-
- typedef bbox_<point_t> bbox_type;
-
- typedef mlc::true_ is_random_accessible_type;
- typedef mlc::true_ has_known_size_type;
- typedef mlc::true_ is_connected_type;
+ /// Virtual types associated to oln::box_<P>.
+ template <typename P>
+ struct vtypes< box_<P> >
+ {
+ typedef P point;
+ typedef box_fwd_piter_<P> fwd_piter;
+ typedef box_bkd_piter_<P> bkd_piter;
};
- /// Bounding box class based on a point class.
- template <typename point_t>
- class bbox_ : public point_set_entry< bbox_<point_t> >,
- private mlc::assert_< mlc_is_a(point_t, abstract::point) >
+ /// Generic box class based on a point class.
+
+ template <typename P>
+ class box_ : public internal::point_set_base_< box_<P> >,
+ private mlc::assert_< mlc_is_a(P, Point) >
{
- // Make self_type public so that is can be used to define a
- // virtual type of oln::topo_bbox_ and oln::topo_lbbox_.
+ typedef box_<P> current;
+ typedef internal::point_set_base_<current> super;
public:
- typedef bbox_<point_t> self_type;
+
+ stc_using(point);
+ stc_using(box);
private:
- typedef point_set_entry<self_type> super_t;
+ typedef stc_type(point, dim) dim__;
+ enum { n = mlc_value(dim__) };
- typedef oln_vtype(point_t, coord) coord_t;
+ public:
- typedef oln_vtype(point_t, dim) dim;
- enum { n = mlc_value(dim) };
+ box_();
+ box_(const P& pmin, const P& pmax);
- public:
+ unsigned impl_npoints() const;
+ bool impl_has(const P& p) const;
+ const box_<P>& impl_bbox() const;
- bbox_();
+ const P& pmin() const;
+ P& pmin();
+ const P& pmax() const;
+ P& pmax();
- bbox_(const point_t& pmin, const point_t& pmax);
+ protected:
+ point pmin_, pmax_;
- bbox_(const bbox_<point_t>& rhs);
+ }; // end of class oln::box_<P>
- bbox_<point_t>& operator=(const bbox_<point_t>& rhs);
- unsigned impl_npoints() const;
- bool impl_has(const point_t& p) const;
- void flush();
+ // -------------------- iterators on box_<P>
- void init_with(const point_t& p);
- void update_with(const point_t& p);
- void take(const point_t& p);
- // FIXME: Add "update : (rhs : exact)"
+ /// Super types.
+
+ template <typename P>
+ struct super_trait_< box_fwd_piter_<P> >
+ {
+ typedef box_fwd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+ template <typename P>
+ struct super_trait_< box_bkd_piter_<P> >
+ {
+ typedef box_bkd_piter_<P> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
- bool includes(const bbox_<point_t>& rhs) const;
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< box_fwd_piter_<P> >
+ {
+ typedef P point;
+ };
+
+ template <typename P>
+ struct vtypes< box_bkd_piter_<P> >
+ {
+ typedef P point;
+ };
+
+
+ /// Class box_fwd_piter_<P>.
+
+ template <typename P>
+ class box_fwd_piter_ : public Iterator_on_Points< box_fwd_piter_<P> >,
+ private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ public:
+ box_fwd_piter_();
+ box_fwd_piter_(const Point_Set< box_<P> >& b);
+ void set_box(const box_<P>& b);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
bool impl_is_valid() const;
+ P impl_to_point() const;
+ const P* impl_point_adr() const;
- void impl_print(std::ostream& ostr) const;
+ private:
+ box_<P> b_;
+ P p_, nop_;
+ };
- protected:
- bool is_valid_;
+ /// Class box_bkd_piter_<P>.
+
+ template <typename P>
+ class box_bkd_piter_ : public Iterator_on_Points< box_bkd_piter_<P> >,
+ private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ public:
+ box_bkd_piter_();
+ box_bkd_piter_(const Point_Set< box_<P> >& b);
+ void set_box(const box_<P>& b);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ P impl_to_point() const;
+ const P* impl_point_adr() const;
+
+ private:
+ box_<P> b_;
+ P p_, nop_;
+ };
- }; // end of class oln::bbox_<point_t>
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- bbox_<point_t>::bbox_()
+
+ // -------------------- box_<P>
+
+
+ template <typename P>
+ box_<P>::box_()
{
- flush();
}
- template <typename point_t>
- bbox_<point_t>::bbox_(const point_t& pmin, const point_t& pmax)
+ template <typename P>
+ box_<P>::box_(const P& pmin, const P& pmax)
{
+ for (unsigned i = 0; i < n; ++i)
+ precondition(pmax[i] >= pmin[i]);
this->pmin_ = pmin;
this->pmax_ = pmax;
- is_valid_ = true;
+ }
+ template <typename P>
+ unsigned
+ box_<P>::impl_npoints() const
+ {
+ unsigned count = 1;
for (unsigned i = 0; i < n; ++i)
- precondition(pmax[i] >= pmin[i]);
+ count *= (this->pmax_[i] - this->pmin_[i] + 1);
+ return count;
}
- template <typename point_t>
- bbox_<point_t>::bbox_(const bbox_<point_t>& rhs)
+ template <typename P>
+ bool
+ box_<P>::impl_has(const P& p) const
{
- // FIXME: Remove these 3 lines?
- precondition(rhs.is_valid());
for (unsigned i = 0; i < n; ++i)
- precondition(rhs.pmax_[i] >= rhs.pmin_[i]);
+ if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
+ return false;
+ return true;
+ }
- this->pmin_ = rhs.pmin_;
- this->pmax_ = rhs.pmax_;
- is_valid_ = rhs.is_valid_;
+ template <typename P>
+ const box_<P>&
+ box_<P>::impl_bbox() const
+ {
+ return *this;
+ }
+ template <typename P>
+ const P&
+ box_<P>::pmin() const
+ {
for (unsigned i = 0; i < n; ++i)
- postcondition(this->pmax_[i] >= this->pmin_[i]);
+ invariant(pmin[i] <= pmax[i]);
+ return this->pmin_;
}
- template <typename point_t>
- bbox_<point_t>& bbox_<point_t>::operator=(const bbox_<point_t>& rhs)
+ template <typename P>
+ const P&
+ box_<P>::pmax() const
{
- // FIXME: Remove these 3 lines?
- precondition(rhs.is_valid());
for (unsigned i = 0; i < n; ++i)
- precondition(rhs.pmax_[i] >= rhs.pmin_[i]);
+ invariant(pmax[i] >= pmin[i]);
+ return this->pmax_;
+ }
- this->pmin_ = rhs.pmin_;
- this->pmax_ = rhs.pmax_;
- is_valid_ = rhs.is_valid_;
+ template <typename P>
+ P&
+ box_<P>::pmin()
+ {
+ return this->pmin_;
+ }
- for (unsigned i = 0; i < n; ++i)
- postcondition(this->pmax_[i] >= this->pmin_[i]);
+ template <typename P>
+ P&
+ box_<P>::pmax()
+ {
+ return this->pmax_;
+ }
- return *this;
+
+
+ // -------------------- box_fwd_piter_<P>
+
+
+ template <typename P>
+ box_fwd_piter_<P>::box_fwd_piter_()
+ {
}
- template <typename point_t>
- unsigned bbox_<point_t>::impl_npoints() const
+ template <typename P>
+ box_fwd_piter_<P>::box_fwd_piter_(const Point_Set< box_<P> >& b)
{
- unsigned count = 1;
- for (unsigned i = 0; i < n; ++i)
- count *= this->len(i);
- return count;
+ this->set_box(exact(b));
}
- template <typename point_t>
- bool bbox_<point_t>::impl_has(const point_t& p) const
+ template <typename P>
+ void box_fwd_piter_<P>::set_box(const box_<P>& b)
{
- precondition(is_valid_);
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i])
- return false;
- return true;
+ b_ = b;
+ nop_ = b_.pmax();
+ ++nop_[0];
+ p_ = nop_;
}
- template <typename point_t>
- void bbox_<point_t>::flush()
+ template <typename P>
+ void box_fwd_piter_<P>::impl_start()
{
- is_valid_ = false;
+ p_ = b_.pmin();
}
- template <typename point_t>
- void bbox_<point_t>::init_with(const point_t& p)
+ template <typename P>
+ void box_fwd_piter_<P>::impl_next()
{
- precondition(not is_valid_);
- this->pmin_ = p;
- this->pmax_ = p;
- is_valid_ = true;
+ for (int i = P::n - 1; i >= 0; --i)
+ if (p_[i] = b_.pmax()[i])
+ p_[i] = b_.pmin()[i];
+ else
+ {
+ ++p_[i];
+ break;
+ }
+ if (p_ = b_.pmin())
+ p_ = nop_;
}
- template <typename point_t>
- void bbox_<point_t>::update_with(const point_t& p)
+ template <typename P>
+ void box_fwd_piter_<P>::impl_invalidate()
{
- precondition(is_valid_);
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i])
- this->pmin_[i] = p[i];
- else if (p[i] > this->pmax_[i])
- this->pmax_[i] = p[i];
+ p_ = nop_;
}
- template <typename point_t>
- void bbox_<point_t>::take(const point_t& p)
+ template <typename P>
+ bool box_fwd_piter_<P>::impl_is_valid() const
{
- if (not is_valid_)
+ return p_ != nop_;
+ }
+
+ template <typename P>
+ P box_fwd_piter_<P>::impl_to_point() const
{
- init_with(p);
- return;
+ return p_;
}
- for (unsigned i = 0; i < n; ++i)
- if (p[i] < this->pmin_[i])
- this->pmin_[i] = p[i];
- else if (p[i] > this->pmax_[i])
- this->pmax_[i] = p[i];
+
+ template <typename P>
+ const P* box_fwd_piter_<P>::impl_point_adr() const
+ {
+ return &p_;
}
- template <typename point_t>
- bool bbox_<point_t>::includes(const bbox_<point_t>& rhs) const
+
+
+ // -------------------- box_bkd_piter_<P>
+
+
+ template <typename P>
+ box_bkd_piter_<P>::box_bkd_piter_()
{
- precondition(is_valid_ and rhs.is_valid());
- for (unsigned i = 0; i < n; ++i)
- if (rhs.pmin()[i] < this->pmin_[i] or rhs.pmax()[i] > this->pmax_[i])
- return false;
- return true;
}
- template <typename point_t>
- bool bbox_<point_t>::impl_is_valid() const
+ template <typename P>
+ box_bkd_piter_<P>::box_bkd_piter_(const Point_Set< box_<P> >& b)
+ {
+ this->set_box(exact(b));
+ }
+
+ template <typename P>
+ void box_bkd_piter_<P>::set_box(const box_<P>& b)
+ {
+ b_ = b;
+ nop_ = b_.pmin();
+ --nop_[0];
+ p_ = nop_;
+ }
+
+ template <typename P>
+ void box_bkd_piter_<P>::impl_start()
+ {
+ p_ = b_.pmax();
+ }
+
+ template <typename P>
+ void box_bkd_piter_<P>::impl_next()
+ {
+ for (int i = P::n - 1; i >= 0; --i)
+ if (p_[i] = b_.pmin()[i])
+ p_[i] = b_.pmax()[i];
+ else
+ {
+ --p_[i];
+ break;
+ }
+ if (p_ = b_.pmax())
+ p_ = nop_;
+ }
+
+ template <typename P>
+ void box_bkd_piter_<P>::impl_invalidate()
+ {
+ p_ = nop_;
+ }
+
+ template <typename P>
+ bool box_bkd_piter_<P>::impl_is_valid() const
+ {
+ return p_ != nop_;
+ }
+
+ template <typename P>
+ P box_bkd_piter_<P>::impl_to_point() const
{
- return is_valid_;
+ return p_;
}
- template <typename point_t>
- void bbox_<point_t>::impl_print(std::ostream& ostr) const
+ template <typename P>
+ const P* box_bkd_piter_<P>::impl_point_adr() const
{
- ostr << "{ pmin=" << this->pmin_
- << ", pmax=" << this->pmax_
- << ", valid=" << is_valid_
- << " }";
+ return &p_;
}
# endif
@@ -267,4 +413,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_BBOX_HH
+#endif // ! OLN_CORE_GEN_BOX_HH
Index: oln/core/gen/plist.hh
--- oln/core/gen/plist.hh (revision 843)
+++ oln/core/gen/plist.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,157 +25,78 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_PSET_LIST_HH
-# define OLN_CORE_GEN_PSET_LIST_HH
+#ifndef OLN_CORE_GEN_PLIST_HH
+# define OLN_CORE_GEN_PLIST_HH
# include <list>
-
-# include <oln/core/point_set_entry.hh>
-# include <oln/core/abstract/point.hh>
+# include <oln/core/internal/point_set_std_based.hh>
namespace oln
{
- // Forward declarations.
- template <typename point_t> class pset_list;
- template <typename C> class fwd_piter_on_std_based_pset;
- template <typename C> class bkd_piter_on_std_based_pset;
+ /// Fwd decl.
+ template <typename P> class plist_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< pset_list<point_t> >
+ // Super type.
+ template <typename P>
+ struct super_trait_< plist_<P> >
{
- typedef pset_list<point_t> self_t;
- typedef point_set_entry<self_t> ret;
+ typedef plist_<P> current__;
+ typedef internal::point_set_std_based_<current__> ret;
};
- /// Virtual types associated to oln::pset_list<point_t>.
- template <typename point_t>
- struct vtypes< pset_list<point_t> >
- {
- typedef point_t point_type;
- typedef fwd_piter_on_std_based_pset< std::list<point_t> > fwd_piter_type;
- typedef bkd_piter_on_std_based_pset< std::list<point_t> > bkd_piter_type;
-
- typedef mlc::false_ is_random_accessible_type;
- typedef mlc::true_ has_known_size_type;
- typedef mlc::false_ is_connected_type;
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< plist_<P> >
+ {
+ typedef std::list<P> std_container;
};
- /// Bounding box class based on a point class.
- template <typename point_t>
- class pset_list : public point_set_entry< pset_list<point_t> >,
- private mlc::assert_< mlc_is_a(point_t, abstract::point) >
- {
- typedef pset_list<point_t> self_type;
- typedef point_set_entry<self_type> super_t;
+ /// Point set class based on std::list.
+ template <typename P>
+ class plist_ : public internal::point_set_std_based_< plist_<P> >
+ {
public:
- pset_list();
- pset_list(const pset_list<point_t>& rhs);
- pset_list<point_t>& operator=(const pset_list<point_t>& rhs);
-
- unsigned impl_npoints() const;
- bool impl_is_valid() const;
- void impl_print(std::ostream& ostr) const;
-
- pset_list<point_t>& append(const point_t& p);
- pset_list<point_t>& prepend(const point_t& p);
-
- const std::list<point_t>& container() const;
- std::list<point_t>& container();
-
- protected:
-
- std::list<point_t> lp_;
+ plist_();
+ plist_<P>& append(const P& p);
+ plist_<P>& prepend(const P& p);
- }; // end of class oln::pset_list<point_t>
+ }; // end of class oln::plist_<P>.
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- pset_list<point_t>::pset_list()
+ template <typename P>
+ plist_<P>::plist_()
{
}
- template <typename point_t>
- pset_list<point_t>::pset_list(const pset_list<point_t>& rhs)
+ template <typename P>
+ plist_<P>& plist_<P>::append(const P& p)
{
- lp_ = rhs.lp_;
- }
-
- template <typename point_t>
- pset_list<point_t>& pset_list<point_t>::operator=(const pset_list<point_t>& rhs)
- {
- lp_ = rhs.lp_;
+ this->con_.push_back(p);
+ this->take_(p);
return *this;
}
- template <typename point_t>
- unsigned pset_list<point_t>::impl_npoints() const
- {
- return lp_.size();
- }
-
- template <typename point_t>
- bool pset_list<point_t>::impl_is_valid() const
+ template <typename P>
+ plist_<P>& plist_<P>::prepend(const P& p)
{
- return true;
- }
-
- template <typename point_t>
- void pset_list<point_t>::impl_print(std::ostream& ostr) const
- {
- typename std::list<point_t>::const_iterator it;
- ostr << "{ ";
- for (it = lp_.begin(); it != lp_.end(); ++it)
- ostr << *it << ' ';
- ostr << "}";
- }
-
- template <typename point_t>
- pset_list<point_t>& pset_list<point_t>::append(const point_t& p)
- {
- precondition(std::find(lp_.begin(), lp_.end(), p)
- = lp_.end());
- lp_.push_back(p);
- return *this;
- }
-
- template <typename point_t>
- pset_list<point_t>& pset_list<point_t>::prepend(const point_t& p)
- {
- precondition(std::find(lp_.begin(), lp_.end(), p)
- = lp_.end());
- lp_.push_front(p);
+ this->con_.push_front(p);
+ this->take_(p);
return *this;
}
- template <typename point_t>
- const std::list<point_t>& pset_list<point_t>::container() const
- {
- return lp_;
- }
-
- template <typename point_t>
- std::list<point_t>& pset_list<point_t>::container()
- {
- return lp_;
- }
-
# endif
} // end of namespace oln
-# include <oln/core/gen/piter_on_std_based_pset.hh>
-
-
-#endif // ! OLN_CORE_GEN_PSET_LIST_HH
+#endif // ! OLN_CORE_GEN_PLIST_HH
Index: oln/core/gen/pvec.hh
--- oln/core/gen/pvec.hh (revision 843)
+++ oln/core/gen/pvec.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,139 +25,82 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_PSET_VEC_HH
-# define OLN_CORE_GEN_PSET_VEC_HH
+#ifndef OLN_CORE_GEN_PVEC_HH
+# define OLN_CORE_GEN_PVEC_HH
# include <vector>
-
-# include <oln/core/point_set_entry.hh>
-# include <oln/core/abstract/point.hh>
+# include <oln/core/internal/point_set_std_based.hh>
namespace oln
{
- // Forward declarations.
- template <typename point_t> class pset_vec;
- template <typename C> class fwd_piter_on_std_based_pset;
- template <typename C> class bkd_piter_on_std_based_pset;
+ /// Fwd decl.
+ template <typename P> class pvec_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< pset_vec<point_t> >
+ // Super type.
+ template <typename P>
+ struct super_trait_< pvec_<P> >
{
- typedef pset_vec<point_t> self_t;
- typedef point_set_entry<self_t> ret;
+ typedef pvec_<P> current__;
+ typedef internal::point_set_std_based_<current__> ret;
};
- /// Virtual types associated to oln::pset_vec<point_t>.
- template <typename point_t>
- struct vtypes< pset_vec<point_t> >
- {
- typedef point_t point_type;
- typedef fwd_piter_on_std_based_pset< std::vector<point_t> > fwd_piter_type;
- typedef bkd_piter_on_std_based_pset< std::vector<point_t> > bkd_piter_type;
-
- typedef mlc::false_ is_random_accessible_type;
- typedef mlc::true_ has_known_size_type;
- typedef mlc::false_ is_connected_type;
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< pvec_<P> >
+ {
+ typedef std::vector<P> std_container;
};
- /// Bounding box class based on a point class.
- template <typename point_t>
- class pset_vec : public point_set_entry< pset_vec<point_t> >,
- private mlc::assert_< mlc_is_a(point_t, abstract::point) >
- {
- typedef pset_vec<point_t> self_type;
- typedef point_set_entry<self_type> super_t;
+ /// Point set class based on std::set.
+ template <typename P>
+ class pvec_ : public internal::point_set_std_based_< pvec_<P> >
+ {
public:
- pset_vec();
- pset_vec(const pset_vec<point_t>& rhs);
- pset_vec<point_t>& operator=(const pset_vec<point_t>& rhs);
-
- unsigned impl_npoints() const;
- bool impl_is_valid() const;
- void impl_print(std::ostream& ostr) const;
-
- pset_vec<point_t>& append(const point_t& p);
-
- const std::vector<point_t>& container() const;
- std::vector<point_t>& container();
+ pvec_();
+ pvec_<P>& append(const P& p);
+ const P& operator[](unsigned i) const;
+ P& operator[](unsigned i);
- protected:
-
- std::vector<point_t> vp_;
-
- }; // end of class oln::pset_vec<point_t>
+ }; // end of class oln::pvec_<P>.
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- pset_vec<point_t>::pset_vec()
+ template <typename P>
+ pvec_<P>::pvec_()
{
}
- template <typename point_t>
- pset_vec<point_t>::pset_vec(const pset_vec<point_t>& rhs)
+ template <typename P>
+ pvec_<P>&
+ pvec_<P>::append(const P& p)
{
- vp_ = rhs.vp_;
- }
-
- template <typename point_t>
- pset_vec<point_t>& pset_vec<point_t>::operator=(const pset_vec<point_t>& rhs)
- {
- vp_ = rhs.vp_;
+ this->con_.push_back(p);
+ this->take_(p);
return *this;
}
- template <typename point_t>
- unsigned pset_vec<point_t>::impl_npoints() const
+ template <typename P>
+ const P&
+ pvec_<P>::operator[](unsigned i) const
{
- return vp_.size();
+ precondition(i < this->npoints());
+ return this->con_[i];
}
- template <typename point_t>
- bool pset_vec<point_t>::impl_is_valid() const
+ template <typename P>
+ P& pvec_<P>::operator[](unsigned i)
{
- return true;
- }
-
- template <typename point_t>
- void pset_vec<point_t>::impl_print(std::ostream& ostr) const
- {
- typename std::vector<point_t>::const_iterator it;
- ostr << "{ ";
- for (it = vp_.begin(); it != vp_.end(); ++it)
- ostr << *it << ' ';
- ostr << "}";
- }
-
- template <typename point_t>
- pset_vec<point_t>& pset_vec<point_t>::append(const point_t& p)
- {
- precondition(std::find(vp_.begin(), vp_.end(), p)
- = vp_.end());
- vp_.push_back(p);
- return *this;
- }
-
- template <typename point_t>
- const std::vector<point_t>& pset_vec<point_t>::container() const
- {
- return vp_;
- }
-
- template <typename point_t>
- std::vector<point_t>& pset_vec<point_t>::container()
- {
- return vp_;
+ precondition(i < this->npoints());
+ return this->con_[i];
}
# endif
@@ -165,7 +108,4 @@
} // end of namespace oln
-# include <oln/core/gen/piter_on_std_based_pset.hh>
-
-
-#endif // ! OLN_CORE_GEN_PSET_VEC_HH
+#endif // ! OLN_CORE_GEN_PVEC_HH
Index: oln/core/gen/fbbox.hh
--- oln/core/gen/fbbox.hh (revision 0)
+++ oln/core/gen/fbbox.hh (revision 0)
@@ -0,0 +1,127 @@
+// Copyright (C) 2001, 2003, 2004, 2005, 2006, 2007 EPITA Research and
+// Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_FBBOX_HH
+# define OLN_CORE_GEN_FBBOX_HH
+
+# include <oln/core/gen/box.hh>
+# include <oln/core/concept/point.hh>
+
+
+namespace oln
+{
+
+
+ /// Bounding box function based on a point class.
+
+ template <typename P>
+ class fbbox_ : private mlc::assert_< mlc_is_a(P, Point) >
+ {
+ private:
+ typedef stc_type(P, dim) dim__;
+ enum { n = mlc_value(dim__) };
+
+ public:
+
+ fbbox_();
+ operator box_<P>() const;
+
+ bool is_valid() const;
+ void flush();
+ fbbox_<P>& take(const P& p);
+ const box_<P>& box() const;
+
+ private:
+ bool is_valid_;
+ box_<P> b_;
+
+ }; // end of class oln::fbbox_<P>
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P>
+ fbbox_<P>::fbbox_()
+ {
+ this->flush();
+ }
+
+ template <typename P>
+ fbbox_<P>::operator box_<P>() const
+ {
+ precondition(this->is_valid_);
+ return this->b_;
+ }
+
+ template <typename P>
+ bool fbbox_<P>::is_valid() const
+ {
+ return this->is_valid_;
+ }
+
+ template <typename P>
+ void fbbox_<P>::flush()
+ {
+ is_valid_ = false;
+ }
+
+ template <typename P>
+ fbbox_<P>& fbbox_<P>::take(const P& p)
+ {
+ if (not this->is_valid_)
+ {
+ this->b_.pmin() = p;
+ this->b_.pmax() = p;
+ this->is_valid_ = true;
+ }
+ else
+ {
+ for (unsigned i = 0; i < n; ++i)
+ if (p[i] < this->b_.pmin()[i])
+ this->b_.pmin()[i] = p[i];
+ else if (p[i] > this->b_.pmax()[i])
+ this->b_.pmax()[i] = p[i];
+ }
+ return *this;
+ }
+
+ template <typename P>
+ const box_<P>& fbbox_<P>::box() const
+ {
+ precondition(this->is_valid_);
+ return this->b_;
+ }
+
+# endif
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_GEN_FBBOX_HH
Index: oln/core/gen/pset.hh
--- oln/core/gen/pset.hh (revision 843)
+++ oln/core/gen/pset.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,142 +29,65 @@
# define OLN_CORE_GEN_PSET_HH
# include <set>
-
-# include <oln/core/point_set_entry.hh>
-# include <oln/core/abstract/point.hh>
+# include <oln/core/internal/point_set_std_based.hh>
namespace oln
{
- // Forward declarations.
- template <typename point_t> class pset_;
- template <typename C> class fwd_piter_on_std_based_pset;
- template <typename C> class bkd_piter_on_std_based_pset;
+ /// Fwd decl.
+ template <typename P> class pset_;
- // Super type declaration.
- template <typename point_t>
- struct set_super_type< pset_<point_t> >
+ // Super type.
+ template <typename P>
+ struct super_trait_< pset_<P> >
{
- typedef pset_<point_t> self_t;
- typedef point_set_entry<self_t> ret;
+ typedef pset_<P> current__;
+ typedef internal::point_set_std_based_<current__> ret;
};
- /// Virtual types associated to oln::pset_<point_t>.
- template <typename point_t>
- struct vtypes< pset_<point_t> >
- {
- typedef point_t point_type;
- typedef fwd_piter_on_std_based_pset< std::set<point_t> > fwd_piter_type;
- typedef bkd_piter_on_std_based_pset< std::set<point_t> > bkd_piter_type;
-
- typedef mlc::false_ is_random_accessible_type;
- typedef mlc::true_ has_known_size_type;
- typedef mlc::false_ is_connected_type;
+ /// Virtual types.
+ template <typename P>
+ struct vtypes< pset_<P> >
+ {
+ typedef std::set<P> std_container;
};
- /// Bounding box class based on a point class.
- template <typename point_t>
- class pset_ : public point_set_entry< pset_<point_t> >,
- private mlc::assert_< mlc_is_a(point_t, abstract::point) >
- {
- typedef pset_<point_t> self_type;
- typedef point_set_entry<self_type> super_t;
+ /// Point set class based on std::set.
+ template <typename P>
+ class pset_ : public internal::point_set_std_based_< pset_<P> >
+ {
public:
pset_();
- pset_(const pset_<point_t>& rhs);
- pset_<point_t>& operator=(const pset_<point_t>& rhs);
-
- unsigned impl_npoints() const;
- bool impl_is_valid() const;
- void impl_print(std::ostream& ostr) const;
-
- pset_<point_t>& insert(const point_t& p);
-
- const std::set<point_t>& container() const;
- std::set<point_t>& container();
-
- protected:
-
- std::set<point_t> sp_;
+ pset_<P>& insert(const P& p);
- }; // end of class oln::pset_<point_t>
+ }; // end of class oln::pset_<P>.
# ifndef OLN_INCLUDE_ONLY
- template <typename point_t>
- pset_<point_t>::pset_()
+ template <typename P>
+ pset_<P>::pset_()
{
}
- template <typename point_t>
- pset_<point_t>::pset_(const pset_<point_t>& rhs)
+ template <typename P>
+ pset_<P>& pset_<P>::insert(const P& p)
{
- sp_ = rhs.sp_;
- }
-
- template <typename point_t>
- pset_<point_t>& pset_<point_t>::operator=(const pset_<point_t>& rhs)
- {
- sp_ = rhs.sp_;
+ this->con_.insert(p);
+ this->take_(p);
return *this;
}
- template <typename point_t>
- unsigned pset_<point_t>::impl_npoints() const
- {
- return sp_.size();
- }
-
- template <typename point_t>
- bool pset_<point_t>::impl_is_valid() const
- {
- return true;
- }
-
- template <typename point_t>
- void pset_<point_t>::impl_print(std::ostream& ostr) const
- {
- typename std::set<point_t>::const_iterator it;
- ostr << "{ ";
- for (it = sp_.begin(); it != sp_.end(); ++it)
- ostr << *it << ' ';
- ostr << "}";
- }
-
- template <typename point_t>
- pset_<point_t>& pset_<point_t>::insert(const point_t& p)
- {
- precondition(sp_.find(p) = sp_.end());
- sp_.insert(p);
- return *this;
- }
-
- template <typename point_t>
- const std::set<point_t>& pset_<point_t>::container() const
- {
- return sp_;
- }
-
- template <typename point_t>
- std::set<point_t>& pset_<point_t>::container()
- {
- return sp_;
- }
-
# endif
} // end of namespace oln
-# include <oln/core/gen/piter_on_std_based_pset.hh>
-
-
#endif // ! OLN_CORE_GEN_PSET_HH
Index: oln/core/internal/point_set_std_based.hh
--- oln/core/internal/point_set_std_based.hh (revision 843)
+++ oln/core/internal/point_set_std_based.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,247 +25,348 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
-# define OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
+#ifndef OLN_CORE_INTERNAL_POINT_SET_STD_BASED_HH
+# define OLN_CORE_INTERNAL_POINT_SET_STD_BASED_HH
-# include <oln/core/abstract/point.hh>
-# include <oln/core/abstract/iterator_on_points.hh>
+# include <ostream>
+# include <algorithm>
+
+# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/concept/iterator_on_points.hh>
+# include <oln/core/gen/fbbox.hh>
namespace oln
{
- // Fwd_piter version.
- // ------------------
-
-
- // Forward declaration.
- template <typename C> class fwd_piter_on_std_based_pset;
+ /// Fwd decl.
+ namespace internal { template <typename Exact> struct point_set_std_based_; }
+ template <typename P> class pset_std_based_fwd_piter_;
+ template <typename P> class pset_std_based_bkd_piter_;
- // Super.
- template <typename C>
- struct set_super_type< fwd_piter_on_std_based_pset<C> >
+ /// Super type.
+ template <typename Exact>
+ struct super_trait_< internal::point_set_std_based_<Exact> >
{
- typedef abstract::iterator_on_points< fwd_piter_on_std_based_pset<C> > ret;
+ typedef internal::point_set_base_<Exact> ret;
};
- // Vtypes.
- template <typename C>
- struct vtypes< fwd_piter_on_std_based_pset<C> >
- {
- typedef typename C::value_type point_type;
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::point_set_std_based_<Exact> >
+ {
+ typedef stc::abstract std_container;
+
+ typedef stc_deferred(std_container) std_container__;
+ typedef stc::final< typename std_container__::value_type > point;
+ typedef stc::final< pset_std_based_fwd_piter_<std_container__> > fwd_piter;
+ typedef stc::final< pset_std_based_bkd_piter_<std_container__> > bkd_piter;
};
- // Class.
- template <typename C>
- class fwd_piter_on_std_based_pset :
+ namespace internal
+ {
+
+ /// Base class for point sets defined over std containers.
- public abstract::iterator_on_points< fwd_piter_on_std_based_pset<C> >,
- private mlc::assert_< mlc_is_a(typename C::value_type, abstract::point) >
+ template <typename Exact>
+ struct point_set_std_based_ : public point_set_base_<Exact>
{
+ typedef point_set_base_<Exact> super;
public:
- fwd_piter_on_std_based_pset(const C& container);
- template <typename point_set>
- fwd_piter_on_std_based_pset(const point_set& ps);
+ stc_using(point);
+ stc_using(box);
- void impl_start();
- void impl_next();
- void impl_invalidate();
- bool impl_is_valid() const;
- typename C::value_type impl_to_point() const;
- const typename C::value_type* impl_point_adr() const;
+ unsigned impl_npoints() const;
+ bool impl_has(const point& p) const;
+ const box& impl_bbox() const;
- private:
+ stc_typename(std_container);
+ const std_container& con() const;
- const C& container_;
- typename C::const_iterator it_;
+ protected:
+
+ point_set_std_based_();
+
+ void take_(const point& p);
+
+ std_container con_;
+ fbbox_<point> fb_;
+
+ }; // end of class point_set_std_based_<Exact>
+
+
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr,
+ const point_set_std_based_<Exact>& pts)
+ {
+ typename Exact::fwd_piter i(pts);
+ ostr << "{ ";
+ for_all(i)
+ ostr << i.to_point() << ' ';
+ ostr << "}";
+ }
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ unsigned
+ point_set_std_based_<Exact>::impl_npoints() const
+ {
+ return this->con_.size();
+ }
+
+ template <typename Exact>
+ bool
+ point_set_std_based_<Exact>::impl_has(const typename point_set_std_based_<Exact>::point& p) const
+ {
+ return std::find(this->con_.begin(), this->con_.end(), p) != this->con_.end();
+ }
+
+ template <typename Exact>
+ const typename point_set_std_based_<Exact>::box&
+ point_set_std_based_<Exact>::impl_bbox() const
+ {
+ precondition(this->fb_.is_valid());
+ return this->fb_.box();
+ }
+
+ template <typename Exact>
+ point_set_std_based_<Exact>::point_set_std_based_()
+ {
+ }
+
+ template <typename Exact>
+ void
+ point_set_std_based_<Exact>::take_(const typename point_set_std_based_<Exact>::point& p)
+ {
+ this->fb_.take(p);
+ }
+
+ template <typename Exact>
+ const typename point_set_std_based_<Exact>::std_container&
+ point_set_std_based_<Exact>::con() const
+ {
+ this->con_;
+ }
+
+# endif
+
+ } // end of namespace oln::internal
- }; // end of class fwd_piter_on_std_based_pset<C>
- // Bkd_piter version.
- // ------------------
+ // -------------------- iterators on classes deriving from internal::point_set_std_based_<Exact>
- // Forward declaration.
- template <typename C> class bkd_piter_on_std_based_pset;
+ // Super types.
- // Super.
template <typename C>
- struct set_super_type< bkd_piter_on_std_based_pset<C> >
+ struct super_trait_< pset_std_based_fwd_piter_<C> >
{
- typedef abstract::iterator_on_points< bkd_piter_on_std_based_pset<C> > ret;
+ typedef pset_std_based_fwd_piter_<C> current__;
+ typedef Iterator_on_Points<current__> ret;
};
+ template <typename C>
+ struct super_trait_< pset_std_based_bkd_piter_<C> >
+ {
+ typedef pset_std_based_bkd_piter_<C> current__;
+ typedef Iterator_on_Points<current__> ret;
+ };
+
+
+
+ /// Virtual types.
- // Vtypes.
template <typename C>
- struct vtypes< bkd_piter_on_std_based_pset<C> >
+ struct vtypes< pset_std_based_fwd_piter_<C> >
{
- typedef typename C::value_type point_type;
+ typedef typename C::value_type point;
};
+ template <typename C>
+ struct vtypes< pset_std_based_bkd_piter_<C> >
+ {
+ typedef typename C::value_type point;
+ };
+
+
+ // Class pset_std_based_fwd_piter_<C>.
- // Class.
template <typename C>
- class bkd_piter_on_std_based_pset :
+ class pset_std_based_fwd_piter_ : public Iterator_on_Points< pset_std_based_fwd_piter_<C> >
+ {
+ typedef pset_std_based_fwd_piter_<C> current;
+ typedef Iterator_on_Points<current> super;
+ public:
+
+ stc_using(point);
+
+ template <typename Ps>
+ pset_std_based_fwd_piter_(const internal::point_set_std_based_<Ps>& con);
+
+ void impl_start();
+ void impl_next();
+ void impl_invalidate();
+ bool impl_is_valid() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
+
+ private:
+
+ const C& con_;
+ typename C::const_iterator it_;
+
+ }; // end of class pset_std_based_fwd_piter_<C>
+
+
+ // Class pset_std_based_bkd_piter_<C>.
- public abstract::iterator_on_points< bkd_piter_on_std_based_pset<C> >,
- private mlc::assert_< mlc_is_a(typename C::value_type, abstract::point) >
+ template <typename C>
+ class pset_std_based_bkd_piter_ : public Iterator_on_Points< pset_std_based_bkd_piter_<C> >
{
+ typedef pset_std_based_bkd_piter_<C> current;
+ typedef Iterator_on_Points<current> super;
public:
- bkd_piter_on_std_based_pset(const C& container);
- template <typename point_set>
- bkd_piter_on_std_based_pset(const point_set& ps);
+ stc_using(point);
+
+ template <typename Ps>
+ pset_std_based_bkd_piter_(const internal::point_set_std_based_<Ps>& pts);
void impl_start();
void impl_next();
void impl_invalidate();
bool impl_is_valid() const;
- typename C::value_type impl_to_point() const;
- const typename C::value_type* impl_point_adr() const;
+ point impl_to_point() const;
+ const point* impl_point_adr() const;
private:
- const C& container_;
+ const C& con_;
typename C::const_reverse_iterator it_;
- }; // end of class bkd_piter_on_std_based_pset<C>
-
+ }; // end of class pset_std_based_bkd_piter_<C>
# ifndef OLN_INCLUDE_ONLY
- // fwd_piter_on_std_based_pset<C>
+ // -------------------- pset_std_based_fwd_piter_<C>
- template <typename C>
- fwd_piter_on_std_based_pset<C>::fwd_piter_on_std_based_pset(const C& container)
- : container_(container)
- {
- this->invalidate();
- }
template <typename C>
- template <typename point_set>
- fwd_piter_on_std_based_pset<C>::fwd_piter_on_std_based_pset(const point_set& ps)
- : container_(ps.exact().container())
+ template <typename Ps>
+ pset_std_based_fwd_piter_<C>::pset_std_based_fwd_piter_(const internal::point_set_std_based_<Ps>& pts)
+ : con_(pts.con())
{
- this->invalidate();
+ this->it_ = this->con_.end();
}
template <typename C>
- void fwd_piter_on_std_based_pset<C>::impl_start()
+ void pset_std_based_fwd_piter_<C>::impl_start()
{
- it_ = container_.begin();
+ this->it_ = this->con_.begin();
}
template <typename C>
- void fwd_piter_on_std_based_pset<C>::impl_next()
+ void pset_std_based_fwd_piter_<C>::impl_next()
{
- ++it_;
+ ++this->it_;
}
template <typename C>
- void fwd_piter_on_std_based_pset<C>::impl_invalidate()
+ void pset_std_based_fwd_piter_<C>::impl_invalidate()
{
- it_ = container_.end();
+ this->it_ = this->con_.end();
}
template <typename C>
- bool fwd_piter_on_std_based_pset<C>::impl_is_valid() const
+ bool pset_std_based_fwd_piter_<C>::impl_is_valid() const
{
- return it_ != container_.end();
+ return this->it_ != this->con_.end();
}
template <typename C>
- typename C::value_type
- fwd_piter_on_std_based_pset<C>::impl_to_point() const
+ typename pset_std_based_fwd_piter_<C>::point
+ pset_std_based_fwd_piter_<C>::impl_to_point() const
{
- return *it_;
+ return *this->it_;
}
template <typename C>
- const typename C::value_type*
- fwd_piter_on_std_based_pset<C>::impl_point_adr() const
+ const typename pset_std_based_fwd_piter_<C>::point*
+ pset_std_based_fwd_piter_<C>::impl_point_adr() const
{
- return 0;
- // FIXME: Read below.
- // "&(*it_)" is not correct because the std does not ensure that
- // "*it_" is dereferenceable (Cf. std trivial iterator concept).
- // However, "::point_adr()" is only required so that an iterator
- // based on another iterator (e.g., a niter constructed from a
- // piter) can stick to the point location of the latter. This
- // is not required for iterators on point set so this method should
- // be optional.
+ return &(*(this->it_));
+ // FIXME: "&(*it_)" is not always correct because the std does not
+ // ensure that "*it_" is dereferenceable (Cf. std trivial iterator
+ // concept). However, "::point_adr()" is only required so that an
+ // iterator based on another iterator (e.g., a niter constructed
+ // from a piter) can stick to the point location of the latter.
+ // This is not required for iterators on point set so this method
+ // should be optional.
}
- // bkd_piter_on_std_based_pset<C>
-
+ // -------------------- pset_std_based_bkd_piter_<C>
- template <typename C>
- bkd_piter_on_std_based_pset<C>::bkd_piter_on_std_based_pset(const C& container)
- : container_(container)
- {
- this->invalidate();
- }
template <typename C>
- template <typename point_set>
- bkd_piter_on_std_based_pset<C>::bkd_piter_on_std_based_pset(const point_set& ps)
- : container_(ps.exact().container())
+ template <typename Ps>
+ pset_std_based_bkd_piter_<C>::pset_std_based_bkd_piter_(const internal::point_set_std_based_<Ps>& pts)
+ : con_(pts.con())
{
- this->invalidate();
+ this->it_ = this->con_.rend();
}
template <typename C>
- void bkd_piter_on_std_based_pset<C>::impl_start()
+ void pset_std_based_bkd_piter_<C>::impl_start()
{
- it_ = container_.rbegin();
+ this->it_ = this->con_.rbegin();
}
template <typename C>
- void bkd_piter_on_std_based_pset<C>::impl_next()
+ void pset_std_based_bkd_piter_<C>::impl_next()
{
- ++it_;
+ ++this->it_;
}
template <typename C>
- void bkd_piter_on_std_based_pset<C>::impl_invalidate()
+ void pset_std_based_bkd_piter_<C>::impl_invalidate()
{
- it_ = container_.rend();
+ this->it_ = this->con_.rend();
}
template <typename C>
- bool bkd_piter_on_std_based_pset<C>::impl_is_valid() const
+ bool pset_std_based_bkd_piter_<C>::impl_is_valid() const
{
- return it_ != container_.rend();
+ return this->it_ != this->con_.rend();
}
template <typename C>
- typename C::value_type
- bkd_piter_on_std_based_pset<C>::impl_to_point() const
+ typename pset_std_based_bkd_piter_<C>::point
+ pset_std_based_bkd_piter_<C>::impl_to_point() const
{
- return *it_;
+ return *this->it_;
}
template <typename C>
- const typename C::value_type*
- bkd_piter_on_std_based_pset<C>::impl_point_adr() const
+ const typename pset_std_based_bkd_piter_<C>::point*
+ pset_std_based_bkd_piter_<C>::impl_point_adr() const
{
- return 0;
- // FIXME: Read comments in the fwd version of this method.
+ return &(*(this->it_));
+ // FIXME: Read comments in pset_std_based_fwd_piter_<C>.
}
@@ -275,4 +376,4 @@
} // end of namespace oln
-#endif // ! OLN_CORE_GEN_PITER_ON_STD_BASED_PSET_HH
+#endif // ! OLN_CORE_INTERNAL_POINT_SET_STD_BASED_HH
Index: oln/core/internal/point_set_base.hh
--- oln/core/internal/point_set_base.hh (revision 843)
+++ oln/core/internal/point_set_base.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,74 +25,70 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_POINT_SET_ENTRY_HH
-# define OLN_CORE_POINT_SET_ENTRY_HH
+#ifndef OLN_CORE_INTERNAL_POINT_SET_BASE_HH
+# define OLN_CORE_INTERNAL_POINT_SET_BASE_HH
-# include <oln/core/abstract/entry.hh>
-# include <oln/core/abstract/point_set/all.hh>
+# include <oln/core/concept/point_set.hh>
namespace oln
{
- /// Fwd decl.
- template <typename E> struct point_set_entry;
+ /// Fwd decls.
+ namespace internal { template <typename Exact> struct point_set_base_; }
+ template <typename P> class box_;
- template <typename E>
- struct set_super_type< point_set_entry<E> >
+ /// Super type.
+ template <typename Exact>
+ struct super_trait_< internal::point_set_base_<Exact> >
{
- typedef mlc::none ret;
+ typedef Point_Set<Exact> ret;
};
- /// Virtual types associated to point_set_entry<E>.
-
- template <typename E>
- struct vtypes< point_set_entry<E> >
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::point_set_base_<Exact> >
{
- typedef stc::abstract point_type;
-
- typedef stc::abstract fwd_piter_type;
- typedef stc::abstract bkd_piter_type;
-
- typedef mlc::none bbox_type;
- typedef stc::abstract is_random_accessible_type;
- typedef stc::abstract has_known_size_type;
- typedef stc::abstract is_connected_type;
-
- // final.
- typedef oln_deduce_vtype(E, point, coord) coord_type;
- typedef oln_deduce_vtype(E, point, grid) grid_type;
- typedef oln_deduce_vtype(E, point, dim) dim_type;
- typedef oln_fwd_piter(E) piter_type;
+ typedef stc::abstract point;
+ typedef stc::abstract fwd_piter;
+ typedef stc::abstract bkd_piter;
+
+ typedef stc_deferred(point) point__;
+ typedef stc_deferred(fwd_piter) fwd_piter__;
+
+ typedef stc::final< box_<point__> > box;
+ typedef stc::final<stc_type(point__, grid)> grid;
+ typedef stc::final<fwd_piter__> piter;
};
+ namespace internal
+ {
- /// Entry class for point sets: point_set_entry<E> is an alias for
- /// entry< abstract::point_set, E>.
+ /// Base class for point sets.
- template <typename E>
- struct point_set_entry : public entry< abstract::point_set, E>
+ template <typename Exact>
+ struct point_set_base_ : public Point_Set<Exact>
{
protected:
- point_set_entry();
+ point_set_base_();
};
-
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- point_set_entry<E>::point_set_entry()
+ template <typename Exact>
+ point_set_base_<Exact>::point_set_base_()
{
}
# endif
+ } // end of namespace oln::internal
} // end of namespace oln
-#endif // ! OLN_CORE_POINT_SET_ENTRY_HH
+#endif // ! OLN_CORE_INTERNAL_POINT_SET_BASE_HH
1
0
02 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Start cleaning so the trunk is BROKEN for several weeks.
Add a temporary SCOOP equipment.
* oln/stc/scoop.hh: New.
* oln/stc/scoop.hxx: New.
* oln/core/equipment.hh: New.
Define some concepts.
* oln/core/abstract/grid.hh: Rename as...
* oln/core/concept/grid.hh: ...this and update.
* oln/core/abstract/point.hh: Rename as...
* oln/core/concept/point.hh: ...this and update.
* oln/core/abstract/dpoint.hh: Rename as...
* oln/core/concept/dpoint.hh: ...this and update.
* oln/core/concept/operators.hh: New.
Update implementation classes.
* oln/core/2d/grid2d.hh: New.
* oln/core/2d/dpoint2d.hh: Update.
* oln/core/2d/point2d.hh: Update.
* oln/core/internal/point_nd.hh: Rename as...
* oln/core/internal/point_base.hh: ...this and update.
* oln/core/internal/dpoint_base.hh: New.
* oln/core/internal/dpoint2d.hh: New.
* oln/core/internal/point2d.hh: New.
Last.
* oln/core/internal/tracked_ptr.hh (mlc/contract.hh): Include it.
core/2d/dpoint2d.hh | 100 +---
core/2d/grid2d.hh | 69 +++
core/2d/point2d.hh | 113 +----
core/concept/dpoint.hh | 158 ++++---
core/concept/grid.hh | 53 --
core/concept/operators.hh | 181 ++++++++
core/concept/point.hh | 427 ++-----------------
core/equipment.hh | 65 ++
core/internal/dpoint2d.hh | 127 +++++
core/internal/dpoint_base.hh | 230 ++++++++++
core/internal/point2d.hh | 127 +++++
core/internal/point_base.hh | 278 ++++--------
core/internal/tracked_ptr.hh | 2
stc/scoop.hh | 155 +++++++
stc/scoop.hxx | 951 +++++++++++++++++++++++++++++++++++++++++++
15 files changed, 2215 insertions(+), 821 deletions(-)
Index: oln/core/concept/grid.hh
--- oln/core/concept/grid.hh (revision 0)
+++ oln/core/concept/grid.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2005, 2006, 2007 EPITA Research and Development
+// Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,58 +26,28 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_GRID_HH
-# define OLN_CORE_ABSTRACT_GRID_HH
+#ifndef OLN_CORE_CONCEPT_GRID_HH
+# define OLN_CORE_CONCEPT_GRID_HH
-# include <oln/core/type.hh>
-# include <oln/core/typedefs.hh>
+# include <oln/core/equipment.hh>
-namespace oln {
-
- // Forward declaration.
- namespace abstract
+namespace oln
{
- template <typename E> class grid;
- }
- /// Super type declaration.
- template <typename E>
- struct set_super_type< abstract::grid<E> >
- {
- typedef mlc::none ret;
- };
+ /// Concept-class "Grid".
- /// Virtual types associated to oln::abstract::grid.
- template <typename E>
- struct vtypes< abstract::grid<E> >
+ template <typename Exact>
+ struct Grid : public Any<Exact>
{
- typedef stc::abstract dimvalue_type;
- };
-
- namespace abstract {
+ stc_typename(dim);
- template <typename E>
- struct grid : public virtual stc::any__simple<E>,
- public oln::type
- {
protected:
- grid();
+ Grid() {}
};
-# ifndef OLN_INCLUDE_ONLY
-
- template <typename E>
- grid<E>::grid()
- {
- }
-
-# endif
-
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_GRID_HH
+#endif // ! OLN_CORE_CONCEPT_GRID_HH
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 0)
+++ oln/core/concept/point.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,16 +26,11 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_POINT_HH
-# define OLN_CORE_ABSTRACT_POINT_HH
+#ifndef OLN_CORE_CONCEPT_POINT_HH
+# define OLN_CORE_CONCEPT_POINT_HH
-# include <xtd/vec.hh>
-
-# include <oln/core/typedefs.hh>
-# include <oln/core/traits_id.hh>
-# include <oln/core/abstract/dpoint.hh>
-
-# include <xtd/vec.hh>
+# include <mlc/value.hh>
+# include <oln/core/equipment.hh>
@@ -43,426 +38,110 @@
{
- namespace ERROR
- {
- struct OPERANDS_ARE_NOT_COMPATIBLE;
-
- } // end of namespace oln::ERROR
-
-
+ /// Concept-class "Point".
- // Forward declaration.
- namespace abstract { template <typename E> class point; }
-
-
- template <typename E>
- struct set_super_type< abstract::point<E> >
+ template <typename Exact>
+ struct Point : public Any<Exact>
{
- typedef mlc::none ret;
- };
-
+ stc_typename(grid);
+ stc_typename(dim);
+ stc_typename(coord);
+ stc_typename(dpoint);
- /// Virtual types associated to abstract::point<E>.
- template <typename E>
- struct vtypes< abstract::point<E> >
- {
- // FIXME: Prefer to use final<deduce..> when possible.
- typedef stc::abstract grid_type;
- typedef stc::abstract dpoint_type;
-# ifndef OLENA_USE_SCOOP_ALT
- typedef oln_deduce_deferred_vtype(E, dpoint, coord) coord_type;
-# endif // !OLENA_USE_SCOOP_ALT
- typedef stc::abstract dim_type;
-
-# ifndef OLENA_USE_SCOOP_ALT
- typedef oln_dim(E) dim_t;
- typedef xtd::vec<mlc_value(dim_t), coord_type> vec_type;
-# endif // !OLENA_USE_SCOOP_ALT
- };
-
-# ifdef OLENA_USE_SCOOP_ALT
- template <typename E>
- struct single_vtype< abstract::point<E>, typedef_::coord_type>
- {
- typedef oln_deduce_vtype(E, dpoint, coord) ret;
- };
+ enum { n = mlc_value(dim) };
- template <typename E>
- struct single_vtype< abstract::point<E>, typedef_::vec_type>
- {
- private:
- typedef oln_dim(E) dim_t;
- typedef oln_coord(E) coord_t;
- public:
- typedef xtd::vec<mlc_value(dim_t), coord_t> ret;
- };
-# endif // OLENA_USE_SCOOP_ALT
-
-
- namespace abstract
- {
-
- /// Abstract point class.
- template <typename E>
- class point : public stc::any__simple<E>,
- public oln::type
- {
- typedef oln_dpoint(E) dpoint_t;
- typedef oln_vec(E) vec_t;
-
- public:
-
-
- /// \{
/// Operator =.
+ bool op_equal_(const Exact& rhs) const;
- bool operator=(const E& rhs) const;
-
- template <typename P>
- bool operator=(const abstract::point<P>& rhs) const;
-
- /// \}
-
-
- /// \{
- /// Operator !=.
-
- bool operator!=(const E& rhs) const;
-
- template <typename P>
- bool operator!=(const abstract::point<P>& rhs) const;
-
- /// \}
-
-
- /// \{
/// Operator <.
+ bool op_less_(const Exact& rhs) const;
- bool operator<(const E& rhs) const;
-
- template <typename P>
- bool operator<(const abstract::point<P>& rhs) const;
-
- /// \}
-
-
- /// \{
- /// Operator >.
-
- bool operator>(const E& rhs) const;
-
- template <typename P>
- bool operator>(const abstract::point<P>& rhs) const;
-
- /// \}
-
-
- /// \{
- /// Operator >=.
-
- bool operator>=(const E& rhs) const;
-
- template <typename P>
- bool operator>=(const abstract::point<P>& rhs) const;
-
- /// \}
-
-
- /// \{
- /// Operator <=.
-
- bool operator<=(const E& rhs) const;
-
- template <typename P>
- bool operator<=(const abstract::point<P>& rhs) const;
-
- /// \}
-
-
- /// \{
/// Operator +=.
+ Exact& op_plus_equal_(const dpoint& rhs);
- E& operator+=(const dpoint_t& rhs);
-
- template <typename D>
- E& operator+=(const abstract::dpoint<D>& rhs);
-
- /// \}
-
-
- /// \{
- /// Operator +.
-
- E operator+(const dpoint_t& rhs) const;
-
- template <typename D>
- xtd_op_plus_trait(E,D) operator+(const abstract::dpoint<D>& rhs) const;
-
- /// \}
-
-
- /// \{
/// Operator -=.
+ Exact& op_minus_equal_(const dpoint& rhs);
- E& operator-=(const dpoint_t& rhs);
-
- template <typename D>
- E& operator-=(const abstract::dpoint<D>& rhs) const;
-
- /// \}
-
-
- /// \{
/// Operator -.
-
- E operator-(const dpoint_t& rhs) const;
-
- template <typename D>
- xtd_op_minus_trait(E, D) operator-(const abstract::dpoint<D>& rhs) const;
-
- /// \}
-
-
- /// \{
- /// Operator -.
-
- dpoint_t operator-(const E& rhs) const;
-
- template <typename P>
- xtd_op_minus_trait(E, P) operator-(const abstract::point<P>& rhs) const;
-
- /// \}
-
-
- const vec_t& vec() const;
- vec_t& vec();
-
-
- ~point()
- {
- // FIXME: See code below.
- }
+ dpoint op_minus_(const Exact& rhs) const;
protected:
+ Point();
- point();
-
- }; // end of class oln::abstract::point<E>
-
+ }; // end of oln::Point<Exact>
-# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool point<E>::operator=(const E& rhs) const
- {
- return this->exact().impl_equal(rhs);
- }
-
- template <typename E>
+ /// Operator -.
template <typename P>
- bool point<E>::operator=(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_equal(rhs.exact());
- }
-
- template <typename E>
- bool point<E>::operator!=(const E& rhs) const
- {
- return not (*this = rhs);
- }
+ typename P::dpoint operator-(const Point<P>& lhs, const Point<P>& rhs);
- template <typename E>
- template <typename P>
- bool point<E>::operator!=(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return not (*this = rhs);
- }
- template <typename E>
- bool point<E>::operator<(const E& rhs) const
- {
- return this->exact().impl_less(rhs);
- }
- template <typename E>
- template <typename P>
- bool point<E>::operator<(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_less(rhs.exact());
- }
-
- template <typename E>
- bool point<E>::operator>(const E& rhs) const
- {
- return rhs < *this;
- }
+ /// \{
+ /// Invalid operators.
- template <typename E>
template <typename P>
- bool point<E>::operator>(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return rhs < *this;
- }
-
- template <typename E>
- bool point<E>::operator>=(const E& rhs) const
- {
- return not (*this < rhs);
- }
+ void operator-(const Point<P>& rhs) /* error */ ;
- template <typename E>
- template <typename P>
- bool point<E>::operator>=(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return not (*this < rhs);
- }
+ template <typename P1, typename P2>
+ void operator+(const Point<P1>& lhs, const Point<P2>& rhs) /* error */ ;
- template <typename E>
- bool point<E>::operator<=(const E& rhs) const
- {
- return not (rhs < *this);
- }
+ /// \}
- template <typename E>
- template <typename P>
- bool point<E>::operator<=(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return not (rhs < *this);
- }
- template <typename E>
- E& point<E>::operator+=(const typename point<E>::dpoint_t& rhs)
- {
- return this->exact().impl_plus_equal(rhs);
- }
- template <typename E>
- template <typename D>
- E& point<E>::operator+=(const abstract::dpoint<D>& rhs)
- {
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(D, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_plus_equal(rhs.exact());
- }
+# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- E point<E>::operator+(const typename point<E>::dpoint_t& rhs) const
- {
- return this->exact().impl_plus(rhs);
- }
- template <typename E>
- template <typename D>
- xtd_op_plus_trait(E,D) point<E>::operator+(const abstract::dpoint<D>& rhs) const
+ template <typename Exact>
+ bool Point<Exact>::op_equal_(const Exact& rhs) const
{
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(D, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_plus(rhs.exact());
+ return exact(this)->impl_op_equal_(rhs);
}
- template <typename E>
- E& point<E>::operator-=(const typename point<E>::dpoint_t& rhs)
+ template <typename Exact>
+ bool Point<Exact>::op_less_(const Exact& rhs) const
{
- return this->exact().impl_minus_equal(rhs);
+ return exact(this)->impl_op_less_(rhs);
}
- template <typename E>
- template <typename D>
- E& point<E>::operator-=(const abstract::dpoint<D>& rhs) const
+ template <typename Exact>
+ Exact& Point<Exact>::op_plus_equal_(const typename Point<Exact>::dpoint& rhs)
{
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(D, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_minus_equal(rhs.exact());
+ return exact(this)->impl_op_plus_equal_(rhs);
}
- template <typename E>
- E point<E>::operator-(const typename point<E>::dpoint_t& rhs) const
+ template <typename Exact>
+ Exact& Point<Exact>::op_minus_equal_(const typename Point<Exact>::dpoint& rhs)
{
- return this->exact().impl_minus(rhs);
+ return exact(this)->impl_op_minus_equal_(rhs);
}
- template <typename E>
- template <typename D>
- xtd_op_minus_trait(E, D) point<E>::operator-(const abstract::dpoint<D>& rhs) const
+ template <typename Exact>
+ typename Point<Exact>::dpoint Point<Exact>::op_minus_(const Exact& rhs) const
{
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(D, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_minus(rhs.exact());
+ return exact(this)->impl_op_minus_(rhs);
}
- template <typename E>
- typename point<E>::dpoint_t point<E>::operator-(const E& rhs) const
+ template <typename Exact>
+ Point<Exact>::Point()
{
- return this->exact().impl_minus(rhs);
+ // mlc::assert_defined_< oln_vtype(Exact, grid) >::check();
+ // mlc::assert_defined_< oln_vtype(Exact, dPoint) >::check();
+ // mlc::assert_defined_< oln_vtype(Exact, coord) >::check();
+ // mlc::assert_defined_< oln_vtype(Exact, dim) >::check();
}
- template <typename E>
template <typename P>
- xtd_op_minus_trait(E, P) point<E>::operator-(const abstract::point<P>& rhs) const
- {
- mlc::assert_equal_< oln_vtype(E, grid),
- oln_vtype(P, grid),
- oln::ERROR::OPERANDS_ARE_NOT_COMPATIBLE >::check();
- return this->exact().impl_minus(rhs.exact());
- }
-
- template <typename E>
- const typename point<E>::vec_t&
- point<E>::vec() const
- {
- return this->exact().impl_vec();
- }
-
- template <typename E>
- typename point<E>::vec_t&
- point<E>::vec()
- {
- return this->exact().impl_vec();
- }
-
- template <typename E>
- point<E>::point()
+ typename P::dpoint operator-(const Point<P>& lhs, const Point<P>& rhs)
{
+ return lhs.op_minus_(exact(rhs));
}
-// template <typename E>
-// point<E>::~point()
-// {
-// mlc::assert_defined_< oln_vtype(E, grid) >::check();
-// mlc::assert_defined_< oln_vtype(E, dpoint) >::check();
-// mlc::assert_defined_< oln_vtype(E, coord) >::check();
-// mlc::assert_defined_< oln_vtype(E, dim) >::check();
-// }
-
# endif
- } // end of namespace oln::abstract
-
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_POINT_HH
+#endif // ! OLN_CORE_CONCEPT_POINT_HH
Index: oln/core/concept/dpoint.hh
--- oln/core/concept/dpoint.hh (revision 0)
+++ oln/core/concept/dpoint.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,10 +26,10 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_DPOINT_HH
-# define OLN_CORE_ABSTRACT_DPOINT_HH
+#ifndef OLN_CORE_CONCEPT_DPOINT_HH
+# define OLN_CORE_CONCEPT_DPOINT_HH
-# include <oln/core/typedefs.hh>
+# include <oln/core/concept/point.hh>
@@ -46,103 +46,125 @@
};
- // Forward declaration.
- namespace abstract { template <typename E> class dpoint; }
- template <typename E>
- struct set_super_type< abstract::dpoint<E> >
+ /// Abstract dpoint class.
+ template <typename Exact>
+ struct Dpoint : public Any<Exact>
{
- typedef mlc::none ret;
- };
+ stc_typename(grid);
+ stc_typename(coord);
+ stc_typename(dim);
+ stc_typename(point);
+ enum { n = mlc_value(dim) };
- /// Virtual types associated to abstract::dpoint<E>.
- template <typename E>
- struct vtypes< abstract::dpoint<E> >
- {
- // FIXME: Prefer to use final<deduce..> when possible.
- typedef stc::abstract grid_type;
- typedef stc::abstract point_type;
- typedef stc::abstract coord_type;
- typedef stc::abstract dim_type;
- };
+ /// Operator =.
+ bool op_equal_(const Exact& rhs) const;
+ /// Operator <.
+ bool op_less_(const Exact& rhs) const;
+ /// Operator +=.
+ Exact& op_plus_equal_(const Exact& rhs);
- namespace abstract
- {
+ /// Operator -=.
+ Exact& op_minus_equal_(const Exact& rhs);
- /// Abstract dpoint class.
- template <typename E>
- class dpoint : public stc::any__simple<E>,
- public oln::type
- {
- public:
+ /// Operator -.
+ Exact op_unary_minus_() const;
- bool operator=(const abstract::dpoint<E>& rhs) const;
- bool operator!=(const abstract::dpoint<E>& rhs) const;
+ protected:
+ Dpoint();
- bool operator< (const abstract::dpoint<E>& rhs) const;
- bool operator> (const abstract::dpoint<E>& rhs) const;
- bool operator>=(const abstract::dpoint<E>& rhs) const;
- bool operator<=(const abstract::dpoint<E>& rhs) const;
+ }; // end of oln::Dpoint<Exact>
- ~dpoint()
- {
- // FIXME: Code is below.
- }
- protected:
+ template <typename P, typename D>
+ P operator-(const Point<P>& lhs, const Dpoint<D>& rhs);
- dpoint();
- };
+ template <typename P, typename D>
+ P operator+(const Point<P>& lhs, const Dpoint<D>& rhs);
+
+
+ /// \{
+ /// Invalid operators.
+
+ template <typename D, typename P>
+ void operator-(const Dpoint<D>& lhs, const Point<P>& rhs) /* error */ ;
+
+ template <typename D, typename P>
+ void operator+(const Dpoint<D>& lhs, const Point<P>& rhs) /* error */ ;
+
+ /// \}
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- bool dpoint<E>::operator=(const abstract::dpoint<E>& rhs) const
+
+ template <typename Exact>
+ bool Dpoint<Exact>::op_equal_(const Exact& rhs) const
{
- return this->exact().impl_eq(rhs.exact());
+ return exact(this)->impl_op_equal_(rhs);
}
- template <typename E>
- bool dpoint<E>::operator!=(const abstract::dpoint<E>& rhs) const { return not (*this = rhs); }
+ template <typename Exact>
+ bool Dpoint<Exact>::op_less_(const Exact& rhs) const
+ {
+ return exact(this)->impl_op_less_(rhs);
+ }
+
+ template <typename Exact>
+ Exact& Dpoint<Exact>::op_plus_equal_(const Exact& rhs)
+ {
+ return exact(this)->impl_op_plus_equal_(rhs);
+ }
+
+ template <typename Exact>
+ Exact& Dpoint<Exact>::op_minus_equal_(const Exact& rhs)
+ {
+ return exact(this)->impl_op_minus_equal_(rhs);
+ }
- template <typename E>
- bool dpoint<E>::operator<(const abstract::dpoint<E>& rhs) const
+ template <typename Exact>
+ Exact Dpoint<Exact>::op_unary_minus_() const
{
- return this->exact().impl_less(rhs.exact());
+ return exact(this)->impl_op_unary_minus_();
}
- template <typename E>
- bool dpoint<E>::operator> (const abstract::dpoint<E>& rhs) const { return rhs < *this; }
+ template <typename Exact>
+ Dpoint<Exact>::Dpoint()
+ {
+ // mlc::assert_defined_< oln_vtype(Exact, grid) >::check();
+ // mlc::assert_defined_< oln_vtype(Exact, point) >::check();
+ // mlc::assert_defined_< oln_vtype(Exact, coord) >::check();
+ // mlc::assert_defined_< oln_vtype(Exact, dim) >::check();
+ }
- template <typename E>
- bool dpoint<E>::operator>=(const abstract::dpoint<E>& rhs) const { return not (*this < rhs); }
- template <typename E>
- bool dpoint<E>::operator<=(const abstract::dpoint<E>& rhs) const { return not (rhs < *this); }
+ /// \{
+ /// Operators.
+
+ template <typename P, typename D>
+ P operator-(const Point<P>& lhs, const Dpoint<D>& rhs)
+ {
+ P tmp = exact(lhs);
+ return tmp -= rhs;
+ }
- template <typename E>
- dpoint<E>::dpoint()
- {}
+ template <typename P, typename D>
+ P operator+(const Point<P>& lhs, const Dpoint<D>& rhs)
+ {
+ P tmp = exact(lhs);
+ return tmp += rhs;
+ }
-// template <typename E>
-// dpoint<E>::~dpoint() {
-// mlc::assert_defined_< oln_vtype(E, grid) >::check();
-// mlc::assert_defined_< oln_vtype(E, point) >::check();
-// mlc::assert_defined_< oln_vtype(E, coord) >::check();
-// mlc::assert_defined_< oln_vtype(E, dim) >::check();
-// }
+ /// \}
# endif
- } // end of namespace oln::abstract
-
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_DPOINT_HH
+#endif // ! OLN_CORE_CONCEPT_DPOINT_HH
Index: oln/core/concept/operators.hh
--- oln/core/concept/operators.hh (revision 0)
+++ oln/core/concept/operators.hh (revision 0)
@@ -0,0 +1,181 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_CONCEPT_OPERATORS_HH
+# define OLN_CORE_CONCEPT_OPERATORS_HH
+
+# include <oln/core/equipment.hh>
+
+
+namespace oln
+{
+
+ /// \{
+ /// Operator = (default version).
+
+ template <typename L, typename R>
+ bool operator=(const Any<L>& lhs, const Any<R>& rhs)
+ {
+ return exact(lhs).op_equal_(exact(rhs));
+ }
+
+ /// \}
+
+
+ /// \{
+ /// Operator != (default version).
+
+ template <typename L, typename R>
+ bool operator!=(const Any<L>& lhs, const Any<R>& rhs)
+ {
+ return not (lhs = rhs);
+ }
+
+ /// \}
+
+
+ /// \{
+ /// Operator < (default version).
+
+ template <typename L, typename R>
+ bool operator< (const Any<L>& lhs, const Any<R>& rhs)
+ {
+ return exact(lhs).op_less_(exact(rhs));
+ }
+
+ /// \}
+
+
+ /// \{
+ /// Operator > (default version).
+
+ template <typename L, typename R>
+ bool operator> (const Any<L>& lhs, const Any<R>& rhs)
+ {
+ return rhs < lhs;
+ }
+
+ /// \}
+
+
+ /// \{
+ /// Operator >= (default version).
+
+ template <typename L, typename R>
+ bool operator>=(const Any<L>& lhs, const Any<R>& rhs)
+ {
+ return not (lhs < rhs);
+ }
+
+ /// \}
+
+
+ /// \{
+ /// Operator <= (default version).
+
+ template <typename L, typename R>
+ bool operator<=(const Any<L>& lhs, const Any<R>& rhs)
+ {
+ return not (rhs < lhs);
+ }
+
+ /// \}
+
+
+ /// \{
+ /// Operator += (default version).
+
+ template <typename L, typename R>
+ L& operator+=(Any<L>& lhs, const Any<R>& rhs)
+ {
+ return exact(lhs).op_plus_equal_(exact(rhs));
+ }
+
+ /// \}
+
+
+ /// \{
+ /// Operators + (default versions).
+
+ template <typename T>
+ T operator+ (const Any<T>& lhs, const Any<T>& rhs)
+ {
+ T tmp = exact(lhs);
+ return tmp += rhs;
+ }
+
+// template <typename L, typename R>
+// xtd_op_plus_trait(L, R) operator+ (const Any<L>& lhs, const Any<R>& rhs)
+// {
+// return exact(lhs).op_plus_(exact(rhs));
+// }
+
+ /// \}
+
+
+ /// \{
+ /// Operator -= (default version).
+
+ template <typename L, typename R>
+ L& operator-=(Any<L>& lhs, const Any<R>& rhs)
+ {
+ return exact(lhs).op_minus_equal_(exact(rhs));
+ }
+
+ /// \}
+
+
+ /// \{
+ /// Operators - (default versions).
+
+ template <typename T>
+ T operator- (const Any<T>& rhs)
+ {
+ return exact(rhs).op_unary_minus_();
+ }
+
+ template <typename T>
+ T operator- (const Any<T>& lhs, const Any<T>& rhs)
+ {
+ T tmp = exact(lhs);
+ return tmp -= rhs;
+ }
+
+// template <typename L, typename R>
+// xtd_op_minus_trait(L, R) operator- (const Any<L>& lhs, const Any<R>& rhs)
+// {
+// return exact(lhs).op_minus_(exact(rhs));
+// }
+
+ /// \}
+
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_CONCEPT_OPERATORS_HH
Index: oln/core/2d/dpoint2d.hh
--- oln/core/2d/dpoint2d.hh (revision 842)
+++ oln/core/2d/dpoint2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,109 +29,59 @@
#ifndef OLN_CORE_2D_DPOINT2D_HH
# define OLN_CORE_2D_DPOINT2D_HH
-# include <mlc/int.hh>
-# include <oln/core/2d/point2d.hh>
-# include <oln/core/internal/dpoint_nd.hh>
+# include <oln/core/2d/grid2d.hh>
+# include <oln/core/internal/dpoint2d.hh>
namespace oln
{
- typedef dpoint2d_<int> dpoint2d;
+
+ struct point2d;
+ struct dpoint2d;
/// Super type.
- template<typename C>
- struct set_super_type< dpoint2d_<C> >
+ template<>
+ struct super_trait_< dpoint2d >
{
- typedef internal::dpoint_nd< dpoint2d_<C> > ret;
+ typedef internal::dpoint2d_< dpoint2d > ret;
};
- /// Fwd decls.
- template <unsigned D> struct grid_;
- typedef grid_<2> grid2d;
- template <typename C> struct point2d_;
- typedef point2d_<int> point2d;
-
-
- /// Virtual types associated to oln::dpoint2d_<C>.
- template <typename C>
- struct vtypes< dpoint2d_<C> >
- {
- typedef grid2d grid_type;
- typedef point2d point_type;
- typedef C coord_type;
- typedef mlc::uint_<2> dim_type;
-
- typedef mlc::uint_<0> row_comp_type;
- typedef mlc::uint_<1> col_comp_type;
+ /// Virtual types.
+ template <>
+ struct vtypes< dpoint2d >
+ {
+ typedef grid2d grid;
+ typedef int coord;
+ typedef point2d point;
};
- /// General 2D dpoint class.
- template <typename C>
- class dpoint2d_
- : public internal::dpoint_nd< dpoint2d_<C> >
+ /// Usual 2D dpoint class.
+ class dpoint2d : public internal::dpoint2d_< dpoint2d >
{
- typedef dpoint2d_<C> self_t;
- typedef internal::dpoint_nd<self_t> super_t;
-
- using super_t::v_;
-
public:
-
- /// Ctor.
- dpoint2d_();
-
- /// Ctor.
- dpoint2d_(const xtd::vec<2,C>& v);
-
- /// Ctor.
- dpoint2d_(C row, C col);
-
- C row() const;
- C& row();
-
- C col() const;
- C& col();
+ /// Ctors.
+ dpoint2d();
+ dpoint2d(int row, int col);
};
# ifndef OLN_INCLUDE_ONLY
- template <typename C>
- dpoint2d_<C>::dpoint2d_()
- {
- }
-
- /// Ctor.
- template <typename C>
- dpoint2d_<C>::dpoint2d_(const xtd::vec<2,C>& v)
- : super_t(v)
+ dpoint2d::dpoint2d()
{
}
- /// Ctor.
- template <typename C>
- dpoint2d_<C>::dpoint2d_(C row, C col)
- : super_t(xtd::mk_vec(row, col))
+ dpoint2d::dpoint2d(int row, int col)
{
+ this->row() = row;
+ this->col() = col;
}
- template <typename C>
- C dpoint2d_<C>::row() const { return v_[0]; }
-
- template <typename C>
- C& dpoint2d_<C>::row() { return v_[0]; }
-
- template <typename C>
- C dpoint2d_<C>::col() const { return v_[1]; }
-
- template <typename C>
- C& dpoint2d_<C>::col() { return v_[1]; }
-
# endif
Index: oln/core/2d/grid2d.hh
--- oln/core/2d/grid2d.hh (revision 0)
+++ oln/core/2d/grid2d.hh (revision 0)
@@ -0,0 +1,69 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_2D_GRID2D_HH
+# define OLN_CORE_2D_GRID2D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/concept/grid.hh>
+
+
+namespace oln
+{
+
+ struct grid2d;
+
+
+ /// Super type.
+ template<>
+ struct super_trait_< grid2d >
+ {
+ typedef Grid< grid2d > ret;
+ };
+
+
+ /// Virtual types.
+ template <>
+ struct vtypes< grid2d >
+ {
+ typedef mlc::uint_<2> dim;
+ };
+
+
+ /// Rectangular grid class.
+ class grid2d : public Grid< grid2d >
+ {
+ public:
+ /// Ctor.
+ grid2d() {}
+ };
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_2D_GRID2D_HH
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 842)
+++ oln/core/2d/point2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -29,125 +29,62 @@
#ifndef OLN_CORE_2D_POINT2D_HH
# define OLN_CORE_2D_POINT2D_HH
-# include <mlc/int.hh>
-# include <oln/core/internal/point_nd.hh>
+# include <oln/core/2d/grid2d.hh>
+# include <oln/core/internal/point2d.hh>
namespace oln
{
- /// Fwd decls.
- template <unsigned D> struct grid_;
- template <typename C> struct dpoint2d_;
- template <typename C> struct point2d_;
-
-
- typedef grid_<2> grid2d;
- typedef dpoint2d_<int> dpoint2d;
- typedef point2d_<int> point2d;
-
-
- /* FIXME: Is this the right place for these functions (on types)?
- In particular, the function on dpoint2d should be near the
- definition of dpoint2d, not point2d's. */
- /// Specializations of functions point and dpoint :
- /// \f$(n, coord) \rightarrow type\f$ for \f$n = 2\f$.
- /// \{
- template <typename C> struct point_ <2, C> { typedef point2d_<C> ret; };
- template <typename C> struct dpoint_ <2, C> { typedef dpoint2d_<C> ret; };
- /// \}
+ struct point2d;
+ struct dpoint2d;
/// Super type.
- template<typename C>
- struct set_super_type< point2d_<C> >
+ template<>
+ struct super_trait_< point2d >
{
- typedef internal::point_nd< point2d_<C> > ret;
+ typedef internal::point2d_< point2d > ret;
};
- /// Virtual types associated to oln::point2d_<C>.
- template <typename C>
- struct vtypes< point2d_<C> >
- {
- typedef grid2d grid_type;
- typedef dpoint2d dpoint_type;
- typedef C coord_type;
- typedef mlc::uint_<2> dim_type;
-
- typedef mlc::uint_<0> row_comp_type;
- typedef mlc::uint_<1> col_comp_type;
+ /// Virtual types.
+ template <>
+ struct vtypes< point2d >
+ {
+ typedef grid2d grid;
+ typedef int coord;
+ typedef dpoint2d dpoint;
};
- /// General 2D point class.
- template <typename C>
- class point2d_ : public internal::point_nd< point2d_<C> >
+ /// Usual 2D point class.
+ class point2d : public internal::point2d_< point2d >
{
- typedef point2d_<C> self_t;
- typedef internal::point_nd<self_t> super_t;
-
- using super_t::v_;
-
public:
-
- /// Ctor.
- point2d_();
-
- /// Ctor.
- point2d_(C row, C col);
-
- /// Ctor.
- point2d_(const xtd::vec<2,C>& v);
-
- /// Dtor.
- ~point2d_()
- {
- }
-
- C row() const;
- C& row();
-
- C col() const;
- C& col();
+ /// Ctors.
+ point2d();
+ point2d(int row, int col);
};
# ifndef OLN_INCLUDE_ONLY
- template <typename C>
- point2d_<C>::point2d_()
+ point2d::point2d()
{
}
- template <typename C>
- point2d_<C>::point2d_(C row, C col)
- : super_t (xtd::mk_vec(row, col))
+ point2d::point2d(int row, int col)
{
+ this->row() = row;
+ this->col() = col;
}
- template <typename C>
- point2d_<C>::point2d_(const xtd::vec<2,C>& v)
- : super_t(v)
- {
- }
-
- template <typename C>
- C point2d_<C>::row() const { return v_[0]; }
-
- template <typename C>
- C& point2d_<C>::row() { return v_[0]; }
-
- template <typename C>
- C point2d_<C>::col() const { return v_[1]; }
-
- template <typename C>
- C& point2d_<C>::col() { return v_[1]; }
-
# endif
+
} // end of namespace oln
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 0)
+++ oln/core/equipment.hh (revision 0)
@@ -0,0 +1,65 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_EQUIPMENT_HH
+# define OLN_CORE_EQUIPMENT_HH
+
+# include <cassert>
+# include <mlc/value.hh>
+# include <mlc/contract.hh>
+# include <oln/stc/scoop.hh> // FIXME: Remove "oln/" later.
+
+
+namespace oln
+{
+
+# include <oln/stc/scoop.hxx> // FIXME: Remove "oln/" later.
+
+
+ stc_decl_associated_type(grid);
+ stc_decl_associated_type(coord);
+ stc_decl_associated_type(dim);
+ stc_decl_associated_type(point);
+ stc_decl_associated_type(dpoint);
+ stc_decl_associated_type(psite);
+ stc_decl_associated_type(index);
+ stc_decl_associated_type(value);
+ stc_decl_associated_type(rvalue);
+ stc_decl_associated_type(lvalue);
+ stc_decl_associated_type(iter);
+ stc_decl_associated_type(data);
+ stc_decl_associated_type(box);
+ stc_decl_associated_type(pset);
+ stc_decl_associated_type(n);
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLN_CORE_EQUIPMENT_HH
+
Index: oln/core/internal/tracked_ptr.hh
--- oln/core/internal/tracked_ptr.hh (revision 842)
+++ oln/core/internal/tracked_ptr.hh (working copy)
@@ -31,6 +31,8 @@
# include <set>
# include <ostream>
+# include <mlc/contract.hh>
+
namespace oln
{
Index: oln/core/internal/point_base.hh
--- oln/core/internal/point_base.hh (revision 841)
+++ oln/core/internal/point_base.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,104 +26,74 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_INTERNAL_POINT_ND_HH
-# define OLN_CORE_INTERNAL_POINT_ND_HH
+#ifndef OLN_CORE_INTERNAL_POINT_BASE_HH
+# define OLN_CORE_INTERNAL_POINT_BASE_HH
# include <xtd/vec.hh>
-# include <xtd/optraits.hh>
-// FIXME: There should be a header grouping the files required to make
-// the extensible traits mechanism work.
-# include <oln/core/traits_id.hh>
-# include <oln/value/proxy.hh>
-# include <oln/core/traits.hh>
+# include <mlc/int.hh>
+# include <oln/core/concept/point.hh>
-# include <oln/core/abstract/point.hh>
-# include <oln/core/internal/dpoint_nd.hh>
namespace oln
{
- /// Function \f$point : (n, coord) \rightarrow point type\f$.
+ // Fwd decl.
+ namespace internal { template <typename Exact> class point_base_; }
- template <unsigned n, typename C>
- struct point_
+ template <typename Exact>
+ struct super_trait_< internal::point_base_<Exact> >
{
- typedef mlc::undefined ret;
+ typedef Point<Exact> ret;
};
+ template <typename Exact>
+ struct vtypes< internal::point_base_<Exact> >
+ {
+ typedef stc::abstract grid;
+ typedef stc_deferred(grid) grid__;
+ typedef stc::final<stc_type(grid__, dim)> dim;
- // Forward declaration.
- namespace internal { template <typename E> class point_nd; }
-
-
-
- // Super type declaration.
- template <typename E>
- struct set_super_type< internal::point_nd<E> >
- {
- typedef abstract::point<E> ret;
+ typedef stc::abstract coord;
+ typedef stc::abstract dpoint;
};
-// FIXME: Already defined in vtypes< abstract::point<E> > (Why?).
-// template <typename E>
-// struct vtypes< internal::point_nd<E> >
-// {
-// private:
-// typedef oln_deferred_vtype(E, dim) dim_t;
-// typedef oln_deferred_vtype(E, coord) coord_t;
-// public:
-// typedef xtd::vec<mlc_value(dim_t), coord_t> vec_type;
-// };
-
namespace internal
{
- template <typename E>
- class point_nd : public abstract::point<E>
+ template <typename Exact>
+ class point_base_ : public Point<Exact>
{
- typedef point_nd<E> self_t;
- typedef oln_dim(E) dim_t;
- typedef oln_coord(E) coord_t;
- typedef oln_dpoint(E) dpoint_t;
- typedef xtd::vec< mlc_value(dim_t), coord_t> vec_t;
+ typedef Point<Exact> super;
public:
- enum { n = mlc_value(dim_t) };
-
- coord_t operator[](unsigned i) const;
- coord_t& operator[](unsigned i);
-
- bool impl_equal(const self_t& rhs) const;
+ stc_using(grid);
+ stc_using(coord);
+ stc_using(dim);
+ stc_using(dpoint);
- bool impl_less(const self_t& rhs) const;
+ coord operator[](unsigned i) const;
+ coord& operator[](unsigned i);
- E& impl_plus_equal(const dpoint_t& rhs);
+ bool impl_op_equal_(const Exact& rhs) const;
- E impl_plus(const dpoint_t& rhs) const;
+ bool impl_op_less_(const Exact& rhs) const;
- E& impl_minus_equal(const dpoint_t& rhs);
+ Exact& impl_op_plus_equal_(const dpoint& rhs); // Definition is in dpoint_base.hh
- E impl_minus(const dpoint_t& rhs) const;
+ Exact& impl_op_minus_equal_(const dpoint& rhs); // Likewise
- dpoint_t impl_minus(const self_t& rhs) const;
+ dpoint impl_op_minus_(const Exact& rhs) const; // Likewise
- const vec_t& impl_vec() const;
- vec_t& impl_vec();
+ typedef xtd::vec<n, coord> vec_t;
+ const vec_t& vec() const;
+ vec_t& vec();
protected:
-
- /// Ctor.
- point_nd();
-
- /// Ctor.
- point_nd(const vec_t& v);
-
- /// Dtor.
- ~point_nd();
+ point_base_();
vec_t v_;
};
@@ -131,97 +101,53 @@
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- typename point_nd<E>::coord_t
- point_nd<E>::operator[](unsigned i) const
+ template <typename Exact>
+ typename point_base_<Exact>::coord
+ point_base_<Exact>::operator[](unsigned i) const
{
assert(i < n);
return v_[i];
}
- template <typename E>
- typename point_nd<E>::coord_t&
- point_nd<E>::operator[](unsigned i)
+ template <typename Exact>
+ typename point_base_<Exact>::coord&
+ point_base_<Exact>::operator[](unsigned i)
{
assert(i < n);
return v_[i];
}
- template <typename E>
- bool point_nd<E>::impl_equal(const self_t& rhs) const
- {
- return v_ = rhs.vec();
- }
-
- template <typename E>
- bool point_nd<E>::impl_less(const self_t& rhs) const
+ template <typename Exact>
+ bool point_base_<Exact>::impl_op_equal_(const Exact& rhs) const
{
- return xtd::lexi_less(v_, rhs.vec());
+ return v_ = rhs.v_;
}
- template <typename E>
- E& point_nd<E>::impl_plus_equal(const dpoint_t& rhs)
+ template <typename Exact>
+ bool point_base_<Exact>::impl_op_less_(const Exact& rhs) const
{
- v_ += rhs.vec();
- return this->exact();
+ return xtd::lexi_less(v_, rhs.v_);
}
- template <typename E>
- E point_nd<E>::impl_plus(const dpoint_t& rhs) const
+ template <typename Exact>
+ const typename point_base_<Exact>::vec_t&
+ point_base_<Exact>::vec() const
{
- E tmp(v_ + rhs.vec());
- return tmp;
- }
-
- template <typename E>
- E& point_nd<E>::impl_minus_equal(const typename point_nd<E>::dpoint_t& rhs)
- {
- v_ += rhs.vec();
- return this->exact();
- }
-
- template <typename E>
- E point_nd<E>::impl_minus(const typename point_nd<E>::dpoint_t& rhs) const
- {
- E tmp(v_ - rhs.vec());
- return tmp;
- }
-
- template <typename E>
- typename point_nd<E>::dpoint_t
- point_nd<E>::impl_minus(const self_t& rhs) const
- {
- typename point_nd<E>::dpoint_t tmp(v_ - rhs.vec());
- return tmp;
+ return v_;
}
- template <typename E>
- const typename point_nd<E>::vec_t&
- point_nd<E>::impl_vec() const
+ template <typename Exact>
+ typename point_base_<Exact>::vec_t&
+ point_base_<Exact>::vec()
{
return v_;
}
- template <typename E>
- typename point_nd<E>::vec_t&
- point_nd<E>::impl_vec()
+ template <typename Exact>
+ point_base_<Exact>::point_base_()
{
- return v_;
}
- template <typename E>
- point_nd<E>::point_nd()
- {}
-
- template <typename E>
- point_nd<E>::point_nd(const typename point_nd<E>::vec_t& v) :
- v_(v)
- {}
-
- template <typename E>
- point_nd<E>::~point_nd()
- {}
-
# endif
@@ -229,14 +155,15 @@
} // end of namespace oln::internal
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const internal::point_base_<Exact>& p);
+
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr, const internal::point_nd<E>& p);
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- std::ostream& operator<<(std::ostream& ostr, const internal::point_nd<E>& p)
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const internal::point_base_<Exact>& p)
{
ostr << p.vec();
return ostr;
@@ -246,52 +173,53 @@
- /// internal::point_nd + internal::dpoint_nd
- template <typename P, typename D>
- struct case_ < xtd::op_plus, mlc::pair_<P,D>,
- oln::id::op_plus_pointnd_dpointnd >
- : where_< mlc::and_< mlc_is_a(P, internal::point_nd),
- mlc_is_a(D, internal::dpoint_nd) > >
- {
- typedef oln_vtype(P, coord) P_coord;
- typedef oln_vtype(D, coord) D_coord;
- typedef xtd_op_plus_trait(P_coord, D_coord) coord;
- typedef oln_vtype(P, dim) dim;
- typedef typename point_<mlc_value(dim), coord>::ret ret;
- };
+// /// internal::point_base_ + internal::dpoint_base_
+// template <typename P, typename D>
+// struct case_ < xtd::op_plus, mlc::pair_<P,D>,
+// oln::id::op_plus_pointnd_dpointnd >
+// : where_< mlc::and_< mlc_is_a(P, internal::point_base_),
+// mlc_is_a(D, internal::dpoint_base_) > >
+// {
+// typedef oln_vtype(P, coord) P_coord;
+// typedef oln_vtype(D, coord) D_coord;
+// typedef xtd_op_plus_trait(P_coord, D_coord) coord;
+// typedef oln_vtype(P, dim) dim;
+// typedef typename point_<mlc_value(dim), coord>::ret ret;
+// };
- /// internal::point_nd - internal::dpoint_nd
- template <typename P, typename D>
- struct case_ < xtd::op_minus, mlc::pair_<P,D>,
- oln::id::op_minus_pointnd_dpointnd >
- : where_< mlc::and_< mlc_is_a(P, internal::point_nd),
- mlc_is_a(D, internal::dpoint_nd) > >
- {
- typedef oln_vtype(P, coord) P_coord;
- typedef oln_vtype(D, coord) D_coord;
- typedef xtd_op_minus_trait(P_coord, D_coord) coord;
- typedef oln_vtype(P, dim) dim;
- typedef typename point_<mlc_value(dim), coord>::ret ret;
- };
+// /// internal::point_base_ - internal::dpoint_base_
+// template <typename P, typename D>
+// struct case_ < xtd::op_minus, mlc::pair_<P,D>,
+// oln::id::op_minus_pointnd_dpointnd >
+// : where_< mlc::and_< mlc_is_a(P, internal::point_base_),
+// mlc_is_a(D, internal::dpoint_base_) > >
+// {
+// typedef oln_vtype(P, coord) P_coord;
+// typedef oln_vtype(D, coord) D_coord;
+// typedef xtd_op_minus_trait(P_coord, D_coord) coord;
+// typedef oln_vtype(P, dim) dim;
+// typedef typename point_<mlc_value(dim), coord>::ret ret;
+// };
- /// internal::point_nd - internal::point_nd
- template <typename P1, typename P2>
- struct case_ < xtd::op_minus, mlc::pair_<P1,P2>,
- oln::id::op_minus_pointnd_pointnd >
- : where_< mlc::and_< mlc_is_a(P1, internal::point_nd),
- mlc_is_a(P2, internal::point_nd) > >
- {
- typedef oln_vtype(P1, coord) P1_coord;
- typedef oln_vtype(P2, coord) P2_coord;
- typedef xtd_op_minus_trait(P1_coord, P2_coord) coord;
- typedef oln_vtype(P1, dim) dim;
- typedef typename dpoint_<mlc_value(dim), coord>::ret ret;
- };
+// /// internal::point_base_ - internal::point_base_
+// template <typename P1, typename P2>
+// struct case_ < xtd::op_minus, mlc::pair_<P1,P2>,
+// oln::id::op_minus_pointnd_pointnd >
+// : where_< mlc::and_< mlc_is_a(P1, internal::point_base_),
+// mlc_is_a(P2, internal::point_base_) > >
+// {
+// typedef oln_vtype(P1, coord) P1_coord;
+// typedef oln_vtype(P2, coord) P2_coord;
+// typedef xtd_op_minus_trait(P1_coord, P2_coord) coord;
+// typedef oln_vtype(P1, dim) dim;
+// typedef typename dpoint_<mlc_value(dim), coord>::ret ret;
+// };
} // end of namespace oln
-#endif // ! OLN_CORE_INTERNAL_POINT_ND_HH
+
+#endif // ! OLN_CORE_INTERNAL_POINT_BASE_HH
Index: oln/core/internal/dpoint2d.hh
--- oln/core/internal/dpoint2d.hh (revision 0)
+++ oln/core/internal/dpoint2d.hh (revision 0)
@@ -0,0 +1,127 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
+// Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_DPOINT2D_HH
+# define OLN_CORE_INTERNAL_DPOINT2D_HH
+
+# include <oln/core/internal/dpoint_base.hh>
+
+
+namespace oln
+{
+
+
+ /// Fwd decls.
+ template <unsigned D> struct grid_;
+ namespace internal { template <typename Exact> struct dpoint2d_; }
+
+
+ /// Super type.
+ template<typename Exact>
+ struct super_trait_< internal::dpoint2d_<Exact> >
+ {
+ typedef internal::dpoint_base_<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::dpoint2d_<Exact> >
+ {
+ };
+
+
+ namespace internal
+ {
+
+
+ template <typename Exact>
+ class dpoint2d_ : public dpoint_base_<Exact>
+ {
+ typedef dpoint_base_<Exact> super;
+ stc_using(coord);
+
+ public:
+
+ coord row() const;
+ coord& row();
+
+ coord col() const;
+ coord& col();
+
+ protected:
+ dpoint2d_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ dpoint2d_<Exact>::dpoint2d_()
+ {
+ }
+
+ template <typename Exact>
+ typename dpoint2d_<Exact>::coord
+ dpoint2d_<Exact>::row() const
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename dpoint2d_<Exact>::coord &
+ dpoint2d_<Exact>::row()
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename dpoint2d_<Exact>::coord
+ dpoint2d_<Exact>::col() const
+ {
+ return this->v_[1];
+ }
+
+ template <typename Exact>
+ typename dpoint2d_<Exact>::coord &
+ dpoint2d_<Exact>::col()
+ {
+ return this->v_[1];
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_DPOINT2D_HH
Index: oln/core/internal/dpoint_base.hh
--- oln/core/internal/dpoint_base.hh (revision 0)
+++ oln/core/internal/dpoint_base.hh (revision 0)
@@ -0,0 +1,230 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
+// Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_DPOINT_BASE_HH
+# define OLN_CORE_INTERNAL_DPOINT_BASE_HH
+
+# include <xtd/vec.hh>
+# include <mlc/int.hh>
+# include <oln/core/concept/dpoint.hh>
+
+
+
+namespace oln
+{
+
+ // Fwd decl.
+ namespace internal { template <typename Exact> class dpoint_base_; }
+
+ template <typename Exact>
+ struct super_trait_< internal::dpoint_base_<Exact> >
+ {
+ typedef Dpoint<Exact> ret;
+ };
+
+ template <typename Exact>
+ struct vtypes< internal::dpoint_base_<Exact> >
+ {
+ typedef stc::abstract grid;
+
+ typedef stc_deferred(grid) grid__;
+ typedef stc::final<stc_type(grid__, dim)> dim;
+
+ typedef stc::abstract coord;
+ typedef stc::abstract point;
+ };
+
+
+ namespace internal
+ {
+
+ template <typename Exact>
+ class dpoint_base_ : public Dpoint<Exact>
+ {
+ typedef Dpoint<Exact> super;
+
+ public:
+
+ stc_using(grid);
+ stc_using(coord);
+ stc_using(dim);
+ stc_using(point);
+
+ coord operator[](unsigned i) const;
+ coord& operator[](unsigned i);
+
+ bool impl_op_equal_(const Exact& rhs) const;
+
+ bool impl_op_less_(const Exact& rhs) const;
+
+ Exact& impl_op_plus_equal_(const Exact& rhs);
+
+ Exact& impl_op_minus_equal_(const Exact& rhs);
+
+ Exact impl_op_unary_minus_() const;
+
+ typedef xtd::vec<n, coord> vec_t;
+ const vec_t& vec() const;
+ vec_t& vec();
+
+ protected:
+ dpoint_base_();
+
+ vec_t v_;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ typename dpoint_base_<Exact>::coord
+ dpoint_base_<Exact>::operator[](unsigned i) const
+ {
+ assert(i < n);
+ return v_[i];
+ }
+
+ template <typename Exact>
+ typename dpoint_base_<Exact>::coord&
+ dpoint_base_<Exact>::operator[](unsigned i)
+ {
+ assert(i < n);
+ return v_[i];
+ }
+
+ template <typename Exact>
+ bool dpoint_base_<Exact>::impl_op_equal_(const Exact& rhs) const
+ {
+ return v_ = rhs.v_;
+ }
+
+ template <typename Exact>
+ bool dpoint_base_<Exact>::impl_op_less_(const Exact& rhs) const
+ {
+ return xtd::lexi_less(v_, rhs.v_);
+ }
+
+ template <typename Exact>
+ Exact& dpoint_base_<Exact>::impl_op_plus_equal_(const Exact& rhs)
+ {
+ v_ += rhs.v_;
+ return *exact(this);
+ }
+
+ template <typename Exact>
+ Exact& dpoint_base_<Exact>::impl_op_minus_equal_(const Exact& rhs)
+ {
+ v_ -= rhs.v_;
+ return *exact(this);
+ }
+
+ template <typename Exact>
+ Exact dpoint_base_<Exact>::impl_op_unary_minus_() const
+ {
+ Exact tmp;
+ tmp.v_ = - v_;
+ return tmp;
+ }
+
+ template <typename Exact>
+ const typename dpoint_base_<Exact>::vec_t&
+ dpoint_base_<Exact>::vec() const
+ {
+ return v_;
+ }
+
+ template <typename Exact>
+ typename dpoint_base_<Exact>::vec_t&
+ dpoint_base_<Exact>::vec()
+ {
+ return v_;
+ }
+
+ template <typename Exact>
+ dpoint_base_<Exact>::dpoint_base_()
+ {
+ }
+
+
+ /// Extra code for internal::point_base_<Exact>.
+
+ template <typename Exact>
+ Exact&
+ point_base_<Exact>::impl_op_plus_equal_(const typename point_base_<Exact>::dpoint& rhs)
+ {
+ this->v_ += rhs.vec();
+ return *exact(this);
+ }
+
+ template <typename Exact>
+ Exact&
+ point_base_<Exact>::impl_op_minus_equal_(const typename point_base_<Exact>::dpoint& rhs)
+ {
+ this->v_ -= rhs.vec();
+ return *exact(this);
+ }
+
+ template <typename Exact>
+ typename point_base_<Exact>::dpoint
+ point_base_<Exact>::impl_op_minus_(const Exact& rhs) const
+ {
+ typename point_base_<Exact>::dpoint tmp;
+ tmp.vec() = this->v_ - rhs.vec();
+ return tmp;
+ }
+
+
+# endif // ! OLN_INCLUDE_ONLY
+
+
+
+ } // end of namespace oln::internal
+
+
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const internal::dpoint_base_<Exact>& p);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ std::ostream& operator<<(std::ostream& ostr, const internal::dpoint_base_<Exact>& p)
+ {
+ ostr << p.vec();
+ return ostr;
+ }
+
+# endif
+
+
+} // end of namespace oln
+
+
+
+#endif // ! OLN_CORE_INTERNAL_DPOINT_BASE_HH
Index: oln/core/internal/point2d.hh
--- oln/core/internal/point2d.hh (revision 0)
+++ oln/core/internal/point2d.hh (revision 0)
@@ -0,0 +1,127 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2006, 2007 EPITA Research and
+// Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_POINT2D_HH
+# define OLN_CORE_INTERNAL_POINT2D_HH
+
+# include <oln/core/internal/point_base.hh>
+
+
+namespace oln
+{
+
+
+ /// Fwd decls.
+ template <unsigned D> struct grid_;
+ namespace internal { template <typename Exact> struct point2d_; }
+
+
+ /// Super type.
+ template<typename Exact>
+ struct super_trait_< internal::point2d_<Exact> >
+ {
+ typedef internal::point_base_<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::point2d_<Exact> >
+ {
+ };
+
+
+ namespace internal
+ {
+
+
+ template <typename Exact>
+ class point2d_ : public point_base_<Exact>
+ {
+ typedef point_base_<Exact> super;
+ stc_using(coord);
+
+ public:
+
+ coord row() const;
+ coord& row();
+
+ coord col() const;
+ coord& col();
+
+ protected:
+ point2d_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ point2d_<Exact>::point2d_()
+ {
+ }
+
+ template <typename Exact>
+ typename point2d_<Exact>::coord
+ point2d_<Exact>::row() const
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename point2d_<Exact>::coord &
+ point2d_<Exact>::row()
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename point2d_<Exact>::coord
+ point2d_<Exact>::col() const
+ {
+ return this->v_[1];
+ }
+
+ template <typename Exact>
+ typename point2d_<Exact>::coord &
+ point2d_<Exact>::col()
+ {
+ return this->v_[1];
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_POINT2D_HH
Index: oln/stc/scoop.hh
--- oln/stc/scoop.hh (revision 0)
+++ oln/stc/scoop.hh (revision 0)
@@ -0,0 +1,155 @@
+// Copyright (C) 2005, 2006, 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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_STC_SCOOP_HH
+# define OLN_STC_SCOOP_HH
+
+# include <mlc/flags.hh>
+# include <mlc/typedef.hh>
+# include <mlc/ret.hh>
+# include <mlc/assert.hh>
+# include <mlc/abort.hh>
+# include <mlc/bool.hh>
+# include <mlc/pair.hh>
+# include <mlc/cmp.hh>
+# include <mlc/if.hh>
+# include <mlc/is_a.hh>
+# include <mlc/case.hh>
+
+
+
+
+namespace stc
+{
+
+ struct not_delegated;
+
+ struct abstract;
+
+ template <typename T>
+ struct final;
+
+ template < template <class> class >
+ struct is;
+
+ typedef mlc::true_ true_;
+ typedef mlc::false_ false_;
+
+
+
+
+ /// Equality test between a couple of types.
+ /// \{
+ template <typename T>
+ struct is_found : public mlc::bexpr_<true>
+ {};
+
+ template <>
+ struct is_found< mlc::not_found > : public mlc::bexpr_<false>
+ {};
+
+ template <typename T>
+ struct is_not_found : public mlc::bexpr_<false>
+ {};
+
+ template <>
+ struct is_not_found< mlc::not_found > : public mlc::bexpr_<true>
+ {};
+ /// \}
+
+
+
+} // end of namespace stc
+
+
+#define stc_decl_associated_type mlc_decl_typedef
+
+
+#define stc_super(T) typename super_trait_< T >::ret
+
+#define stc_stm(From, Target) typename get_stm< From , Target >::ret
+
+
+
+// Access to associated type
+# define stc_type_(From, Type) vtype<From, typedef_::Type>::ret
+# define stc_type(From, Type) typename stc_type_(From, Type)
+
+
+// below the more tolerant version is used, namely stc_deferred,
+// yet it sometimes can be replaced by "stc_find_type(E, Name)"
+# define stc_find_type_(From, Type) find_vtype<From, typedef_::Type>::ret
+# define stc_find_type(From, Type) typename stc_find_type_(From, Type)
+
+// Boolean expression counterpart of stc_find_type
+# define stc_type_is_found(Type) stc::is_found< stc_deferred(Type) >
+# define stc_type_is_not_found(Type) stc::is_not_found< stc_deferred(Type) >
+
+
+
+
+
+
+
+// For concepts.
+# define stc_typename(Type) typedef stc_type(Exact, Type) Type
+# define stc_using(Type) typedef typename super::Type Type
+# define stc_using_from(Abstraction, Type) typedef typename Abstraction<Exact>::Type Type
+# define stc_deduce_typename(Src, Type) typedef stc_type(Src, Type) Type
+
+
+// For impl classes.
+# define stc_deferred(Type) typename deferred_vtype<Exact, typedef_::Type >::ret
+# define stc_lookup(Type) typedef typename vtype< stc_type(current, exact_type), typedef_::Type>::ret Type
+
+// For set_impl classes.
+# define stc_deferred_typename(Type) typedef stc_deferred(Type) Type
+
+
+# define stc_deferred_type(From, Type) typename deferred_vtype< From, typedef_::Type >::ret
+
+
+
+// the macro below was called stc_prop which was ambiguous
+// (that lets us think that it is true_ or false_) but the
+// result is a mlc::bexpr_!
+// so it has been renamed as stc_is
+# define stc_is(Type) mlc::eq_< stc_find_type(E, Type), stc::true_ >
+
+// likewise:
+
+# define stc_is_not(Type) \
+ mlc::or_< mlc::eq_< stc_find_type(E, Type), \
+ mlc::not_found >, \
+ mlc::eq_< stc_find_type(E, Type), \
+ stc::false_ > >
+
+# define stc_prop(From, Type) typename mlc::eq_< stc_find_type(From, Type), stc::true_ >::eval
+
+
+
+#endif // ! OLN_STC_SCOOP_HH
Index: oln/stc/scoop.hxx
--- oln/stc/scoop.hxx (revision 0)
+++ oln/stc/scoop.hxx (revision 0)
@@ -0,0 +1,951 @@
+
+/* \file oln/stc/scoop.hxx
+ \brief To be included within a namespace to import SCOOP 2 equipment. */
+
+
+mlc_decl_typedef(exact_);
+
+mlc_decl_typedef(category);
+mlc_decl_typedef(behavior);
+mlc_decl_typedef(delegatee);
+
+
+
+namespace ERROR
+{
+
+ template < typename first_definition,
+ typename re_definition,
+ typename target >
+ struct final_vtype_redefined_;
+
+
+ template < typename first_definition,
+ typename declaration,
+ typename target >
+ struct vtype_declared_but_already_set_;
+
+
+ template < typename from,
+ typename target >
+ struct vtype_not_defined;
+
+
+ template < typename curr,
+ typename target,
+ typename stm >
+ struct wrong_final_stm_;
+
+
+ template < typename target,
+ typename declaration,
+ typename from >
+ struct vtype_declared_but_not_defined;
+
+
+ template <typename T>
+ struct _declaration_is_in_;
+
+ template <typename T>
+ struct _definition_is_looked_up_from_;
+
+
+ template <typename T>
+ struct _for_vtype_;
+
+
+ struct no_delegatee_declared_;
+
+
+} /* end of namespace ERROR */
+
+
+
+
+/* vtypes */
+
+template <typename from_type>
+struct vtypes
+{
+};
+
+template <typename from_type, typename type>
+struct single_vtype
+{
+ typedef mlc::not_found ret;
+};
+
+
+
+
+template <typename from_type>
+struct super_trait_;
+
+
+template <template <class> class abstraction, typename Exact>
+struct super_trait_< abstraction<Exact> >
+{
+ typedef mlc::none ret;
+};
+
+
+
+
+
+/* Any */
+
+template <typename Exact>
+struct Any;
+
+
+template <typename Exact>
+struct super_trait_< Any<Exact> >
+{
+ typedef mlc::none ret;
+};
+
+template <typename Exact>
+struct vtypes< Any<Exact> >
+{
+ typedef stc::final<Exact> exact_;
+};
+
+template <typename Exact>
+struct Any
+{
+ typedef Exact exact_;
+protected:
+ Any() {}
+};
+
+
+template <typename Exact>
+Exact& exact(Any<Exact>& ref)
+{
+ return *(Exact*)(void*)(&ref);
+}
+
+template <typename Exact>
+const Exact& exact(const Any<Exact>& cref)
+{
+ return *(const Exact*)(const void*)(&cref);
+}
+
+
+template <typename Exact>
+Exact* exact(Any<Exact>* ptr)
+{
+ return (Exact*)(void*)(ptr);
+}
+
+template <typename Exact>
+const Exact* exact(const Any<Exact>* cptr)
+{
+ return (const Exact*)(const void*)(cptr);
+}
+
+template <typename Exact>
+const Exact* my_exact(const Any<Exact>* cptr)
+{
+ return (const Exact*)(const void*)(cptr);
+}
+
+
+
+
+
+
+namespace internal
+{
+
+
+ /*
+ * Forward declarations.
+ */
+
+
+ template <typename from, typename target>
+ struct get_stm;
+
+ template <typename res1, typename res2>
+ struct helper_get_stm;
+
+ template <typename from, typename target>
+ struct first_stm;
+
+ template <typename curr, typename target, typename stm>
+ struct helper_first_stm;
+
+
+ template <typename from, typename target, typename curr = from>
+ struct superior_find;
+
+ template <typename from, typename target, typename curr, typename stm>
+ struct helper_superior_find;
+
+ template <typename from, typename target>
+ struct delegator_find;
+
+ template <typename from, typename target, typename delegatee>
+ struct helper_delegator_find;
+
+ template <typename from, typename target>
+ struct find;
+
+ template <typename from, typename target, typename where, typename res>
+ struct helper_find;
+
+
+
+ template <typename from, typename target>
+ struct check;
+
+ template <typename curr, typename target, typename stm>
+ struct helper_check;
+
+
+
+ /* get_stm(from, target)
+ *
+ * Returns the statement for class 'from' corresponding to 'target'.
+ * This statement is either defined in 'vtypes' or in 'single_vtype'.
+ *
+ * This routine is local; it does not recourse on superior classes.
+ *
+ */
+
+ template <typename res1>
+ struct helper_get_stm <res1, mlc::not_found>
+ {
+ typedef res1 ret;
+ };
+
+ template <typename res2>
+ struct helper_get_stm <mlc::not_found, res2>
+ {
+ typedef res2 ret;
+ };
+
+ template <>
+ struct helper_get_stm <mlc::not_found, mlc::not_found>
+ {
+ typedef mlc::not_found ret;
+ };
+
+ template <typename res1, typename res2>
+ struct helper_get_stm /* FIXME: Insert mlc::abort_<> statement here? */
+ {
+ /* error */
+ };
+
+ template <typename from, typename target>
+ struct get_stm
+ {
+ typedef vtypes<from> decl1;
+ typedef typename target::template from_<decl1>::ret res1;
+
+ typedef single_vtype<from, target> decl2;
+ typedef typename decl2::ret ret2;
+
+ typedef typename helper_get_stm<res1, ret2>::ret ret;
+ };
+
+
+
+
+ /* -------------------- */
+ /* Checking algorithm. */
+ /* -------------------- */
+
+ /*
+ * check_no_final_inherited
+ *
+ * FIXME: ...
+ */
+
+ template < typename orig, typename curr, typename target,
+ typename stm = typename get_stm<curr, target>::ret >
+ struct check_no_final_inherited
+
+ : mlc::assert_< mlc_is_not_a(stm, stc::final),
+ ERROR::final_vtype_redefined_< orig,
+ mlc::pair_<curr, stm>,
+ target >
+ >,
+ /* rec */ check_no_final_inherited<orig, stc_super(curr), target>
+ {
+ };
+
+ template <typename orig, typename target, typename stm>
+ struct check_no_final_inherited <orig, /* if curr = */ mlc::none, target, stm>
+ {
+ };
+
+
+ /*
+ * check_no_stm_inherited
+ *
+ * FIXME: ...
+ */
+
+ template < typename orig, typename curr, typename target,
+ typename stm = typename get_stm<curr, target>::ret >
+ struct check_no_stm_inherited
+
+ : mlc::assert_< stc::is_not_found<stm>,
+ ERROR::vtype_declared_but_already_set_< orig,
+ mlc::pair_<curr, stm>,
+ target >
+ >,
+ /* rec */ check_no_stm_inherited<orig, stc_super(curr), target>
+ {
+ };
+
+ template <typename orig, typename target, typename stm>
+ struct check_no_stm_inherited <orig, /* if curr = */ mlc::none, target, stm>
+ {
+ };
+
+
+ /*
+ * check_delegatee_inherited
+ */
+
+ template <typename curr, typename target>
+ struct check_delegatee_inherited
+ : mlc::assert_< stc::is_found< typename first_stm<curr,
+ typedef_::delegatee>::ret::second_elt >,
+ ERROR::no_delegatee_declared_ >
+ {
+ };
+
+
+ /*
+ * check_final_stm
+ */
+
+ template <typename curr, typename target, typename stm>
+ struct check_final_stm
+ {};
+
+ template <typename curr, typename target>
+ struct check_final_stm < curr, target, stc::abstract >
+ : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::abstract> > >
+ {};
+
+ template <typename curr, typename target, typename T>
+ struct check_final_stm < curr, target, stc::final<T> >
+ : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::final<T> > > >
+ {};
+
+ template <typename curr, typename target>
+ struct check_final_stm < curr, target, stc::not_delegated >
+ : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<stc::not_delegated> > >
+ {};
+
+ template <typename curr, typename target>
+ struct check_final_stm < curr, target, mlc::not_found >
+ : mlc::abort_< ERROR::wrong_final_stm_<curr, target, stc::final<mlc::not_found> > >
+ {};
+
+
+
+
+ /*
+ * check(from, target)
+ *
+ * pseudo-code:
+ *
+ * check(from, target)
+ * {
+ * if (from = mlc::none) // stop because no more class
+ * return done;
+ * else
+ * return helper_check(from, target, get_stm(from, target));
+ * }
+ */
+
+ struct dummy {};
+
+ template <typename target>
+ struct check < /* if from = */ mlc::none, target >
+ {
+ typedef dummy ret;
+ };
+
+ template <typename from, typename target>
+ struct check /* otherwise */
+ {
+ typedef typename helper_check< from, target,
+ stc_stm(from, target) >::ret ret;
+ };
+
+
+
+
+ /*
+ * pseudo-code:
+ *
+ * helper_check(curr, target, stm)
+ * {
+ * super = super(curr);
+ *
+ * if (stm = stc::abstract) {
+ * check_no_stm_inherited(curr, super, target);
+ * return check(super, target);
+ * }
+ * if (stm = stc::final<T>) {
+ * check_final_stm(T);
+ * check_no_final_inherited((curr, T), super, target);
+ * return check(super, target);
+ * }
+ * if (stm = stc::not_delegated) {
+ * check_delegatee_inherited(curr);
+ * check_no_final_inherited((curr, stc::not_delegated), super, target);
+ * return check(super, target);
+ * }
+ * if (stm = mlc::not_found) {
+ * return check(super, target);
+ * }
+ * // otherwise, non-final stm:
+ * if (stm = T) {
+ * check_no_final_inherited((curr, T), super, target);
+ * return check(super, target);
+ * }
+ * }
+ *
+ */
+
+ template <typename curr, typename target>
+ struct helper_check < curr, target,
+ /* if stm = */ stc::abstract >
+ : check_no_stm_inherited< mlc::pair_<curr, stc::abstract >,
+ stc_super(curr),
+ target >
+ {
+ typedef typename check<stc_super(curr), target>::ret ret;
+ };
+
+ template <typename curr, typename target, typename T>
+ struct helper_check < curr, target,
+ /* if stm = */ stc::final<T> >
+ : check_no_final_inherited< mlc::pair_<curr, stc::final<T> >,
+ stc_super(curr),
+ target >
+ {
+ /* FIXME:
+ check_final_stm(T);
+ */
+ typedef typename check<stc_super(curr), target>::ret ret;
+ };
+
+ template <typename curr, typename target>
+ struct helper_check < curr, target,
+ /* if stm = */ stc::not_delegated >
+ : check_no_final_inherited< mlc::pair_<curr, stc::not_delegated>,
+ stc_super(curr),
+ target >
+ {
+ /* FIXME:
+ check_delegatee_inherited(curr);
+ */
+ typedef typename check<stc_super(curr), target>::ret ret;
+ };
+
+ template <typename curr, typename target>
+ struct helper_check < curr, target,
+ /* if stm = */ mlc::not_found >
+ {
+ typedef typename check<stc_super(curr), target>::ret ret;
+ };
+
+ template <typename curr, typename target, typename stm>
+ struct helper_check /* otherwise, non-final stm */
+ : check_no_final_inherited< mlc::pair_<curr, stm>,
+ stc_super(curr),
+ target >
+ {
+ typedef typename check<stc_super(curr), target>::ret ret;
+ };
+
+
+
+ /* ------------------- */
+ /* Look-up algorithm. */
+ /* ------------------- */
+
+ /*
+ * first_stm(from, target)
+ *
+ * returns a pair (Where, Value) with Value being:
+ * - stc::abstract
+ * - stc::not_delegated
+ * - mlc::not_found
+ * - a type T
+ * and Where being the class where the stm is found.
+ *
+ *
+ * helper_first_stm(curr, target, stm)
+ * {
+ * if (stm = mlc::not_found)
+ * return first_stm(super(curr), target);
+ * else if (stm = stc::final<T>)
+ * return pair(curr, T);
+ * else
+ * return pair(curr, stm);
+ * }
+ *
+ * first_stm(from, target)
+ * {
+ * if (from = mlc::none)
+ * return pair(mlc::none, mlc::not_found);
+ * else
+ * return helper_first_stm(from, target,
+ * get_stm(from, target));
+ * }
+ *
+ */
+
+ template <typename curr, typename target>
+ struct helper_first_stm < curr, target,
+ /* if stm = */ mlc::not_found >
+ {
+ typedef typename first_stm<stc_super(curr), target>::ret ret;
+ };
+
+ template <typename curr, typename target, typename T>
+ struct helper_first_stm < curr, target,
+ /* if stm = */ stc::final<T> >
+ {
+ typedef mlc::pair_<curr, T> ret;
+ };
+
+ template <typename curr, typename target, typename stm>
+ struct helper_first_stm /* otherwise */
+ {
+ typedef mlc::pair_<curr, stm> ret;
+ };
+
+ template <typename target>
+ struct first_stm < /* if from = */ mlc::none, target >
+ {
+ typedef mlc::pair_<mlc::none, mlc::not_found> ret;
+ };
+
+ template <typename from, typename target>
+ struct first_stm /* otherwise */
+ {
+ typedef typename helper_first_stm<from, target,
+ stc_stm(from, target)>::ret ret;
+ };
+
+
+
+ /*
+ * superior_find(from, target)
+ *
+ * returns:
+ * either mlc::not_found
+ * or a type T
+ * behavior:
+ * - the stm stc::not_delegated is ignored
+ * - error when stc::abstract is reached
+ *
+ * helper_superior_find(from, target, curr, stm)
+ * {
+ * if (stm = stc::abstract)
+ * error("<target> declared in <curr> but not defined at <from>");
+ * else if (stm = mlc::not_found or
+ * stm = stc::not_delegated)
+ * return superior_find(from, target, super(curr));
+ * else if (stm = stc::final<T>)
+ * return T;
+ * else
+ * return stm;
+ * }
+ *
+ * superior_find(from, target, curr = from)
+ * {
+ * if (curr = mlc::none)
+ * return mlc::not_found;
+ * else
+ * return helper_superior_find(from, target, curr,
+ * get_stm(curr, target));
+ * }
+ */
+
+ template <typename from, typename target, typename curr>
+ struct helper_superior_find < from, target, curr,
+ /* if stm = */ stc::abstract >
+ {
+ /* FIXME: error("<target> declared in <curr> but not defined at <from>"); */
+ };
+
+ template <typename from, typename target, typename curr>
+ struct helper_superior_find < from, target, curr,
+ /* if stm = */ mlc::not_found >
+ {
+ typedef typename superior_find< from, target,
+ stc_super(curr) >::ret ret;
+ };
+
+ template <typename from, typename target, typename curr>
+ struct helper_superior_find < from, target, curr,
+ /* if stm = */ stc::not_delegated >
+ {
+ typedef typename superior_find< from, target,
+ stc_super(curr) >::ret ret;
+ };
+
+ template <typename from, typename target, typename curr, typename T>
+ struct helper_superior_find < from, target, curr,
+ /* if stm = */ stc::final<T> >
+ {
+ typedef T ret;
+ };
+
+ template <typename from, typename target, typename curr, typename stm>
+ struct helper_superior_find /* otherwise */
+ {
+ typedef stm ret;
+ };
+
+ template <typename from, typename target>
+ struct superior_find < from, target, /* if curr = */ mlc::none >
+ {
+ typedef mlc::not_found ret;
+ };
+
+ template <typename from, typename target, typename curr>
+ struct superior_find /* otherwise */
+ {
+ typedef typename helper_superior_find<from, target, curr,
+ stc_stm(curr, target)>::ret ret;
+ };
+
+
+
+ /*
+ * delegator_find(from, target)
+ *
+ *
+ * delegator_find(from, target)
+ * {
+ * precondition(target != delegatee);
+ * delegatee = superior_find(from, delegatee);
+ * if (delegatee = mlc::not_found)
+ * return mlc::not_found;
+ * else
+ * return find(delegatee, target);
+ * }
+ */
+
+ template <typename from, typename target>
+ struct helper_delegator_find < from, target,
+ /* if delegatee = */ mlc::not_found >
+ {
+ typedef mlc::not_found ret;
+ };
+
+ template <typename from, typename target, typename delegatee>
+ struct helper_delegator_find /* otherwise */
+ {
+ typedef typename find<delegatee, target>::ret ret;
+ };
+
+ template <typename from, typename target>
+ struct delegator_find
+ {
+ typedef typename superior_find<from, typedef_::delegatee>::ret delegatee;
+ typedef typename helper_delegator_find<from, target, delegatee>::ret ret;
+ };
+
+
+
+ /*
+ * helper_find(from, target, where, res)
+ *
+ *
+ *
+ */
+
+ template <typename from, typename target, typename where>
+ struct helper_find < from, target, where,
+ /* if res = */ mlc::not_found >
+ {
+ typedef typename delegator_find<from, target>::ret ret;
+ };
+
+ template <typename from, typename target, typename where>
+ struct helper_find < from, target, where,
+ /* if res = */ stc::abstract >
+ {
+ typedef typename delegator_find<from, target>::ret res_d;
+ struct check_
+ : mlc::assert_< stc::is_found<res_d>,
+ ERROR::vtype_declared_but_not_defined
+ < ERROR::_for_vtype_<target>,
+ ERROR::_declaration_is_in_<where>,
+ ERROR::_definition_is_looked_up_from_<from> > >
+ /* FIXME: error("<target> declared in <where> but not defined at <from>"); */
+ {
+ typedef res_d ret;
+ };
+ typedef typename check_::ret ret;
+ };
+
+ template <typename from, typename target, typename where>
+ struct helper_find < from, target, where,
+ /* if res = */ stc::not_delegated >
+ {
+ typedef typename superior_find<from, target>::ret ret;
+ };
+
+ template <typename from, typename target, typename where, typename res>
+ struct helper_find /* otherwise */
+ {
+ typedef res ret;
+ };
+
+
+
+ /*
+ * find(from, target)
+ *
+ * FIXME: ...
+ *
+ * find(from, target)
+ * {
+ * if (target = delegatee)
+ * return superior_find(from, delegatee);
+ * else
+ * return helper_find(from, target);
+ * }
+ */
+
+ template <typename from>
+ struct find <from, /* if target = */ typedef_::delegatee >
+ {
+ typedef typename superior_find<from, typedef_::delegatee>::ret ret;
+ };
+
+ template <typename from, typename target>
+ struct find /* otherwise */
+ {
+ typedef typename first_stm<from, target>::ret stm;
+ typedef mlc_elt(stm, 1) where;
+ typedef mlc_elt(stm, 2) res;
+ typedef typename helper_find<from, target,
+ where, res>::ret ret;
+ };
+
+
+} /* end of internal */
+
+
+/*
+ * find_vtype(from, target)
+ *
+ * FIXME:...
+ *
+ */
+
+template <typename from, typename target>
+struct deferred_vtype
+{
+ typedef typename internal::find<from, target>::ret ret;
+};
+
+template <typename from, typename target>
+struct find_vtype
+{
+ typedef typename internal::find<from, target>::ret ret;
+ typedef typename internal::check<from, target>::ret chk;
+};
+
+template <typename from, typename target>
+struct vtype
+{
+ typedef typename find_vtype<from, target>::ret res;
+ struct check_ : mlc::assert_< stc::is_found<res>,
+ ERROR::vtype_not_defined<from, target> >
+ {
+ typedef res ret;
+ };
+ typedef typename check_::ret ret;
+};
+
+
+
+mlc_case_equipment_for_namespace(internal);
+
+
+
+
+namespace internal
+{
+
+
+ template < template <class> class abstraction,
+ unsigned num = 1 >
+ struct selector
+ {
+ protected: selector() {}
+ };
+
+
+ /* fwd decl */
+ template < template <class> class abstraction, typename E, unsigned num >
+ struct plug_node;
+
+ template < template <class> class abstraction,
+ typename E,
+ unsigned num,
+ typename another_selector = mlc::false_ >
+ struct next_plug_node
+ {
+ /* here: no other selector */
+ protected: next_plug_node() {}
+ };
+
+ template < template <class> class abstraction,
+ typename E >
+ struct next_plug_node < abstraction, E, 1, mlc::false_ >
+ : public abstraction<E>
+ {
+ protected: next_plug_node() {}
+ };
+
+
+ template < template <class> class abstraction,
+ typename E,
+ unsigned num >
+ struct next_plug_node < abstraction,
+ E,
+ num,
+ mlc::true_>
+
+ : /* plug to client selectors */
+ public virtual switch_< selector<abstraction, num>, E >::ret,
+
+ /* here: another selector (number is 'num + 1') */
+ public plug_node<abstraction, E, num + 1>
+ {
+ protected: next_plug_node() {}
+ };
+
+
+ template < template <class> class abstraction,
+ typename E,
+ unsigned num >
+ struct plug_node
+ : public next_plug_node< abstraction,
+ E,
+ num,
+ typename mlc::is_defined_< case_< selector<abstraction, num>,
+ E, 1 > >::eval >
+ {
+ protected: plug_node() {}
+ };
+
+
+ template < template <class> class abstraction,
+ unsigned num,
+ typename E >
+ struct default_case_ < selector<abstraction, num>,
+ E >
+ {
+ typedef abstraction<E> ret;
+ };
+
+
+ template < template <class> class abstraction,
+ typename E >
+ struct plug : public plug_node<abstraction, E, 1>
+ {
+ protected: plug() {}
+ };
+
+ template <typename abstraction, typename E>
+ struct top;
+
+ template <template<class> class abstraction, typename E>
+ struct top < stc::is<abstraction>, E > : public plug< abstraction, E >
+ {
+ protected: top() {}
+ };
+
+ template <typename E>
+ struct top < mlc::none, E > : public Any<E>
+ {
+ protected: top() {}
+ };
+
+ template <typename E>
+ struct top < mlc::not_found, E >; /* FIXME: Error msg here */
+
+
+} /* end of namespace internal */
+
+
+/* top class */
+
+template <typename E> struct top;
+
+template <typename E>
+struct vtypes< top<E> >
+{
+ typedef stc::final<E> exact;
+ /* default is "no category" */
+};
+
+template <typename E>
+struct top : public internal::top< stc_find_type(E, category), E >
+{
+protected:
+ top() {}
+};
+
+
+
+namespace automatic
+{
+
+ /*
+ * set_impl
+ */
+
+ template < template <class> class abstraction, typename behavior, typename E >
+ struct set_impl
+ /* to be defined by the client */ ;
+
+
+
+ /*
+ * impl
+ */
+
+ template < template <class> class abstraction, typename behavior, typename E >
+ struct impl : public set_impl< abstraction, behavior, E >
+ { /* fetch */ };
+
+ template < template <class> class abstraction, typename E >
+ struct impl< abstraction, /* behavior is */ mlc::not_found, E >
+ { /* nothing */ };
+
+ template < template <class> class abstraction, typename E >
+ struct impl< abstraction, mlc::none /* behavior */, E >
+ { /* nothing */ };
+
+
+
+ /*
+ * get_impl
+ */
+
+ template < template <class> class abstraction, typename E >
+ struct get_impl : impl< abstraction, stc_find_type(E, behavior), E >
+ { /* depends upon behavior */ };
+
+
+} /* end of namespace automatic */
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Improve sanity checks.
* tests/sanity/Makefile.am (CPPFLAGS): Rename as...
(AM_CPPFLAGS): ...this.
(check): Rename as...
(check-local): ...this.
Pass CXX and CXXFLAGS variables to includes.test through the
environment.
Protect RHS in shell variable assignments.
Makefile.am | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
Index: tests/sanity/Makefile.am
--- tests/sanity/Makefile.am (revision 841)
+++ tests/sanity/Makefile.am (working copy)
@@ -10,17 +10,19 @@
XTD_LOCAL_CPPFLAGS = -I$(top_srcdir)/extended -I$(top_builddir)/extended
STC_LOCAL_CPPFLAGS = -I$(top_srcdir)/static -I$(top_builddir)/static
MLC_LOCAL_CPPFLAGS = -I$(top_srcdir)/metalic -I$(top_builddir)/metalic
-CPPFLAGS = \
+AM_CPPFLAGS = \
-I$(srcdir)/.. \
$(OLN_LOCAL_CPPFLAGS) $(XTD_LOCAL_CPPFLAGS) \
$(STC_LOCAL_CPPFLAGS) $(MLC_LOCAL_CPPFLAGS)
-check:
- TOP_SRCDIR=$(top_srcdir) SRCDIR=$(srcdir) \
- TOP_BUILDDIR=$(top_builddir) \
- PATH_TO_OLN_SRCDIR=$(OLN_LOCAL_SRC) \
- PATH_TO_OLN_BUILDDIR=$(OLN_LOCAL_BUILD) \
- CPPFLAGS="$(CPPFLAGS) $(DEFS) -I$(top_builddir)" \
+check-local:
+ TOP_SRCDIR="$(top_srcdir)" SRCDIR="$(srcdir)" \
+ TOP_BUILDDIR="$(top_builddir)" \
+ PATH_TO_OLN_SRCDIR="$(OLN_LOCAL_SRC)" \
+ PATH_TO_OLN_BUILDDIR="$(OLN_LOCAL_BUILD)" \
+ CXX="$(CXX)" \
+ CPPFLAGS="$(CPPFLAGS) $(AM_CPPFLAGS) $(DEFS) -I$(top_builddir)" \
+ CXXFLAGS="$(CXXFLAGS) $(AM_CXXFLAGS)" \
$(SHELL) $(srcdir)/includes.test
CLEANFILES = failures incltest.*
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Since ConceptGCC doesn't handle concept-c++/mini-oln yet, I've disabled
it.
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Fix mini-oln and its Concept-C++ counterpart.
* samples/mini-oln/mini-oln.cc,
(oln::Image_with_neighborhood::niter_t): New typedef.
(oln::iterator2d::impl_op_point_t)
(oln::iterator2d::impl_op_paren): Rename as...
(oln::iterator2d::impl_op_point_type)
(oln::iterator2d::impl_op_parens): ...this.
* samples/mini-oln/mini-oln.cc,
* samples/mini-oln/concept-c++/mini-oln.cc:
(oln::Image::operator(), oln::Image2d::operator())
(oln::Image3d::operator()): Fix the delegations.
(oln::set_super_type< image_base<E> >::ret): Set to mlc::none.
(oln::image2d::self_t): New typedef.
(oln::image2d::point_t, oln::image2d::iter_t)
(oln::image2d::value_t): Fix typedefs.
* samples/mini-oln/concept-c++/mini-oln.cc: s/where/requires/
(needed by recent revisions of SVN ConceptGCC).
Declare typedefs used
as virtual types at the beginning of the file
(concepts): Rename namespace as...
(oln::concepts): ...this.
Group together abstractions on the one hand, and implementations
on the other hand.
(oln::image_with_nbh): Rename class as...
(oln::Image_with_neighborhood): ...this.
(oln::vtypes< Iterator<E> >, oln::vtypes< Image<E> >)
(oln::vtypes<image_with_nbh>)
(oln::set_super_type<Image2d>, oln::set_super_type<Image3d>,
(oln::set_super_type<image_with_nbh>): Remove (useless and
semantically wrong definitions).
(oln::Iterator::point_t, oln::Image::point_t, Image::value_t)
(oln::Image2d::point_t, oln::Image2d::value_t)
(oln::Image3d::point_t, oln::Image3d::value_t)
(oln::Image_with_neighborhood::nbh_t)
(oln::Image_with_neighborhood::niter_t): Fix typedefs.
(oln::Image::iter_t, oln::Image2d::iter_t, oln::Image3d::iter_t):
Remove typedefs.
(oln::Iterator::start, oln::Iterator::next)
(oln::Iterator::is_valid, oln::Iterator::point_t)
(oln::Image::has)
(oln::Image2d::nrows_get, oln::Image2d::ncols_get)
(oln::Image3d::nrows_get, oln::Image3d::ncols_get)
(oln::Image3d::nslis_get, oln::Image_with_neighborhood nbh): Fix
the delegations.
* samples/mini-oln/concept-c++/mini-oln.cc
(oln::image_dimension_switch): Inherit oln::Image<E> by default.
(oln::vtypes< image_base<E> >::point_type)
(oln::vtypes< image_base<E> >::iter_type)
(oln::vtypes< image_base<E> >::value_type): Set to stc::abstract.
(oln::vtypes< image_base<E> >::niter_type)
(oln::vtypes< image_base<E> >::nbh_type): New typedefs.
(oln::image_base::point_t, oln::image_base::iter_t)
(oln::image_base::value_t): Remove typedefs.
(oln::image_base::operator(), oln::image_base::has): Remove
methods.
(oln::image_base::image_base): Add ctor.
* samples/mini-oln/concept-c++/mini-oln.cc
(oln::set_super_type<iterator2d>::ret): Set to mlc::none.
(oln::set_super_type<iterator2d>::start)
(oln::set_super_type<iterator2d>::next)
(oln::set_super_type<iterator2d>::is_valid)
(oln::set_super_type<iterator2d>::operator point_t): Rename as...
(oln::set_super_type<iterator2d>::impl_start)
(oln::set_super_type<iterator2d>::impl_next)
(oln::set_super_type<iterator2d>::impl_is_valid)
(oln::set_super_type<iterator2d>::impl_op_point_type): ...these.
(oln::image2d::operator(), oln::image2d::nrows_get)
(oln::image2d::ncols_get, oln::image2d::has): Rename as...
(oln::image2d::impl_op_parens, oln::image2d::impl_nrows_get)
(oln::image2d::impl_ncols_get, oln::image2d::impl_has): Rename as...
(oln::neighborhood2d): New class.
(oln::set_super_type< image_morpher<E> >::ret): Set to
image_base<E>.
(oln::vtypes< image_morpher<E> >::delegatee_t): Set to
stc::abstract.
(oln::image_morpher): Inherit from image_base<E>.
(oln::image_morpher::delegatee_t): Fix this typedef.
(oln::set_super_type< image_morpher < plus<I, N> > >): Turn
into...
(oln::set_super_type< plus<I, N> >): ...this.
(oln::vtypes< plus<I, N> >::delegatee_t): Rename as...
(oln::vtypes< plus<I, N> >::delegatee_type): ...this.
(oln::vtypes< plus<I, N> >::nbh_type)
(oln::vtypes< plus<I, N> >::niter_type): New typedefs.
(oln::plus::self_t, oln::plus::super_t): New typedefs.
(oln::plus::plus): Pass the equipped image to the ctor of the super
class.
(oln::plus::impl_nbh): New accessor.
(main): Rewrite the test.
* samples/mini-oln/concept-c++/Makefile.am: Disable mini-oln.
concept-c++/Makefile.am | 8
concept-c++/mini-oln.cc | 457 +++++++++++++++++++++++-------------------------
mini-oln.cc | 60 ++----
3 files changed, 252 insertions(+), 273 deletions(-)
Index: samples/mini-oln/concept-c++/mini-oln.cc
--- samples/mini-oln/concept-c++/mini-oln.cc (revision 840)
+++ samples/mini-oln/concept-c++/mini-oln.cc (working copy)
@@ -37,9 +37,13 @@
#include <stc/scoop.hh>
+/*-------------.
+| Equipement. |
+`-------------*/
+
// Helper macros.
#define oln_type_of_(FromType, Alias) \
- oln::find_vtype<FromType, oln::typedef_:: Alias##_type>::ret
+ find_vtype<FromType, oln::typedef_:: Alias##_type>::ret
#define oln_type_of(FromType, Alias) \
typename oln_type_of_(FromType, Alias)
@@ -48,12 +52,25 @@
stc_scoop_equipment_for_namespace(oln);
mlc_case_equipment_for_namespace(oln);
+// Virtual types declaration.
+namespace oln
+{
+ mlc_decl_typedef(point_type);
+ mlc_decl_typedef(iter_type);
+ mlc_decl_typedef(value_type);
+
+ mlc_decl_typedef(nbh_type);
+ mlc_decl_typedef(niter_type);
+}
/*-----------.
| Concepts. |
`-----------*/
+namespace oln
+{
+
namespace concepts
{
// These concepts are not automatic (i.e., prefixed with `auto'),
@@ -103,363 +120,302 @@
int I::ncols_get() const;
int I::nslis_get() const;
};
-}
+ } // End of namespace oln::concepts.
+} // End of namespace oln.
-/*-------------.
-| Mini-Olena. |
-`-------------*/
+/*---------------.
+| Abstractions. |
+`---------------*/
+
+namespace oln
+{
// ------- //
// Point. //
// ------- //
-namespace oln
-{
template <typename E>
struct Point : public stc::any<E>
{
};
- struct point2d : public Point<point2d>
- {
- typedef int coord_type;
- coord_type row;
- coord_type col;
- };
-
- struct point3d : public Point<point2d>
- {
- typedef int coord_type;
- coord_type row;
- coord_type col;
- coord_type sli;
- };
-}
-
-namespace concepts
-{
- concept_map Point2d<oln::point2d>
- {
- typedef oln::point2d::coord_type coord_type;
- };
-
- concept_map Point3d<oln::point3d>
- {
- typedef oln::point2d::coord_type coord_type;
- };
-}
-
// ---------- //
// Iterator. //
// ---------- //
-namespace oln
-{
- template <typename E>
- struct Iterator;
-
- mlc_decl_typedef(point_type);
-
- template <typename E>
- struct vtypes< Iterator<E> >
- {
- typedef mlc::undefined point_type;
- };
-
template <typename E>
struct Iterator : public stc::any<E>
{
- typedef oln_type_of(Iterator, point) point_t;
+ typedef oln_type_of(E, point) point_t;
void start()
{
- this->exact().start();
+ this->exact().impl_start();
}
void next()
{
- this->exact().next();
+ this->exact().impl_next();
}
bool is_valid() const
{
- return this->exact().is_valid();
- };
+ return this->exact().impl_is_valid();
+ }
// auto
- operator point_t()
+ operator point_t() const
{
- return this->exact().operator point_t();
+ return this->exact().impl_op_point_type();
}
};
-}
// ------- //
// Image. //
// ------- //
-namespace oln
-{
- template <typename E>
- struct Image;
-
- mlc_decl_typedef(iter_type);
- mlc_decl_typedef(value_type);
-
- template <typename E>
- struct vtypes< Image<E> >
- {
- typedef mlc::undefined point_type;
- typedef mlc::undefined iter_type;
- typedef mlc::undefined value_type;
- };
-
template <typename E>
struct Image : public stc::any<E>
{
- typedef oln_type_of(Image, point) point_t;
- typedef oln_type_of(Image, iter) iter_t;
- typedef oln_type_of(Image, value) value_t;
+ typedef oln_type_of(E, point) point_t;
+ typedef oln_type_of(E, value) value_t;
value_t& operator ()(point_t& p)
{
- return this->exact().operator ()(p);
+ return this->exact().impl_op_parens(p);
}
bool has(const point_t& p) const
{
- return this->exact().has(p);
+ return this->exact().impl_has(p);
}
};
-}
// --------- //
// Image2d. //
// --------- //
-namespace oln
-{
- struct Image2d;
-
- template<>
- struct set_super_type<Image2d>
- {
- typedef Image<Image2d> ret;
- };
-
- struct Image2d : public Image<Image2d>
+ template <typename E>
+ struct Image2d : public Image<E>
{
- typedef oln_type_of_(Image2d, point) point_t;
- typedef oln_type_of_(Image2d, iter) iter_t;
- typedef oln_type_of_(Image2d, value) value_t;
+ typedef oln_type_of(E, point) point_t;
+ typedef oln_type_of(E, value) value_t;
+ // FIXME: delete?
value_t& operator ()(point_t& p)
{
- return this->exact().operator ()(p);
+ return this->exact().impl_op_parens(p);
}
int nrows_get() const
{
- return this->exact().nrows_get();
+ return this->exact().impl_nrows_get();
}
int ncols_get() const
{
- return this->exact().ncols_get();
+ return this->exact().impl_ncols_get();
}
};
-}
-// ---------- //
+ // --------- //
// Image 3d. //
-// ---------- //
-
-namespace oln
-{
- struct Image3d;
-
- template<>
- struct set_super_type<Image3d>
- {
- typedef Image<Image3d> ret;
- };
+ // --------- //
- struct Image3d : public Image<Image3d>
+ template <typename E>
+ struct Image3d : public Image<E>
{
- typedef oln_type_of_(Image3d, point) point_t;
- typedef oln_type_of_(Image3d, iter) iter_t;
- typedef oln_type_of_(Image3d, value) value_t;
+ typedef oln_type_of(E, point) point_t;
+ typedef oln_type_of(E, value) value_t;
+ // FIXME: delete?
value_t& operator ()(point_t& p)
{
- return this->exact().operator ()(p);
+ return this->exact().impl_op_parens(p);
}
int nrows_get() const
{
- return this->exact().nrows_get();
+ return this->exact().impl_nrows_get();
}
int ncols_get() const
{
- return this->exact().ncols_get();
+ return this->exact().impl_ncols_get();
}
int nslis_get() const
{
- return this->exact().nslis_get();
+ return this->exact().impl_nslis_get();
}
};
-}
// ------------------------- //
-// Image with neighborhood. //
+ // Image_with_neighborhood. //
// ------------------------- //
-namespace oln
-{
- struct image_with_nbh;
-
- mlc_decl_typedef(niter_type);
- mlc_decl_typedef(nbh_type);
-
- template<>
- struct set_super_type<image_with_nbh>
- {
- typedef Image<image_with_nbh> ret;
- };
-
- template <>
- struct vtypes<image_with_nbh>
- {
- typedef mlc::undefined niter_type;
- typedef mlc::undefined nbh_type;
- };
-
- struct image_with_nbh : public Image<image_with_nbh>
+ template <typename E>
+ struct Image_with_neighborhood : public Image<E>
{
- typedef oln_type_of_(image_with_nbh, niter) niter_t;
- typedef oln_type_of_(image_with_nbh, nbh) nbh_t;
+ typedef oln_type_of(E, nbh) nbh_t;
+ typedef oln_type_of(E, niter) niter_t;
- // FIXME: Implement.
-#if 0
nbh_t nbh() const
{
+ return this->exact().impl_nbh();
}
-#endif
};
-}
+
+} // End of namespace oln.
+/*---------.
+| Bridge. |
+`---------*/
+
+namespace oln
+{
// -------- //
// Switch. //
// -------- //
-namespace oln
-{
- // Fwd. decl.
- template <typename E>
- class image_dimension_switch;
+ // Forward declaration.
+ template <typename E> struct image_dimension_switch;
- // Default version, abort.
+ // Default version.
template <typename E>
- class image_dimension_switch : mlc::abort_<E>
+ struct image_dimension_switch : public oln::Image<E>
+ {
+ image_dimension_switch()
{
+ std::cout << "image_dimension_switch<E>" << std::endl;
+ }
};
// Concept-based overloading for Image2d.
- template <typename E> where concepts::Point2d< oln_type_of(E, point) >
- class image_dimension_switch<E> : public oln::Image2d
+ template <typename E>
+ requires concepts::Point2d< oln_type_of(E, point) >
+ struct image_dimension_switch<E> : public oln::Image2d<E>
{
public:
image_dimension_switch()
{
std::cout << "image_dimension_switch<E> "
- << "where concepts::Point2d<oln_type_of(E, point)>"
+ << "requires oln::concepts::Point2d<oln_type_of(E, point)>"
<< std::endl;
}
};
// Concept-based overloading for Image3d.
- template <typename E> where concepts::Point3d< oln_type_of(E, point) >
- class image_dimension_switch<E> : public oln::Image3d
+ template <typename E>
+ requires concepts::Point3d< oln_type_of(E, point) >
+ struct image_dimension_switch<E> : public oln::Image3d<E>
{
public:
image_dimension_switch()
{
std::cout << "image_dimension_switch<E> "
- << "where concepts::Point3d<oln_type_of(E, point)>"
+ << "requires oln::concepts::Point3d<oln_type_of(E, point)>"
<< std::endl;
}
};
-}
// ------------ //
// Image base. //
// ------------ //
-namespace oln
-{
- template <typename E>
- struct image_base;
+ // Forward declaration.
+ template <typename E> struct image_base;
template<typename E>
struct set_super_type< image_base<E> >
{
- typedef typename oln::image_dimension_switch<E> ret;
+ typedef mlc::none ret;
};
template <typename E>
struct vtypes< image_base<E> >
{
- typedef mlc::undefined point_type;
- typedef mlc::undefined iter_type;
- typedef mlc::undefined value_type;
+ typedef stc::abstract point_type;
+ typedef stc::abstract iter_type;
+ typedef stc::abstract value_type;
+
+ typedef mlc::none niter_type;
+ typedef mlc::none nbh_type;
};
template <typename E>
struct image_base : public oln::image_dimension_switch<E>
{
- typedef oln_type_of(image_base, point) point_t;
- typedef oln_type_of(image_base, iter) iter_t;
- typedef oln_type_of(image_base, value) value_t;
-
- value_t& operator ()(point_t& p)
+ image_base()
{
- return this->exact().operator ()(p);
}
+ };
- bool has(const point_t& p) const
+} // End of namespace oln.
+
+
+/*------------------.
+| Implementations. |
+`------------------*/
+
+namespace oln
{
- return this->exact().has(p);
- }
+ // -------- //
+ // Points. //
+ // -------- //
+
+ struct point2d : public Point<point2d>
+ {
+ typedef int coord_type;
+ coord_type row;
+ coord_type col;
};
-}
+ struct point3d : public Point<point3d>
+ {
+ typedef int coord_type;
+ coord_type row;
+ coord_type col;
+ coord_type sli;
+ };
-// ------------ //
-// iterator2d. //
-// ------------ //
+ // Explicitly map point2d and point3d to their concepts.
+ namespace concepts
+ {
+ concept_map Point2d<oln::point2d>
+ {
+ typedef oln::point2d::coord_type coord_type;
+ };
-namespace oln
+ concept_map Point3d<oln::point3d>
{
- struct iterator2d;
+ typedef oln::point2d::coord_type coord_type;
+ };
+
+ } // End of namespace oln::concepts
- template <typename T>
- struct image2d;
+
+ // ------------- //
+ // Iterator 2d. //
+ // ------------- //
+
+ // Forward declarations.
+ struct iterator2d;
+ template <typename T> struct image2d;
template<>
struct set_super_type<iterator2d>
{
- typedef Iterator<iterator2d> ret;
+ typedef mlc::none ret;
};
template <>
@@ -479,13 +435,13 @@
{
}
- void start()
+ void impl_start()
{
p.row = 0;
p.col = 0;
}
- void next()
+ void impl_next()
{
p.col = p.col + 1;
@@ -496,12 +452,12 @@
}
}
- bool is_valid() const
+ bool impl_is_valid() const
{
return p.row < nrows;
}
- operator point_t()
+ point_t& impl_op_point_type()
{
return p;
}
@@ -511,17 +467,14 @@
int ncols;
point_t p;
};
-}
-// --------- //
-// image2d. //
-// --------- //
+ // ---------- //
+ // Image 2d. //
+ // ---------- //
-namespace oln
-{
- template <typename T>
- struct image2d;
+ // Forward declaration.
+ template <typename T> struct image2d;
template<typename T>
struct set_super_type< image2d<T> >
@@ -540,9 +493,10 @@
template <typename T>
struct image2d : public image_base< image2d<T> >
{
- typedef oln_type_of(image2d, point) point_t;
- typedef oln_type_of(image2d, iter) iter_t;
- typedef oln_type_of(image2d, value) value_t;
+ typedef image2d<T> self_t;
+ typedef oln_type_of(self_t, point) point_t;
+ typedef oln_type_of(self_t, iter) iter_t;
+ typedef oln_type_of(self_t, value) value_t;
image2d(int nrows, int ncols) :
data (0),
@@ -552,22 +506,22 @@
data = new std::vector<value_t>;
}
- value_t& operator()(const point_t& p)
+ value_t& impl_op_parens(const point_t& p)
{
return this->data[p.row * nrows + p.col];
}
- int nrows_get() const
+ int impl_nrows_get() const
{
return nrows;
}
- int ncols_get() const
+ int impl_ncols_get() const
{
return ncols;
}
- bool has(point_t& p) const
+ bool impl_has(point_t& p) const
{
assert(!!data);
return p.row >= 0 && p.row < nrows && p.col >= 0 && p.col < ncols;
@@ -578,34 +532,43 @@
int nrows;
int ncols;
};
-}
+
+
+ // ----------------- //
+ // Neighborhood 2d. //
+ // ----------------- //
+
+ struct niter2d {};
+
+ struct neighborhood2d
+ {
+ typedef niter2d niter_type;
+ };
// --------------- //
-// image_morpher. //
+ // Image morpher. //
// --------------- //
-namespace oln
-{
- template <typename E>
- struct image_morpher;
+ // Forward declaration.
+ template <typename E> struct image_morpher;
template<typename E>
struct set_super_type< image_morpher<E> >
{
- typedef image_base< image_morpher<E> > ret;
+ typedef image_base<E> ret;
};
template <typename E>
struct vtypes< image_morpher<E> >
{
- typedef mlc::undefined delegatee_t;
+ typedef stc::abstract delegatee_type;
};
template <typename E>
- struct image_morpher : public image_base< image_morpher<E> >
+ struct image_morpher : public image_base<E>
{
- typedef oln_type_of(image_morpher, delegatee) delegatee_t;
+ typedef oln_type_of(E, delegatee) delegatee_t;
image_morpher(delegatee_t& ref_ima) :
ref_ima (ref_ima)
@@ -619,20 +582,17 @@
protected:
delegatee_t& ref_ima;
};
-}
-// ------ //
-// plus. //
-// ------ //
+ // ------------------------- //
+ // Image with neighborhood. //
+ // ------------------------- //
-namespace oln
-{
- template <typename I, typename N>
- struct plus;
+ // Forward declaration.
+ template <typename I, typename N> struct plus;
template <typename I, typename N>
- struct set_super_type< image_morpher<plus<I, N> > >
+ struct set_super_type< plus<I, N> >
{
typedef image_morpher< plus <I, N> > ret;
};
@@ -640,30 +600,48 @@
template <typename I, typename N>
struct vtypes< plus<I, N> >
{
- typedef I delegatee_t;
+ typedef I delegatee_type;
+ typedef N nbh_type;
+ // For the sake of simplicity, the niter type is obtained directly
+ // from the neighborhood type itself (without using a virtual
+ // type).
+ typedef typename N::niter_type niter_type;
};
template <typename I, typename N>
struct plus : public image_morpher<plus<I, N> >
{
+ typedef plus<I, N> self_t;
+ typedef image_morpher<self_t> super_t;
+
plus(I& ima, N& nbh) :
+ super_t (ima),
nbh (nbh)
{
}
+ N impl_nbh() const
+ {
+ return nbh;
+ }
+
protected:
N& nbh;
};
- // Helper.
+ /// Helper.
template <typename I, typename N>
+ // FIXME: To be enabled later
+#if 0
+ requires concepts::Image<I>
+#endif
plus<I, N> operator+(I& lhs, N& rhs)
{
plus<I, N> res(lhs, rhs);
return res;
}
-}
+} // End of namespace oln.
/*--------------.
@@ -674,16 +652,25 @@
{
using namespace oln;
- typedef plus<image2d<int>, image_with_nbh> my_ima;
+ point2d p;
+ typedef image2d<int> ima_t;
+ ima_t ima1(10, 10);
- point2d p2d;
- point3d p3d;
+ iterator2d it(ima1);
- image2d<int> ima(10, 10);
- image_with_nbh ima_nb;
+ typedef neighborhood2d nbh_t;
- iterator2d it2d(ima);
+// // A type of image with neighborhood2d.
+// typedef plus<ima_t, nbh_t> ima_wih_nbh_t;
+// neighborhood2d nbh;
+// ima_wih_nbh_t ima2(ima1, nbh);
- // my_ima p = ima + ima_nb;
-}
+// // Another way to build an image with neigborhood.
+// ima_wih_nbh_t ima3 = ima1 + nbh;
+
+// // FIXME: Same with 3d.
+// point3d q;
+
+// // ...
+}
Index: samples/mini-oln/concept-c++/Makefile.am
--- samples/mini-oln/concept-c++/Makefile.am (revision 840)
+++ samples/mini-oln/concept-c++/Makefile.am (working copy)
@@ -14,8 +14,10 @@
# Hacky.
CXX = @CONCEPTCXX@
-check_PROGRAMS = mini-oln
+# FIXME: Disabled, since ConceptGCC fails to compile this sample
+# (dying with an Internal Compiler Error).
-mini_oln_SOURCES = mini-oln.cc
+# check_PROGRAMS = mini-oln
+# mini_oln_SOURCES = mini-oln.cc
-TESTS = $(check_PROGRAMS)
+# TESTS = $(check_PROGRAMS)
Index: samples/mini-oln/mini-oln.cc
--- samples/mini-oln/mini-oln.cc (revision 840)
+++ samples/mini-oln/mini-oln.cc (working copy)
@@ -62,18 +62,6 @@
}
-// --------------------- //
-// Forward declarations. //
-// --------------------- //
-
-// FIXME: Remove.
-namespace oln
-{
- struct point2d;
- struct point3d;
-}
-
-
/*---------------.
| Abstractions. |
`---------------*/
@@ -89,6 +77,7 @@
{
};
+
// ---------- //
// Iterator. //
// ---------- //
@@ -133,7 +122,7 @@
value_t& operator ()(point_t& p)
{
- return this->exact().impl_op_paren(p);
+ return this->exact().impl_op_parens(p);
}
bool has(const point_t& p) const
@@ -156,7 +145,7 @@
//FIXME: delete?
value_t& operator ()(point_t& p)
{
- return this->exact().impl_op_paren(p);
+ return this->exact().impl_op_parens(p);
}
int nrows_get() const
@@ -184,7 +173,7 @@
//FIXME: delete?
value_t& operator ()(point_t& p)
{
- return this->exact().impl_operator_paren(p);
+ return this->exact().impl_op_parens(p);
}
int nrows_get() const
@@ -212,8 +201,8 @@
struct Image_with_neighborhood : public Image<E>
{
typedef oln_type_of(E, nbh) nbh_t;
+ typedef oln_type_of(E, niter) niter_t;
- // FIXME: Implement.
nbh_t nbh() const
{
return this->exact().impl_nbh();
@@ -265,13 +254,13 @@
// Image base. //
// ------------ //
- template <typename E>
- struct image_base;
+ // Forward declaration.
+ template <typename E> struct image_base;
template<typename E>
struct set_super_type< image_base<E> >
{
- typedef typename mlc::none ret;
+ typedef mlc::none ret;
};
template <typename E>
@@ -299,6 +288,7 @@
/*------------------.
| Implementations. |
`------------------*/
+
namespace oln
{
// -------- //
@@ -319,15 +309,13 @@
};
- // ------------ //
+ // ------------- //
// Iterator2d. //
- // ------------ //
+ // ------------- //
// Forward declarations.
struct iterator2d;
-
- template <typename T>
- struct image2d;
+ template <typename T> struct image2d;
template<>
struct set_super_type<iterator2d>
@@ -374,7 +362,7 @@
return p.row < nrows;
}
- point_t& impl_op_point_t()
+ point_t& impl_op_point_type()
{
return p;
}
@@ -390,8 +378,8 @@
// Image 2d. //
// ---------- //
- template <typename T>
- struct image2d;
+ // Forward declaration.
+ template <typename T> struct image2d;
template<typename T>
struct set_super_type< image2d<T> >
@@ -410,9 +398,10 @@
template <typename T>
struct image2d : public image_base< image2d<T> >
{
- typedef oln_type_of(image2d, point) point_t;
- typedef oln_type_of(image2d, iter) iter_t;
- typedef oln_type_of(image2d, value) value_t;
+ typedef image2d<T> self_t;
+ typedef oln_type_of(self_t, point) point_t;
+ typedef oln_type_of(self_t, iter) iter_t;
+ typedef oln_type_of(self_t, value) value_t;
image2d(int nrows, int ncols) :
data (0),
@@ -422,7 +411,7 @@
data = new std::vector<value_t>;
}
- value_t& impl_op_paren(const point_t& p)
+ value_t& impl_op_parens(const point_t& p)
{
return this->data[p.row * nrows + p.col];
}
@@ -466,8 +455,8 @@
// Image morpher. //
// --------------- //
- template <typename E>
- struct image_morpher;
+ // Forward declaration.
+ template <typename E> struct image_morpher;
template<typename E>
struct set_super_type< image_morpher<E> >
@@ -504,8 +493,8 @@
// Image with neighborhood. //
// ------------------------- //
- template <typename I, typename N>
- struct plus;
+ // Forward declaration.
+ template <typename I, typename N> struct plus;
template <typename I, typename N>
struct set_super_type< plus<I, N> >
@@ -581,6 +570,7 @@
ima_wih_nbh_t ima3 = ima1 + nbh;
+ // FIXME: Same with 3d.
point3d q;
// ...
1
0