Commit 9878f630 authored by Thierry Geraud's avatar Thierry Geraud
Browse files

2006-08-30 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>

	Start point hierarchy.
	
	* oln/core/typedefs.hh (oln_type_of): New macro.
	(dim_type): New typedef decl.
	* oln/core/abstract/point.hh: New.
	* oln/core/abstract/point_nd.hh: New.
	* oln/core/2d/point2d.hh: New.



git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@509 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 42c056a8
2006-08-30 Thierry GERAUD <theo@tegucigalpa.lrde.epita.fr>
* oln/core/typedefs.hh (oln_type_of): New macro.
(dim_type): New typedef decl.
* oln/core/abstract/point.hh: New.
* oln/core/abstract/point_nd.hh: New.
* oln/core/2d/point2d.hh: New.
2006-06-05 Roland Levillain <roland@lrde.epita.fr>
Catch up with Static's support for multiple inheritance.
......
// 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 OLENA_CORE_2D_POINT2D_HH
# define OLENA_CORE_2D_POINT2D_HH
# include <mlc/int.hh>
# include <oln/core/abstract/point_nd.hh>
namespace oln
{
// Forward declarations.
template <typename C> class point2d_;
class dpoint2d;
class grid2d;
// /// Super type.
// template<typename C>
// struct set_super_type< point2d_<C> >
// {
// typedef abstract::point< point2d_<C> > ret;
// };
/// Virtual types associated to oln::abstract::image.
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;
};
/// General 2D point class.
template <typename C>
class point2d_ : public abstract::point_nd< point2d_<C> > // FIXME: stc_get_super_(point2d_<C>)
{
typedef point2d_<C> self;
typedef abstract::point_nd<self> super; // FIXME: stc_get_super(self)
typedef oln_type_of(self, coord) coord;
using super::v_;
public:
const coord row() const { return v_[0]; }
coord& row() { return v_[0]; }
const coord col() const { return v_[1]; }
coord& col() { return v_[1]; }
};
/// Classical 2D point class.
typedef point2d_<int> point2d;
} // end of namespace oln
#endif // ! OLENA_CORE_2D_POINT2D_HH
// 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 OLENA_CORE_ABSTRACT_POINT_HH
# define OLENA_CORE_ABSTRACT_POINT_HH
# include <mlc/assert.hh>
# include <mlc/cmp.hh>
# include <stc/any.hh>
# include <stc/vtypes.hh>
# include <oln/core/typedefs.hh>
namespace oln {
namespace abstract {
/// Abstract point class.
template <typename E>
class point : public stc::any__simple<E>
{
public:
bool operator==(const abstract::point<E>& rhs) const
{
return this->exact().impl_eq(rhs.exact());
}
protected:
point()
{}
~point() {
mlc::assert_defined_< oln_type_of(E, grid) >::check();
mlc::assert_defined_< oln_type_of(E, dpoint) >::check();
mlc::assert_defined_< oln_type_of(E, coord) >::check();
mlc::assert_defined_< oln_type_of(E, dim) >::check();
}
};
} // end of namespace oln::abstract
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_POINT_HH
// 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 OLENA_CORE_ABSTRACT_POINT_ND_HH
# define OLENA_CORE_ABSTRACT_POINT_ND_HH
# include <mlc/value.hh>
# include <xtd/vec.hh>
# include <oln/core/abstract/point.hh>
namespace oln
{
namespace abstract
{
template <typename E>
class point_nd : public abstract::point<E>
{
typedef point_nd<E> self;
typedef oln_type_of(E, dim) dim;
typedef oln_type_of(E, coord) coord;
public:
enum { n = mlc_value(dim) };
bool impl_eq(const self& rhs) const
{
return v_ == rhs.v_;
}
const coord operator[](unsigned i) const
{
assert(i < n);
return v_[i];
}
coord& operator[](unsigned i)
{
assert(i < n);
return v_[i];
}
protected:
xtd::vec<n,coord> v_;
};
} // end of namespace oln::abstract
} // end of namespace oln
#endif // ! OLENA_CORE_ABSTRACT_POINT_ND_HH
......@@ -37,6 +37,18 @@
# include <stc/vtypes.hh>
/*! \macro oln_type_of(OlnType, Alias)
**
** Macro to retrieve an associated type \Alias from an oln type
** \OlnType whose category is not specified.
*/
# define oln_type_of(OlnType, Alias) \
stc_type_of(oln, void, OlnType, Alias)
namespace oln
{
......@@ -48,6 +60,7 @@ namespace oln
// triggers Metalic's typedef introspection equipment.
stc_equip_namespace_with_vtypes();
/*-------.
| Misc. |
`-------*/
......@@ -154,6 +167,13 @@ namespace oln
mlc_decl_typedef(coord_type);
/*-----------------.
| category::point. |
`-----------------*/
mlc_decl_typedef(dim_type);
/*------------------------------------.
| category::fun1 and category::fun2. |
`------------------------------------*/
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment