Commit 2689d29e authored by Thierry Geraud's avatar Thierry Geraud
Browse files

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.


git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@843 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent a68735c2
2007-03-02 Thierry Geraud <theo@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.
2007-03-02 Roland Levillain <roland@lrde.epita.fr>
Improve sanity checks.
......
// 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> >
/// Virtual types.
template <>
struct vtypes< dpoint2d >
{
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;
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
......
// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
// Copyright (C) 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
......@@ -25,58 +25,45 @@
// 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_2D_GRID2D_HH
# define OLN_CORE_2D_GRID2D_HH
# include <oln/core/type.hh>
# include <oln/core/typedefs.hh>
# include <mlc/int.hh>
# include <oln/core/concept/grid.hh>
namespace oln {
namespace oln
{
// Forward declaration.
namespace abstract
{
template <typename E> class grid;
}
struct grid2d;
/// Super type declaration.
template <typename E>
struct set_super_type< abstract::grid<E> >
{
typedef mlc::none ret;
};
/// Virtual types associated to oln::abstract::grid.
template <typename E>
struct vtypes< abstract::grid<E> >
/// Super type.
template<>
struct super_trait_< grid2d >
{
typedef stc::abstract dimvalue_type;
typedef Grid< grid2d > ret;
};
namespace abstract {
template <typename E>
struct grid : public virtual stc::any__simple<E>,
public oln::type
{
protected:
grid();
};
# ifndef OLN_INCLUDE_ONLY
/// Virtual types.
template <>
struct vtypes< grid2d >
{
typedef mlc::uint_<2> dim;
};
template <typename E>
grid<E>::grid()
{
}
# endif
/// Rectangular grid class.
class grid2d : public Grid< grid2d >
{
public:
/// Ctor.
grid2d() {}
};
} // end of namespace oln::abstract
} // end of namespace oln
#endif // ! OLN_CORE_ABSTRACT_GRID_HH
#endif // ! OLN_CORE_2D_GRID2D_HH
// 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> >
/// Virtual types.
template <>
struct vtypes< point2d >
{
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;
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_()
{
}
template <typename C>
point2d_<C>::point2d_(C row, C col)
: super_t (xtd::mk_vec(row, col))
point2d::point2d()
{
}
template <typename C>
point2d_<C>::point2d_(const xtd::vec<2,C>& v)
: super_t(v)
point2d::point2d(int row, int col)
{
this->row() = row;
this->col() = col;
}
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
......
// Copyright (C) 2001, 2002, 2003, 2004, 2006 EPITA Research and
// Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
// of the GNU General Public License version 2 as published by the
// Free Software Foundation.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this library; see the file COPYING. If not, write to
// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
// Boston, MA 02111-1307, USA.
//
// As a special exception, you may use this file as part of a free
// software library without restriction. Specifically, if other files
// instantiate templates or use macros or inline functions from this
// file, or you compile this file and link it with other files to
// produce an executable, this file does not by itself cause the
// resulting executable to be covered by the GNU General Public
// License. This exception does not however invalidate any other
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef OLN_CORE_ABSTRACT_POINT_HH
# define OLN_CORE_ABSTRACT_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>
namespace oln
{
namespace ERROR
{
struct OPERANDS_ARE_NOT_COMPATIBLE;
} // end of namespace oln::ERROR
// Forward declaration.
namespace abstract { template <typename E> class point; }
template <typename E>
struct set_super_type< abstract::point<E> >
{
typedef mlc::none ret;
};
/// 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;
};
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 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 >=.
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 +=.
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;
/// \}
/// \{
</