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
March 2007
- 7 participants
- 73 discussions
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