Commit 5d3fd7b4 authored by Thomas Moulard's avatar Thomas Moulard
Browse files

Fix misc mistakes.

	* samples/mini-oln/README: Add newline.
	* samples/mini-oln/mini-oln.cc: Fix misc mistakes
                (name resolution, SCOOP paradigm, typo).

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@738 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent c95008cb
2007-02-06 Thomas Moulard <thomas.moulard@lrde.epita.fr>
Fix misc mistakes.
* samples/mini-oln/README: Add newline.
* samples/mini-oln/mini-oln.cc: Fix misc mistakes
(name resolution, SCOOP paradigm, typo).
2007-02-05 Thomas Moulard <thomas.moulard@lrde.epita.fr>
Fix type resolution and misc bugs.
......
FIXME
\ No newline at end of file
FIXME
......@@ -37,7 +37,7 @@
// 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)
......@@ -49,8 +49,8 @@ mlc_case_equipment_for_namespace(oln);
/*-------------.
| Mini-Olena. |
`-------------*/
| Mini-Olena. |
`-------------*/
// -------------------- //
// Vtypes declaration. //
......@@ -67,6 +67,16 @@ namespace oln
mlc_decl_typedef(nbh_type);
}
// --------------------- //
// Forward declarations. //
// --------------------- //
namespace oln
{
struct point2d;
struct point3d;
}
// ------- //
// Point. //
// ------- //
......@@ -77,19 +87,6 @@ namespace oln
struct Point : public stc::any<E>
{
};
struct point2d : public Point<point2d>
{
int row;
int col;
};
struct point3d : public Point<point2d>
{
int row;
int col;
int sli;
};
}
......@@ -102,22 +99,10 @@ namespace oln
template <typename E>
struct Iterator;
template<typename E>
struct set_super_type<Iterator<E> >
{
typedef mlc::none ret;
};
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()
{
......@@ -132,85 +117,16 @@ namespace oln
bool is_valid() const
{
return this->exact().impl_is_valid();
};
}
// auto
operator point_t()
operator point_t() const
{
return this->exact().impl_op_point_type();
}
};
}
// ------------ //
// iterator2d. //
// ------------ //
namespace oln
{
struct iterator2d;
template <typename T>
struct image2d;
template<>
struct set_super_type<iterator2d>
{
typedef Iterator<iterator2d> ret;
};
template <>
struct vtypes<iterator2d>
{
typedef point2d point_type;
};
struct iterator2d : public Iterator<iterator2d>
{
typedef oln_type_of_(iterator2d, point) point_t;
template <typename T>
iterator2d(image2d<T>& ima) :
nrows (ima.nrows_get()),
ncols (ima.ncols_get())
{
}
void impl_start()
{
p.row = 0;
p.col = 0;
}
void impl_next()
{
p.col = p.col + 1;
if (p.col == ncols)
{
p.col = 0;
p.row = p.row + 1;
}
}
bool impl_is_valid() const
{
return p.row < nrows;
}
point_t& impl_op_point_t()
{
return p;
}
protected:
int nrows;
int ncols;
point_t p;
};
}
// ------- //
// Image. //
......@@ -224,12 +140,15 @@ namespace oln
template <typename E>
struct Image : public stc::any<E>
{
typename E::value_t& operator ()(typename E::point_t& p)
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().impl_op_paren(p);
}
bool has(const typename E::point_t& p) const
bool has(const point_t& p) const
{
return this->exact().impl_has(p);
}
......@@ -244,10 +163,13 @@ namespace oln
namespace oln
{
template <typename E>
struct Image2d : public Image<Image2d<E> >
struct Image2d : public Image<E>
{
typedef oln_type_of(E, point) point_t;
typedef oln_type_of(E, value) value_t;
//FIXME: delete?
typename E::value_t& operator ()(typename E::point_t& p)
value_t& operator ()(point_t& p)
{
return this->exact().impl_op_paren(p);
}
......@@ -272,10 +194,13 @@ namespace oln
namespace oln
{
template <typename E>
struct Image3d : public Image<Image3d<E> >
struct Image3d : public Image<E>
{
typedef oln_type_of(E, point) point_t;
typedef oln_type_of(E, value) value_t;
//FIXME: delete?
typename E::value_t& operator ()(typename E::point_t& p)
value_t& operator ()(point_t& p)
{
return this->exact().impl_operator_paren(p);
}
......@@ -298,25 +223,6 @@ namespace oln
}
// ------------------------- //
// Image with neighborhood. //
// ------------------------- //
namespace oln
{
template <typename E>
struct Image_with_nbh : public Image<Image_with_nbh<E> >
{
// FIXME: Implement.
#if 0
nbh_t nbh() const
{
}
#endif
};
}
// -------- //
// Switch. //
// -------- //
......@@ -327,14 +233,14 @@ namespace oln
template <typename E>
struct case_<switch_image_base, E, 1> :
public mlc::where_ < mlc::eq_ <E, point2d> >
public mlc::where_ < mlc::eq_ <oln_type_of(E, point), point2d> >
{
typedef Image2d<E> ret;
};
template <typename E>
struct case_<switch_image_base, E, 2> :
public mlc::where_ < mlc::eq_ <E, point3d> >
public mlc::where_ < mlc::eq_ <oln_type_of(E, point), point3d> >
{
typedef Image3d<E> ret;
};
......@@ -374,7 +280,7 @@ namespace oln
};
template <typename E>
struct image_base : public oln::switch_<switch_image_base, E>::ret
struct image_base : public switch_<switch_image_base, E>::ret
{
image_base()
{
......@@ -383,6 +289,93 @@ namespace oln
}
// ------- //
// points. //
// ------- //
namespace oln
{
struct point2d : public Point<point2d>
{
int row;
int col;
};
struct point3d : public Point<point2d>
{
int row;
int col;
int sli;
};
}
// ------------ //
// iterator2d. //
// ------------ //
namespace oln
{
struct iterator2d;
template <typename T>
struct image2d;
template<>
struct set_super_type<iterator2d>
{
typedef mlc::none ret;
};
template <>
struct vtypes<iterator2d>
{
typedef point2d point_type;
};
struct iterator2d : public Iterator<iterator2d>
{
typedef oln_type_of_(iterator2d, point) point_t;
template <typename T>
iterator2d(image2d<T>& ima) :
nrows (ima.nrows_get()),
ncols (ima.ncols_get())
{
}
void impl_start()
{
p.row = 0;
p.col = 0;
}
void impl_next()
{
p.col = p.col + 1;
if (p.col == ncols)
{
p.col = 0;
p.row = p.row + 1;
}
}
bool impl_is_valid() const
{
return p.row < nrows;
}
point_t& impl_op_point_t()
{
return p;
}
protected:
int nrows;
int ncols;
point_t p;
};
}
// --------- //
......@@ -451,37 +444,38 @@ namespace oln
};
}
// ---------------- //
// image_with_nbh. //
// ---------------- //
// namespace oln
// {
// struct image_with_nbh;
// template<>
// struct set_super_type<image_with_nbh>
// {
// typedef image_base<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_base< image_with_nbh >
// {
// typedef oln_type_of_(image_with_nbh, nbh) niter_t;
// typedef oln_type_of_(image_with_nbh, niter) nbh_t;
// image_with_nbh()
// {
// }
// };
// }
namespace oln
{
struct image_with_nbh;
template<>
struct set_super_type<image_with_nbh>
{
typedef image_base<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_base< image_with_nbh >
{
typedef oln_type_of_(image_with_nbh, nbh) niter_t;
typedef oln_type_of_(image_with_nbh, niter) nbh_t;
image_with_nbh()
{
}
};
}
// --------------- //
// image_morpher. //
......@@ -501,7 +495,7 @@ namespace oln
template <typename E>
struct vtypes< image_morpher<E> >
{
typedef mlc::undefined delegatee_t;
typedef mlc::undefined delegatee_type;
};
template <typename E>
......@@ -542,7 +536,7 @@ namespace oln
template <typename I, typename N>
struct vtypes< plus<I, N> >
{
typedef I delegatee_t;
typedef I delegatee_type;
};
template <typename I, typename N>
......@@ -576,15 +570,22 @@ int main()
{
using namespace oln;
// typedef plus<image2d<int>, image_with_nbh> my_ima;
typedef plus<image2d<int>, image_with_nbh> my_ima;
point2d p2d;
point3d p3d;
image2d<int> ima(10, 10);
// image_with_nbh ima_nb;
image_with_nbh ima_nb;
// iterator2d it2d(ima);
iterator2d it2d(ima);
// my_ima p = ima + ima_nb;
}
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