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
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Update SCOOP 2 alternative implementation.
* stc/scoop-alt.hh: Split this file into...
* stc/scoop-alt.hh, stc/scoop-alt.inc: ...these.
Catch up with the interface of oln/stc/scoop.hh and
oln/stc/scoop.hxx.
* stc/Makefile.am (nobase_stc_HEADERS): Add scoop-alt.inc.
* tests/scoop-alt.cc: Adjust existing tests.
(ex8, ex9): New tests.
(main): Run them.
stc/Makefile.am | 1
stc/scoop-alt.hh | 720 ++++---------------------
stc/scoop-alt.inc | 1471 +++++++++++++++++++++++++++++------------------------
tests/scoop-alt.cc | 393 +++++++++++---
4 files changed, 1255 insertions(+), 1330 deletions(-)
Index: tests/scoop-alt.cc
--- tests/scoop-alt.cc (revision 877)
+++ tests/scoop-alt.cc (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -31,31 +31,42 @@
/// These examples comes from doc/algorithm.ml.
+#include <cassert>
-#include <mlc/cmp.hh>
#include <mlc/assert.hh>
+#include <mlc/cmp.hh>
#include <stc/scoop-alt.hh>
-// Namespace equipment.
-stc_scoop_equipment_for_namespace(my);
+#include <mlc/int.hh>
// FIXME: Check single_vtype, too.
namespace my
{
+
+ // ------------------------------------------------- Namespace equipment.
+
+# include <stc/scoop-alt.inc>
+
+
// ------------------------------------------------------------ Typedefs.
mlc_decl_typedef(my_type);
- mlc_decl_typedef(foo_type);
- mlc_decl_typedef(bar_type);
- mlc_decl_typedef(baz_type);
- mlc_decl_typedef(quux_type);
- mlc_decl_typedef(hop_type);
+ mlc_decl_typedef(foo);
+ mlc_decl_typedef(bar);
+ mlc_decl_typedef(baz);
+ mlc_decl_typedef(quux);
+ mlc_decl_typedef(hop);
+
+ mlc_decl_typedef(value);
- mlc_decl_typedef(value_type);
+ mlc_decl_typedef(dim);
+ mlc_decl_typedef(mydim);
+
+ mlc_decl_typedef(grid);
@@ -78,7 +89,7 @@
}
// Set super type.
- template <> struct set_super_type<ex1::A> { typedef stc::none ret; };
+ template <> struct super_trait_<ex1::A> { typedef stc::none ret; };
/// Virtual types associated to A.
template <>
@@ -95,7 +106,7 @@
check()
{
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex1::A, my), int)
+ mlc_eq(stc_find_type_(my::ex1::A, my_type), int)
>::check();
}
}
@@ -131,9 +142,9 @@
}
// Set super types.
- template <> struct set_super_type<ex2::A> { typedef stc::none ret; };
- template <> struct set_super_type<ex2::B> { typedef ex2::A ret; };
- template <> struct set_super_type<ex2::C> { typedef ex2::B ret; };
+ template <> struct super_trait_<ex2::A> { typedef stc::none ret; };
+ template <> struct super_trait_<ex2::B> { typedef ex2::A ret; };
+ template <> struct super_trait_<ex2::C> { typedef ex2::B ret; };
/// Virtual types associated to A.
template <>
@@ -166,15 +177,15 @@
check()
{
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex2::A, my), int)
+ mlc_eq(stc_find_type_(my::ex2::A, my_type), int)
>::check();
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex2::B, my), float)
+ mlc_eq(stc_find_type_(my::ex2::B, my_type), float)
>::check();
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex2::C, my), int)
+ mlc_eq(stc_find_type_(my::ex2::C, my_type), int)
>::check();
}
}
@@ -205,8 +216,8 @@
}
// Set super types.
- template <> struct set_super_type<ex3::A> { typedef stc::none ret; };
- template <> struct set_super_type<ex3::B> { typedef ex3::A ret; };
+ template <> struct super_trait_<ex3::A> { typedef stc::none ret; };
+ template <> struct super_trait_<ex3::B> { typedef ex3::A ret; };
/// Virtual types associated to A.
template <>
@@ -231,7 +242,7 @@
check()
{
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex3::B, my), int)
+ mlc_eq(stc_find_type_(my::ex3::B, my_type), int)
>::check();
}
}
@@ -258,7 +269,7 @@
}
// Set super type.
- template <> struct set_super_type<ex4::A> { typedef stc::none ret; };
+ template <> struct super_trait_<ex4::A> { typedef stc::none ret; };
/// Virtual types associated to A.
template <>
@@ -275,7 +286,7 @@
check()
{
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex4::A, my), int)
+ mlc_eq(stc_find_type_(my::ex4::A, my_type), int)
>::check();
}
}
@@ -303,7 +314,7 @@
// C<>--D
class C < stc::none
{
- vtype delegatee_type = D;
+ vtype delegatee = D;
}
type t = C#my_type;
@@ -318,9 +329,9 @@
}
// Set super types.
- template <> struct set_super_type<ex5::A> { typedef stc::none ret; };
- template <> struct set_super_type<ex5::D> { typedef stc::none ret; };
- template <> struct set_super_type<ex5::C> { typedef ex5::A ret; };
+ template <> struct super_trait_<ex5::A> { typedef stc::none ret; };
+ template <> struct super_trait_<ex5::D> { typedef stc::none ret; };
+ template <> struct super_trait_<ex5::C> { typedef ex5::A ret; };
/// Virtual types associated to A.
template <>
@@ -339,7 +350,7 @@
template <>
struct vtypes<ex5::C>
{
- typedef ex5::D delegatee_type;
+ typedef ex5::D delegatee;
};
namespace ex5
@@ -352,7 +363,7 @@
check()
{
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex5::C, my), stc::not_found)
+ mlc_eq(stc_find_type_(my::ex5::C, my_type), stc::not_found)
>::check();
}
}
@@ -381,7 +392,7 @@
class A < stc::none | class C < B
{ | {
- } | vtype delegatee_type = Y;
+ } | vtype delegatee = Y;
class B < A | vtype foo = int;
{ | vtype baz = not_delegated;
vtype foo = 0; | vtype hop = not_delegated;
@@ -414,15 +425,15 @@
}
// Set super types.
- template <> struct set_super_type<ex6::A> { typedef stc::none ret; };
- template <> struct set_super_type<ex6::B> { typedef ex6::A ret; };
+ template <> struct super_trait_<ex6::A> { typedef stc::none ret; };
+ template <> struct super_trait_<ex6::B> { typedef ex6::A ret; };
- template <> struct set_super_type<ex6::X> { typedef stc::none ret; };
- template <> struct set_super_type<ex6::Y> { typedef ex6::X ret; };
+ template <> struct super_trait_<ex6::X> { typedef stc::none ret; };
+ template <> struct super_trait_<ex6::Y> { typedef ex6::X ret; };
- template <> struct set_super_type<ex6::C> { typedef ex6::B ret; };
- template <> struct set_super_type<ex6::D> { typedef ex6::C ret; };
- template <> struct set_super_type<ex6::E> { typedef ex6::D ret; };
+ template <> struct super_trait_<ex6::C> { typedef ex6::B ret; };
+ template <> struct super_trait_<ex6::D> { typedef ex6::C ret; };
+ template <> struct super_trait_<ex6::E> { typedef ex6::D ret; };
/// Virtual types associated to A.
template <>
@@ -434,47 +445,47 @@
template <>
struct vtypes<ex6::B>
{
- typedef stc::abstract foo_type;
+ typedef stc::abstract foo;
};
/// Virtual types associated to X.
template <>
struct vtypes<ex6::X>
{
- typedef stc::abstract bar_type;
- typedef int hop_type;
+ typedef stc::abstract bar;
+ typedef int hop;
};
/// Virtual types associated to Y.
template <>
struct vtypes<ex6::Y>
{
- typedef short baz_type;
- typedef char bar_type;
+ typedef short baz;
+ typedef char bar;
};
/// Virtual types associated to C.
template <>
struct vtypes<ex6::C>
{
- typedef ex6::Y delegatee_type;
- typedef int foo_type;
- typedef stc::not_delegated baz_type;
- typedef stc::not_delegated hop_type;
+ typedef ex6::Y delegatee;
+ typedef int foo;
+ typedef stc::not_delegated baz;
+ typedef stc::not_delegated hop;
};
/// Virtual types associated to D.
template <>
struct vtypes<ex6::D>
{
- typedef unsigned quux_type;
+ typedef unsigned quux;
};
/// Virtual types associated to E.
template <>
struct vtypes<ex6::E>
{
- typedef float baz_type;
+ typedef float baz;
};
namespace ex6
@@ -493,23 +504,23 @@
check()
{
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex6::E, foo), int)
+ mlc_eq(stc_find_type_(my::ex6::E, foo), int)
>::check();
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex6::E, bar), char)
+ mlc_eq(stc_find_type_(my::ex6::E, bar), char)
>::check();
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex6::E, baz), float)
+ mlc_eq(stc_find_type_(my::ex6::E, baz), float)
>::check();
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex6::E, quux), unsigned)
+ mlc_eq(stc_find_type_(my::ex6::E, quux), unsigned)
>::check();
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex6::E, hop), stc::not_found)
+ mlc_eq(stc_find_type_(my::ex6::E, hop), stc::not_found)
>::check();
}
}
@@ -521,24 +532,24 @@
class /image_entry/ < stc::none
{
- vtype value_type = 0;
+ vtype value = 0;
}
class image2d<int> < image_entry
{
- vtypes value_type = int;
+ vtypes value = int;
}
class /value_morpher/ < image_entry
{
- vtype delegatee_type = 0;
- vtype value_type = stc::not_delegated;
+ vtype delegatee = 0;
+ vtype value = stc::not_delegated;
}
class value_cast<image2d<int>, float> < value_morpher
{
- vtype delegatee_type = image2d<int>;
- vtype value_type = float;
+ vtype delegatee = image2d<int>;
+ vtype value = float;
}
*/
@@ -557,22 +568,22 @@
// Set super types.
template <>
- struct set_super_type<ex7::abstract::image_entry>
+ struct super_trait_<ex7::abstract::image_entry>
{
typedef stc::none ret;
};
template <>
- struct set_super_type<ex7::abstract::value_morpher>
+ struct super_trait_<ex7::abstract::value_morpher>
{
typedef ex7::abstract::image_entry ret;
};
template <typename T>
- struct set_super_type< ex7::image2d<T> >
+ struct super_trait_< ex7::image2d<T> >
{
typedef ex7::abstract::image_entry ret;
};
template <typename I, typename T>
- struct set_super_type< ex7::value_cast<I, T> >
+ struct super_trait_< ex7::value_cast<I, T> >
{
typedef ex7::abstract::value_morpher ret;
};
@@ -582,30 +593,30 @@
template <>
struct vtypes<ex7::abstract::image_entry>
{
- typedef stc::abstract value_type;
+ typedef stc::abstract value;
};
/// Virtual types associated to abstract::value_morpher.
template <>
struct vtypes<ex7::abstract::value_morpher>
{
- typedef stc::abstract delegatee_type;
- typedef stc::not_delegated value_type;
+ typedef stc::abstract delegatee;
+ typedef stc::not_delegated value;
};
/// Virtual types associated to image2d<T>.
template <typename T>
struct vtypes< ex7::image2d<T> >
{
- typedef T value_type;
+ typedef T value;
};
/// Virtual types associated to value_cast<I, T>.
template <typename I, typename T>
struct vtypes< ex7::value_cast<I, T> >
{
- typedef I delegatee_type;
- typedef T value_type;
+ typedef I delegatee;
+ typedef T value;
};
@@ -628,16 +639,254 @@
check()
{
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, my::ex7::image2d<int>, value), int)
+ mlc_eq(stc_find_type_(my::ex7::image2d<int>, value), int)
>::check();
typedef value_cast< image2d<int>, float> morphed_type;
mlc::assert_<
- mlc_eq(stc_find_vtype_(my, morphed_type, value), float)
+ mlc_eq(stc_find_type_(morphed_type, value), float)
>::check();
}
}
+
+ /* ---------------------------------------------------------------- Ex 8.
+
+ Another Olena-like example with recursive definitions.
+
+ class internal_dpoint_nd < stc::none
+ {
+ vtype mydim = find dpoint2d "dim";
+ }
+
+ class dpoint2d < internal_dpoint_nd
+ {
+ // Dummy value (because our C++ types are limited in this prototype).
+ vtype dim = int
+ }
+
+ This example is translated to C++ using the Exact-type-passing
+ technique in order to perform a test closer to what can be found
+ in Olena. */
+
+ namespace ex8
+ {
+ // Forward declarations.
+ template <typename Exact> struct internal_dpoint_nd;
+ struct dpoint2d;
+ }
+
+ // Set super types.
+ template <typename Exact>
+ struct super_trait_< ex8::internal_dpoint_nd<Exact> >
+ {
+ typedef stc::none ret;
+ };
+ template <>
+ struct super_trait_<ex8::dpoint2d>
+ {
+ typedef ex8::internal_dpoint_nd< ex8::dpoint2d > ret;
+ };
+
+ /// Virtual types associated to internal_dpoint_nd<Exact>.
+ template <typename Exact>
+ struct vtypes< ex8::internal_dpoint_nd <Exact> >
+ {
+ typedef stc_find_type(Exact, dim) mydim;
+ };
+ /// Virtual types associated to dpoint2d.
+ template <>
+ struct vtypes< ex8::dpoint2d >
+ {
+ typedef int dim;
+ };
+
+ namespace ex8
+ {
+ template <typename Exact>
+ struct internal_dpoint_nd : public stc::none
+ {
+ };
+ struct dpoint2d : public internal_dpoint_nd< dpoint2d >
+ {
+ };
+
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_type_(my::ex8::dpoint2d, mydim), int)
+ >::check();
+ }
+
+ } // end of namespace my::ex8
+
+
+ /* ---------------------------------------------------------------- Ex 9.
+
+ Another Olena-inspired example.
+
+ ...
+
+ There are other virtual types in the Olena version of the
+ following classes, but we don't need them for this simple test. */
+
+ // FIXME: I (Roland) don't know why this test succeeds, while the
+ // equivalent SCOOP 2 hierarchy doesn't work in Olena.
+
+ /*------------------------.
+ | internal::point_base_. |
+ `------------------------*/
+
+ // Forward declaration.
+ namespace ex9
+ {
+ namespace internal
+ {
+ template <typename Exact> struct point_base_;
+ }
+ }
+
+ /// Set super type.
+ template <typename Exact>
+ struct super_trait_< ex9::internal::point_base_<Exact> >
+ {
+ typedef stc::none ret;
+ };
+
+ /// Virtual types associated to internal::point_base_<Exact>
+ template <typename Exact>
+ struct vtypes< ex9::internal::point_base_<Exact> >
+ {
+ typedef stc::abstract grid;
+
+ typedef stc_deferred(grid) grid__;
+ typedef stc::final<stc_type(grid__, dim)> dim;
+
+ };
+
+ // Actual definition.
+ namespace ex9
+ {
+ namespace internal
+ {
+ template <typename Exact>
+ struct point_base_ : public stc::none
+ {
+ stc_typename(dim);
+ static const unsigned dim_val = mlc_value(dim);
+ };
+ } // end of namespace my::ex9::internal
+ }
+
+
+ /*---------------------.
+ | internal::point2d_. |
+ `---------------------*/
+
+ // FIXME: Add internal::point2d_, as in Olena, and check whether
+ // this addition triggers the same behavior observed in Olena.
+
+// namespace ex9
+// {
+// // Forward declarations.
+// namespace internal
+// {
+// template <typename Exact> struct point2d_;
+// }
+// }
+
+ // ...
+
+
+ /*---------.
+ | grid2d. |
+ `---------*/
+
+ // Forward declaration.
+ namespace ex9
+ {
+ struct grid2d;
+ }
+
+ /// Set super type.
+ template <>
+ struct super_trait_< ex9::grid2d >
+ {
+ typedef stc::none ret;
+ };
+
+ /// Virtual types associated to grid2d.
+ template <>
+ struct vtypes< ex9::grid2d >
+ {
+ typedef mlc::uint_<2u> dim;
+ };
+
+ // Actual definition.
+ namespace ex9
+ {
+ struct grid2d : public stc::none
+ {
+ };
+ }
+
+
+ /*----------.
+ | point2d. |
+ `----------*/
+
+ // Forward declaration.
+ namespace ex9
+ {
+ struct point2d;
+ }
+
+ /// Set super type.
+ template <>
+ struct super_trait_< ex9::point2d >
+ {
+ typedef ex9::internal::point_base_<ex9::point2d> ret;
+ };
+
+
+ /// Virtual types associated to point2d.
+ template <>
+ struct vtypes< ex9::point2d >
+ {
+ typedef ex9::grid2d grid;
+ };
+
+ // Actual definition.
+ namespace ex9
+ {
+ struct point2d : public internal::point_base_< point2d >
+ {
+ };
+ }
+
+
+ /*---------------------.
+ | Client (test) code. |
+ `---------------------*/
+
+ namespace ex9
+ {
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_type_(my::ex9::point2d, dim), mlc::uint_<2u>)
+ >::check();
+
+ assert(ex9::point2d::dim_val == 2);
+
+ point2d p;
+ }
+
+ } // end of namespace my::ex9
+
+
} // end of namespace my
@@ -651,4 +900,6 @@
my::ex5::check();
my::ex6::check();
my::ex7::check();
+ my::ex8::check();
+ my::ex9::check();
}
Index: stc/scoop-alt.hh
--- stc/scoop-alt.hh (revision 877)
+++ stc/scoop-alt.hh (working copy)
@@ -35,9 +35,15 @@
#ifndef STC_SCOOP_ALT_HH
# define STC_SCOOP_ALT_HH
+/** Define a stick-macro so that we can check in
+ \file stc/scoop-alt.inc that \file stc/scoop-alt.hh has been
+ included (or not) when including the former from client code. */
+# define STATIC_SCOOP_ALT_HH_INCLUDED
+
# include <mlc/flags.hh>
# include <mlc/typedef.hh>
# include <mlc/abort.hh>
+# include <mlc/case.hh>
# include <stc/internal/match-with.hh>
@@ -53,31 +59,46 @@
#endif
using mlc::none;
+ // FIXME: Likewise, define a true stc::not_found type.
+#if 0
struct not_found;
+#endif
+ typedef mlc::not_found not_found;
struct abstract;
struct not_delegated;
struct not_delegated_abstract;
template <typename T> struct final;
+ template < template <class> class category >
+ struct is;
- /// \brief Shortcuts for comparison with stc::not_found.
- ///
- /// Duplicate with their Metalic's homonyms, but still useful, since
- /// they deal with std::not_found (not mlc::not_found).
+
+
+ /// Equality test between a couple of types.
/// \{
template <typename T>
- struct is_not_found_ : public mlc_is_a(T, stc::not_found)::bexpr
- {
- };
+ struct is_found : public mlc::bexpr_<true>
+ {};
+
+ template <>
+ struct is_found< mlc::not_found > : public mlc::bexpr_<false>
+ {};
template <typename T>
- struct is_found_ : public mlc_is_not_a(T, stc::not_found)::bexpr
- {
- };
+ struct is_not_found : public mlc::bexpr_<false>
+ {};
+
+ template <>
+ struct is_not_found< mlc::not_found > : public mlc::bexpr_<true>
+ {};
/// \}
+
namespace ERROR
{
+ template <typename class_name>
+ struct super_trait_not_defined_for_;
+
struct IN_find_VIRTUAL_TYPE_IS_ABSTRACT;
struct IN_find_local_VIRTUAL_TYPE_MULTIPLY_DEFINED;
@@ -98,613 +119,108 @@
} // end of namespace stc
-#define stc_super(T) typename set_super_type< T >::ret
+/*------------------.
+| Shortcuts macro. |
+`------------------*/
-// Based on doc/algorithm.ml.
+# define stc_decl_associated_type mlc_decl_typedef
+# define stc_super(T) typename super_trait_< T >::ret
-#define stc_scoop_equipment_for_namespace(SCOOPED_NAMESPACE) \
- \
-namespace SCOOPED_NAMESPACE \
-{ \
- \
- /* Declare delegatee_type. */ \
- mlc_decl_typedef(delegatee_type); \
- \
- \
- template <typename class_name> \
- struct set_super_type \
- { \
- }; \
- \
- template <typename class_name> \
- struct vtypes \
- { \
- }; \
- \
- template <typename class_name, typename type_name> \
- struct single_vtype \
- { \
- typedef mlc::not_found ret; \
- }; \
- \
- /* ----------------------------------------------------- find_local. */ \
- \
- /* Highly inspired from Th�o's get_stm! */ \
- \
- namespace find_local_ \
- { \
- /* Forward declaration. */ \
- template <typename T, typename U> struct match_with; \
- \
- template <typename T> \
- struct match_with <T, mlc::not_found> \
- { \
- typedef T ret; \
- }; \
- \
- template <typename U> \
- struct match_with <mlc::not_found, U> \
- { \
- typedef U ret; \
- }; \
- \
- template <> \
- struct match_with <mlc::not_found, mlc::not_found> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename T, typename U> \
- struct match_with : \
- mlc::abort_<T, \
- stc::ERROR::IN_find_local_VIRTUAL_TYPE_MULTIPLY_DEFINED> \
- { \
- }; \
- \
- } /* end of namespace find_local_ */ \
- \
- template <typename source, typename target> \
- struct find_local \
- { \
- typedef SCOOPED_NAMESPACE::vtypes<source> decl1; \
- typedef typename target::template from_<decl1>::ret res1; \
- \
- typedef SCOOPED_NAMESPACE::single_vtype<source, target> decl2; \
- typedef typename decl2::ret ret2; \
- \
- \
- /* Result. */ \
- typedef typename find_local_::match_with<res1, ret2>::ret ret; \
- }; \
- \
- \
- /* --------------------------------------------------------- merge2. */ \
- \
- \
- namespace merge2_ \
- { \
- /* Forward declaration. */ \
- template <typename T, typename U> struct match_with; \
- \
- \
- /* ----------------------------- */ \
- /* local_res == stc::not_found. */ \
- /* ----------------------------- */ \
- \
- stc_internal_match_pair_0p_with(stc::not_found, stc::not_found, \
- stc::not_found); \
- \
- stc_internal_match_pair_0p_with(stc::not_found, stc::abstract, \
- stc::not_found); \
- \
- stc_internal_match_pair_1p_with(U, \
- stc::not_found, stc::final<U>, \
- stc::final<U>); \
- \
- stc_internal_match_pair_1p_with(U, \
- stc::not_found, U, \
- U); \
- \
- \
- /* ---------------------------- */ \
- /* local_res == stc::abstract. */ \
- /* ---------------------------- */ \
- \
- stc_internal_match_pair_0p_with(stc::abstract, stc::not_found, \
- stc::abstract); \
- \
- stc_internal_match_pair_0p_with(stc::abstract, stc::abstract, \
- stc::abstract); \
- \
- stc_internal_match_pair_1p_with_error(U, \
- stc::abstract, stc::final<U>, \
- stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
- \
- stc_internal_match_pair_1p_with_error(U, \
- stc::abstract, U, \
- stc::ERROR::IN_merge2_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
- \
- \
- /* ---------------------------- */ \
- /* local_res == stc::final<T>. */ \
- /* ---------------------------- */ \
- \
- stc_internal_match_pair_1p_with(T, \
- stc::final<T>, stc::not_found, \
- stc::final<T>); \
- \
- stc_internal_match_pair_1p_with(T, \
- stc::final<T>, stc::abstract, \
- stc::final<T>); \
- \
- stc_internal_match_pair_2p_with_error(T, U, \
- stc::final<T>, stc::final<U>, \
- stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL); \
- \
- stc_internal_match_pair_2p_with(T, U, \
- stc::final<T>, U, \
- stc::final<T>); \
- \
- \
- /* ---------------- */ \
- /* local_res == T. */ \
- /* ---------------- */ \
- \
- stc_internal_match_pair_1p_with(T, \
- T, stc::not_found, \
- T); \
- \
- stc_internal_match_pair_1p_with(T, \
- T, stc::abstract, \
- T); \
- \
- stc_internal_match_pair_2p_with_error(T, U, \
- T, stc::final<U>, \
- stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED); \
- \
- template <typename T, typename U> \
- struct match_with \
- { \
- typedef T ret; \
- }; \
- \
- } /* end of namespace merge2_ */ \
- \
- template <typename local_res, typename super_res> \
- struct merge2 \
- { \
- /* Result. */ \
- typedef typename merge2_::match_with<local_res, super_res>::ret ret; \
- }; \
- \
- \
- /* --------------------------------------------------------- merge3. */ \
- \
- \
- namespace merge3_ \
- { \
- /* Forward declaration. */ \
- template <typename T, typename U, typename V> struct match_with; \
- \
- \
- /* ----------------------------- */ \
- /* local_res == stc::not_found. */ \
- /* ----------------------------- */ \
- \
- /* super_res == stc::not_found. */ \
- stc_internal_match_triple_0p_with( \
- stc::not_found, stc::not_found, stc::not_found, \
- stc::not_found); \
- \
- stc_internal_match_triple_0p_with( \
- stc::not_found, stc::not_found, stc::abstract, \
- stc::not_found); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_found, stc::not_found, stc::final<V>, \
- stc::final<V>); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_found, stc::not_found, V, \
- V); \
- \
- /* super_res == stc::abstract. */ \
- stc_internal_match_triple_0p_with( \
- stc::not_found, stc::abstract, stc::not_found, \
- stc::not_found); \
- \
- stc_internal_match_triple_0p_with( \
- stc::not_found, stc::abstract, stc::abstract, \
- stc::abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_found, stc::abstract, stc::final<V>, \
- stc::final<V>); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_found, stc::abstract, V, \
- V); \
- \
- /* super_res is a concrete type. */ \
- stc_internal_match_triple_2p_with(U, V, \
- stc::not_found, stc::final<U>, V, \
- stc::final<U>); \
- \
- stc_internal_match_triple_2p_with(U, V, \
- stc::not_found, U, V, \
- U); \
- \
- \
- /* ---------------------------- */ \
- /* local_res == stc::abstract. */ \
- /* ---------------------------- */ \
- \
- /* super_res == stc::not_found. */ \
- stc_internal_match_triple_0p_with( \
- stc::abstract, stc::not_found, stc::not_found, \
- stc::abstract); \
- \
- stc_internal_match_triple_0p_with( \
- stc::abstract, stc::not_found, stc::abstract, \
- stc::abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::not_found, stc::final<V>, \
- stc::final<V>); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::not_found, V, \
- V); \
- \
- \
- /* super_res == stc::abstract. */ \
- stc_internal_match_triple_0p_with( \
- stc::abstract, stc::abstract, stc::not_found, \
- stc::abstract); \
- \
- stc_internal_match_triple_0p_with( \
- stc::abstract, stc::abstract, stc::abstract, \
- stc::abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::abstract, stc::final<V>, \
- stc::final<V>); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::abstract, V, \
- V); \
- \
- \
- /* super_res == stc::not_delegated_abstract. */ \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::not_delegated_abstract, V, \
- stc::not_delegated_abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::not_delegated, V, \
- stc::not_delegated_abstract); \
- \
- \
- /* super_res is a concrete type. */ \
- stc_internal_match_triple_2p_with_error(U, V, \
- stc::abstract, stc::final<U>, V, \
- stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
- \
- stc_internal_match_triple_2p_with_error(U, V, \
- stc::abstract, U, V, \
- stc::ERROR::IN_merge3_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
- \
- \
- /* --------------------------------- */ \
- /* local_res == stc::not_delegated. */ \
- /* --------------------------------- */ \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_delegated, stc::not_found, V, \
- stc::not_delegated); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_delegated, stc::abstract, V, \
- stc::not_delegated_abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_delegated, stc::not_delegated_abstract, V, \
- stc::not_delegated_abstract); \
- \
- \
- /* ------------------------------------------ */ \
- /* local_res == stc::not_delegated_abstract. */ \
- /* ------------------------------------------ */ \
- \
- /* FIXME: Shouldn't we introduce a means to tag a vtype both as */ \
- /* abstract *and* not delegated? (Currently, the rule below */ \
- /* prevents this). */ \
- stc_internal_match_triple_2p_with_error(U, V, \
- stc::not_delegated_abstract, U, V, \
- stc::ERROR::IN_merge3_LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT); \
- \
- \
- /* ---------------------------- */ \
- /* local_res == stc::final<T>. */ \
- /* ---------------------------- */ \
- \
- stc_internal_match_triple_3p_with_error(T, U, V, \
- stc::final<T>, stc::final<U>, V, \
- stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL); \
- \
- stc_internal_match_triple_3p_with(T, U, V, \
- stc::final<T>, U, V, \
- stc::final<T>); \
- \
- \
- /* ---------------- */ \
- /* local_res == T. */ \
- /* ---------------- */ \
- \
- stc_internal_match_triple_3p_with_error(T, U, V, \
- T, stc::final<U>, V, \
- stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED); \
- \
- template <typename T, typename U, typename V> \
- struct match_with \
- { \
- typedef T ret; \
- }; \
- \
- } /* end of namespace merge3_ */ \
- \
- \
- template <typename local_res, typename super_res, typename delegatee_res> \
- struct merge3 \
- { \
- /* Result. */ \
- typedef typename \
- merge3_::match_with<local_res, super_res, delegatee_res>::ret ret; \
- }; \
- \
- \
- /* ------------------------------------------------------ find_rec. */ \
- \
- /* Forward declarations. */ \
- template <typename source, typename target> struct find_rec; \
- template <typename source, typename target> struct find_rec_in_supers; \
- \
- \
- namespace find_rec_ \
- { \
- \
- namespace find_delegatee_res_ \
- { \
- /* Forward declaration. */ \
- template <typename delegatee, typename target> struct match_with; \
- \
- template <typename target> \
- struct match_with<stc::not_found, target> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename target> \
- struct match_with<stc::abstract, target> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename delegatee, typename target> \
- struct match_with \
- { \
- typedef typename find_rec<delegatee, target>::ret ret; \
- }; \
- \
- } /* end of namespace find_delegatee_res_ */ \
- \
- \
- /* Forward declaration. */ \
- template <typename source, typename target> struct match_with; \
- \
- template <typename target> \
- struct match_with<stc::none, target> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename source, typename target> \
- struct match_with \
- { \
- typedef typename find_local<source, target>::ret local_res; \
- typedef typename find_rec<stc_super(source), target>::ret super_res; \
- /* delegatee_type is the name of the (optional) virtual type */ \
- /* containing the (type of the) delgatee. */ \
- typedef typename \
- find_rec_in_supers<source, typedef_::delegatee_type>::ret delegatee; \
- \
- typedef typename \
- find_delegatee_res_::match_with<delegatee, target>::ret delegatee_res; \
- typedef typename \
- merge3<local_res, super_res, delegatee_res>::ret ret; \
- }; \
- \
- } /* end of namespace find_rec_ */ \
- \
- template <typename source, typename target> \
- struct find_rec \
- { \
- /* Result. */ \
- typedef typename find_rec_::match_with<source, target>::ret ret; \
- }; \
- \
- \
- /* --------------------------------------------- find_rec_in_supers. */ \
- \
- namespace find_rec_in_supers_ \
- { \
- /* Forward declaration. */ \
- template <typename source, typename target> struct match_with; \
- \
- template <typename target> \
- struct match_with<stc::none, target> \
- { \
- typedef stc::none ret; \
- }; \
- \
- template <typename source, typename target> \
- struct match_with \
- { \
- typedef typename find_local<source, target>::ret local_res; \
- typedef typename find_rec<stc_super(source), target>::ret super_res; \
- typedef typename merge2<local_res, super_res>::ret ret; \
- }; \
- \
- } /* end of namespace find_rec_in_supers_ */ \
- \
- template <typename source, typename target> \
- struct find_rec_in_supers \
- { \
- /* Result. */ \
- typedef typename \
- find_rec_in_supers_::match_with<source, target>::ret ret; \
- }; \
- \
- \
- /* ----------------------------------------------------------- find. */ \
- \
- namespace find_ \
- { \
- /* Forward declaration. */ \
- template <typename T> struct match_with; \
- \
- /* FIXME: We'd like to add a static abort here, but we can't, */ \
- /* since stc::abstract is not a free parameter (enabling this */ \
- /* abort statement would prevent any compilation). */ \
- template <> \
- struct match_with<stc::abstract> \
- /* : mlc::abort_<stc::abstract, \
- stc::ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT> */ \
- { \
- }; \
- \
- /* FIXME: We'd like to add a static abort here, but we can't, */ \
- /* since stc::not_delegated_abstract is not a free parameter */ \
- /* (enabling this abort statement would prevent any */ \
- /* compilation). */ \
- template <> \
- struct match_with<stc::not_delegated_abstract> \
- /* : mlc::abort_<stc::not_delegated_abstract, */ \
- /* stc::ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT> */ \
- { \
- }; \
- \
- template <> \
- struct match_with<stc::not_delegated> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename T> \
- struct match_with< stc::final<T> > \
- { \
- typedef T ret; \
- }; \
- \
- template <typename T> \
- struct match_with \
- { \
- typedef T ret; \
- }; \
- \
- } /* end of namespace find_ */ \
- \
- \
- /** Find a virtual type. */ \
- template <typename source, typename target> \
- struct find_vtype \
- { \
- typedef typename find_rec<source, target>::ret res; \
- /* Result. */ \
- typedef typename find_::match_with<res>::ret ret; \
- }; \
- \
- \
- /** Find a virtual type, and ensure it is found. */ \
- template <typename from, typename target> \
- struct vtype \
- { \
- typedef typename find_vtype<from, target>::ret res; \
- struct check_ : mlc::assert_< mlc::is_found_<res> > \
- { \
- typedef res ret; \
- }; \
- typedef typename check_::ret ret; \
- }; \
- \
-} /* end of SCOOPED_NAMESPACE */ \
- \
-struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_o_n;
+// FIXME: Document all these macros.
-/*------------------.
-| Shortcuts macro. |
-`------------------*/
+/// Access to associated type.
+/// \{
+# define stc_type_(Source, Target) vtype<Source, typedef_::Target>::ret
+# define stc_type(Source, Target) typename stc_type_(Source, Target)
+
+# define stc_type_in_(Namespace, Source, Target) \
+ Namespace::vtype<Source, Namespace::typedef_::Target>::ret
+# define stc_type_in(Namespace, Source, Target) \
+ typename stc_type_in_(Namespace, Source, Target)
+
+/// Access from the interior of the class.
+/// \{
+# define stc_get_type_(Target) vtype<Exact, typedef_::Target>::ret
+# define stc_get_type(Target) typename stc_get_type_(Target)
+/// \}
+
+/// \}
+
+
+/// Likewise, but more tolerant.
+/// \{
+# define stc_find_type_(Source, Target) \
+ find_vtype<Source, typedef_::Target>::ret
+# define stc_find_type(Source, Target) \
+ typename stc_find_type_(Source, Target)
+/// \}
+
+/// Boolean expression counterpart of stc_find_type
+/// \{
+# define stc_type_is_found(Target) \
+ stc::is_found< stc_deferred(Target) >
+# define stc_type_is_not_found(Target) \
+ stc::is_not_found< stc_deferred(Target) >
+/// \}
-// FIXME: Document all these macros.
-# define stc_find_vtype_(Namespace, Source, Target) \
- Namespace::find_vtype<Source, Namespace::typedef_::Target##_type>::ret
+# define stc_is_a(T, U) \
+ mlc::wrap_< \
+ typename mlc::is_a_< sizeof(mlc::form::of< U >()) > \
+ ::template ret< typename mlc::basic_< stc_deferred(T) >::ret, U > \
+ >
-# define stc_find_vtype(Namespace, Source, Target) \
- typename stc_find_vtype_(Namespace, Source, Target)
+
+/// For concepts.
+/// \{
+# define stc_typename(Target) typedef stc_type(Exact, Target) Target
+# define stc_using(Target) typedef typename super::Target Target
+# define stc_using_from(Abstraction, Target) \
+ typedef typename Abstraction<Exact>::Target Target
+# define stc_deduce_typename(Src, Target) typedef stc_type(Src, Target) Target
+/// \}
+
+
+/// For implementation classes.
+/// \{
+/// Dummy
+# define stc_deferred(Target) \
+ stc_find_type(Exact, Target)
+// typename deferred_vtype<Exact, typedef_::Target >::ret
+# define stc_lookup(Target) \
+ typedef typename vtype< stc_type(current, exact_type), \
+ typedef_::Target>::ret Target
+/// \}
+
+
+/// For set_impl classes.
+/// \{
+# define stc_deferred_typename(Target) typedef stc_deferred(Target) Target
+/// \}
// Dummy alias, for compatibility purpose (deferred virtual types are
// not currently handled by this version of stc/scoop2.hh).
-# define stc_deferred_vtype(Namespace, From, Target) \
- stc_find_vtype(Namespace, From, Target)
+# define stc_deferred_type(Source, Target) \
+ stc_find_type(Source, Target)
-# define stc_vtype_(Namespace, From, Target) \
- Namespace::vtype<From, Namespace::typedef_::Target##_type>::ret
-# define stc_vtype(Namespace, From, Target) \
- typename stc_vtype_(Namespace, From, Target)
+// 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(Target) mlc::eq_< stc_find_type(E, Target), stc::true_ >
+
+// Likewise.
+# define stc_is_not(Target) \
+ mlc::or_< mlc::eq_< stc_find_type(E, Target), \
+ mlc::not_found >, \
+ mlc::eq_< stc_find_type(E, Target), \
+ stc::false_ > >
-# define stc_find_deduce_vtype_(Namespace, From, Target1, Target2) \
- Namespace::find_vtype< \
- Namespace::find_vtype< \
- From, \
- Namespace::typedef_::Target1##_type \
- >::ret, \
- Namespace::typedef_::Target2##_type \
- >::ret
-
-# define stc_find_deduce_vtype(Namespace, From, Target1, Target2) \
- typename Namespace::find_vtype< \
- typename Namespace::find_vtype< \
- From, \
- Namespace::typedef_::Target1##_type \
- >::ret, \
- Namespace::typedef_::Target2##_type \
- >::ret
-
-# define stc_deduce_deferred_vtype(Namespace, From, Target1, Target2) \
- stc_find_deduce_vtype(Namespace, From, Target1, Target2)
-
-# define stc_deduce_vtype_(Namespace, From, Target1, Target2) \
- Namespace::vtype< \
- Namespace::vtype< \
- From, \
- Namespace::typedef_::Target1##_type \
- >::ret, \
- Namespace::typedef_::Target2##_type \
- >::ret
-
-# define stc_deduce_vtype(Namespace, From, Target1, Target2) \
- typename Namespace::vtype< \
- typename Namespace::vtype< \
- From, \
- Namespace::typedef_::Target1##_type \
- >::ret, \
- Namespace::typedef_::Target2##_type \
- >::ret
+# define stc_prop(Source, Target) \
+ typename mlc::eq_< stc_find_type(Source, Target), stc::true_ >::eval
#endif // ! STC_SCOOP_ALT_HH
Index: stc/Makefile.am
--- stc/Makefile.am (revision 877)
+++ stc/Makefile.am (working copy)
@@ -8,6 +8,7 @@
find_exact.hh \
scoop.hh \
scoop-alt.hh \
+ scoop-alt.inc \
valist_aggregator.hh \
\
internal/extract_vtype_from_list.hh \
Index: stc/scoop-alt.inc
--- stc/scoop-alt.inc (revision 877)
+++ stc/scoop-alt.inc (working copy)
@@ -1,3 +1,5 @@
+ // -*- C++ -*-
+
// Copyright (C) 2005, 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
@@ -26,685 +28,840 @@
// Public License.
-/* \file stc/scoop-alt.hh
+#ifndef STATIC_SCOOP_ALT_HH_INCLUDED
+# error "alt/scoop.inc included but alt/scoop.hh hasn't been included"
+#endif
+
+
+/* \file stc/scoop-alt.inc
\brief Alternative equipment for SCOOP 2 (in particular, virtual
- types). */
+ types).
+
+ To be included inside the namespace to equip. \file
+ stc/scoop-alt.hh must have been previously included before this
+ file. */
-#ifndef STC_SCOOP_ALT_HH
-# define STC_SCOOP_ALT_HH
+/* Install core virtual types in the equipped namespace. */
+/* \{ */
+mlc_decl_typedef(exact_);
-# include <mlc/flags.hh>
-# include <mlc/typedef.hh>
-# include <mlc/abort.hh>
+mlc_decl_typedef(category);
+mlc_decl_typedef(behavior);
+mlc_decl_typedef(delegatee);
+/* \} */
-# include <stc/internal/match-with.hh>
+/*--------.
+| Super. |
+`--------*/
-namespace stc
+/// Default version.
+template <typename class_name>
+struct super_trait_ :
+ mlc::abort_< class_name,
+ stc::ERROR::super_trait_not_defined_for_< class_name > >
{
- /* FIXME: Define a real stc::none, instead of making it an alias of
- mlc::none. For compatibility purpose with the current
- implementation of the SCOOP 2 paradigm (see stc/scoop.hh), we
- need to have stc::none be equal to mlc::none. */
-#if 0
- struct none {};
-#endif
- using mlc::none;
+ typedef mlc::none ret;
+};
- struct not_found;
- struct abstract;
- struct not_delegated;
- struct not_delegated_abstract;
- template <typename T> struct final;
+/// Version for abstractions (security cap).
+template <template <class> class abstraction, typename Exact>
+struct super_trait_< abstraction<Exact> >
+{
+ typedef mlc::none ret;
+};
+/// Helper for const versions.
+template <typename class_name>
+struct super_trait_ <const class_name> : public super_trait_<class_name>
+{
+};
+
+
+/*---------.
+| Vtypes. |
+`---------*/
+
+template <typename class_name>
+struct vtypes
+{
+};
+
+/// Helper for const versions.
+template <typename class_name>
+struct vtypes <const class_name> : public vtypes <class_name>
+{
+};
+
+template <typename class_name, typename type_name>
+struct single_vtype
+{
+ typedef mlc::not_found ret;
+};
+
+
+
+/*------.
+| Any. |
+`------*/
+
+// FIXME: Get rid of stc/any.hh?
+
+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() {}
+};
+
+
+/*--------.
+| Exact. |
+`--------*/
+
+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);
+}
+
+
+/*----------------------.
+| Virtual type lookup. |
+`----------------------*/
+
+/* ----------------------------------------------------- find_local. */
+
+/* Highly inspired from Th�o's get_stm! */
+
+namespace find_local_
+{
+ /* Forward declaration. */
+ template <typename T, typename U> struct match_with;
+
+ template <typename T>
+ struct match_with <T, mlc::not_found>
+ {
+ typedef T ret;
+ };
+
+ template <typename U>
+ struct match_with <mlc::not_found, U>
+ {
+ typedef U ret;
+ };
+
+ template <>
+ struct match_with <mlc::not_found, mlc::not_found>
+ {
+ typedef stc::not_found ret;
+ };
+
+ template <typename T, typename U>
+ struct match_with :
+ mlc::abort_<T,
+ stc::ERROR::IN_find_local_VIRTUAL_TYPE_MULTIPLY_DEFINED>
+ {
+ };
+
+} /* End of namespace find_local_. */
+
+template <typename source, typename target>
+struct find_local
+{
+ typedef vtypes<source> decl1;
+ typedef typename target::template from_<decl1>::ret res1;
+
+ typedef single_vtype<source, target> decl2;
+ typedef typename decl2::ret ret2;
+
+
+ /* Result. */
+ typedef typename find_local_::match_with<res1, ret2>::ret ret;
+};
+
+
+/* --------------------------------------------------------- merge2. */
+
+
+namespace merge2_
+{
+ /* Forward declaration. */
+ template <typename T, typename U> struct match_with;
+
+
+ /* ----------------------------- */
+ /* local_res == stc::not_found. */
+ /* ----------------------------- */
+
+ stc_internal_match_pair_0p_with(stc::not_found, stc::not_found,
+ stc::not_found);
+
+ stc_internal_match_pair_0p_with(stc::not_found, stc::abstract,
+ stc::not_found);
+
+ stc_internal_match_pair_1p_with(U,
+ stc::not_found, stc::final<U>,
+ stc::final<U>);
+
+ stc_internal_match_pair_1p_with(U,
+ stc::not_found, U,
+ U);
+
+
+ /* ---------------------------- */
+ /* local_res == stc::abstract. */
+ /* ---------------------------- */
+
+ stc_internal_match_pair_0p_with(stc::abstract, stc::not_found,
+ stc::abstract);
+
+ stc_internal_match_pair_0p_with(stc::abstract, stc::abstract,
+ stc::abstract);
+
+ stc_internal_match_pair_1p_with_error(U,
+ stc::abstract, stc::final<U>,
+ stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT);
+
+ stc_internal_match_pair_1p_with_error(U,
+ stc::abstract, U,
+ stc::ERROR::IN_merge2_VIRTUAL_TYPE_REDEFINED_ABSTRACT);
+
+
+ /* ---------------------------- */
+ /* local_res == stc::final<T>. */
+ /* ---------------------------- */
+
+ stc_internal_match_pair_1p_with(T,
+ stc::final<T>, stc::not_found,
+ stc::final<T>);
+
+ stc_internal_match_pair_1p_with(T,
+ stc::final<T>, stc::abstract,
+ stc::final<T>);
+
+ stc_internal_match_pair_2p_with_error(T, U,
+ stc::final<T>, stc::final<U>,
+ stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL);
+
+ stc_internal_match_pair_2p_with(T, U,
+ stc::final<T>, U,
+ stc::final<T>);
+
+
+ /* ---------------- */
+ /* local_res == T. */
+ /* ---------------- */
+
+ stc_internal_match_pair_1p_with(T,
+ T, stc::not_found,
+ T);
+
+ stc_internal_match_pair_1p_with(T,
+ T, stc::abstract,
+ T);
+
+ stc_internal_match_pair_2p_with_error(T, U,
+ T, stc::final<U>,
+ stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED);
+
+ template <typename T, typename U>
+ struct match_with
+ {
+ typedef T ret;
+ };
+
+} /* End of namespace merge2_. */
+
+template <typename local_res, typename super_res>
+struct merge2
+{
+ /* Result. */
+ typedef typename merge2_::match_with<local_res, super_res>::ret ret;
+};
+
+
+/* --------------------------------------------------------- merge3. */
+
+
+namespace merge3_
+{
+ /* Forward declaration. */
+ template <typename T, typename U, typename V> struct match_with;
+
+
+ /* ----------------------------- */
+ /* local_res == stc::not_found. */
+ /* ----------------------------- */
+
+ /* super_res == stc::not_found. */
+ stc_internal_match_triple_0p_with(
+ stc::not_found, stc::not_found, stc::not_found,
+ stc::not_found);
+
+ stc_internal_match_triple_0p_with(
+ stc::not_found, stc::not_found, stc::abstract,
+ stc::not_found);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::not_found, stc::not_found, stc::final<V>,
+ stc::final<V>);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::not_found, stc::not_found, V,
+ V);
+
+ /* super_res == stc::abstract. */
+ stc_internal_match_triple_0p_with(
+ stc::not_found, stc::abstract, stc::not_found,
+ stc::not_found);
+
+ stc_internal_match_triple_0p_with(
+ stc::not_found, stc::abstract, stc::abstract,
+ stc::abstract);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::not_found, stc::abstract, stc::final<V>,
+ stc::final<V>);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::not_found, stc::abstract, V,
+ V);
+
+ /* super_res is a concrete type. */
+ stc_internal_match_triple_2p_with(U, V,
+ stc::not_found, stc::final<U>, V,
+ stc::final<U>);
+
+ stc_internal_match_triple_2p_with(U, V,
+ stc::not_found, U, V,
+ U);
+
+
+ /* ---------------------------- */
+ /* local_res == stc::abstract. */
+ /* ---------------------------- */
+
+ /* super_res == stc::not_found. */
+ stc_internal_match_triple_0p_with(
+ stc::abstract, stc::not_found, stc::not_found,
+ stc::abstract);
+
+ stc_internal_match_triple_0p_with(
+ stc::abstract, stc::not_found, stc::abstract,
+ stc::abstract);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::abstract, stc::not_found, stc::final<V>,
+ stc::final<V>);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::abstract, stc::not_found, V,
+ V);
+
+
+ /* super_res == stc::abstract. */
+ stc_internal_match_triple_0p_with(
+ stc::abstract, stc::abstract, stc::not_found,
+ stc::abstract);
+
+ stc_internal_match_triple_0p_with(
+ stc::abstract, stc::abstract, stc::abstract,
+ stc::abstract);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::abstract, stc::abstract, stc::final<V>,
+ stc::final<V>);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::abstract, stc::abstract, V,
+ V);
+
+
+ /* super_res == stc::not_delegated_abstract. */
+ stc_internal_match_triple_1p_with(V,
+ stc::abstract, stc::not_delegated_abstract, V,
+ stc::not_delegated_abstract);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::abstract, stc::not_delegated, V,
+ stc::not_delegated_abstract);
+
+
+ /* super_res is a concrete type. */
+ stc_internal_match_triple_2p_with_error(U, V,
+ stc::abstract, stc::final<U>, V,
+ stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT);
+
+ stc_internal_match_triple_2p_with_error(U, V,
+ stc::abstract, U, V,
+ stc::ERROR::IN_merge3_VIRTUAL_TYPE_REDEFINED_ABSTRACT);
+
+
+ /* --------------------------------- */
+ /* local_res == stc::not_delegated. */
+ /* --------------------------------- */
+
+ stc_internal_match_triple_1p_with(V,
+ stc::not_delegated, stc::not_found, V,
+ stc::not_delegated);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::not_delegated, stc::abstract, V,
+ stc::not_delegated_abstract);
+
+ stc_internal_match_triple_1p_with(V,
+ stc::not_delegated, stc::not_delegated_abstract, V,
+ stc::not_delegated_abstract);
+
+
+ /* ------------------------------------------ */
+ /* local_res == stc::not_delegated_abstract. */
+ /* ------------------------------------------ */
+
+ /* FIXME: Shouldn't we introduce a means to tag a vtype both as */
+ /* abstract *and* not delegated? (Currently, the rule below */
+ /* prevents this). */
+ stc_internal_match_triple_2p_with_error(U, V,
+ stc::not_delegated_abstract, U, V,
+ stc::ERROR::IN_merge3_LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT);
+
+
+ /* ---------------------------- */
+ /* local_res == stc::final<T>. */
+ /* ---------------------------- */
+
+ stc_internal_match_triple_3p_with_error(T, U, V,
+ stc::final<T>, stc::final<U>, V,
+ stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL);
+
+ stc_internal_match_triple_3p_with(T, U, V,
+ stc::final<T>, U, V,
+ stc::final<T>);
+
+
+ /* ---------------- */
+ /* local_res == T. */
+ /* ---------------- */
+
+ stc_internal_match_triple_3p_with_error(T, U, V,
+ T, stc::final<U>, V,
+ stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED);
+
+ template <typename T, typename U, typename V>
+ struct match_with
+ {
+ typedef T ret;
+ };
+
+} /* End of namespace merge3_. */
+
+
+template <typename local_res, typename super_res, typename delegatee_res>
+struct merge3
+{
+ /* Result. */
+ typedef typename
+ merge3_::match_with<local_res, super_res, delegatee_res>::ret ret;
+};
+
+
+/* ------------------------------------------------------ find_rec. */
+
+/* Forward declarations. */
+template <typename source, typename target> struct find_rec;
+template <typename source, typename target> struct find_rec_in_supers;
+
+
+namespace find_rec_
+{
+
+ namespace find_delegatee_res_
+ {
+ /* Forward declaration. */
+ template <typename delegatee, typename target> struct match_with;
+
+ template <typename target>
+ struct match_with<stc::not_found, target>
+ {
+ typedef stc::not_found ret;
+ };
+
+ template <typename target>
+ struct match_with<stc::abstract, target>
+ {
+ typedef stc::not_found ret;
+ };
+
+ template <typename delegatee, typename target>
+ struct match_with
+ {
+ typedef typename find_rec<delegatee, target>::ret ret;
+ };
+
+ } /* End of namespace find_delegatee_res_. */
+
+
+ /* Forward declaration. */
+ template <typename source, typename target> struct match_with;
+
+ template <typename target>
+ struct match_with<stc::none, target>
+ {
+ typedef stc::not_found ret;
+ };
+
+ template <typename source, typename target>
+ struct match_with
+ {
+ typedef typename find_local<source, target>::ret local_res;
+ typedef typename find_rec<stc_super(source), target>::ret super_res;
+ /* delegatee is the name of the (optional) virtual type */
+ /* containing the (type of the) delgatee. */
+ typedef typename
+ find_rec_in_supers<source, typedef_::delegatee>::ret delegatee;
+
+ typedef typename
+ find_delegatee_res_::match_with<delegatee, target>::ret delegatee_res;
+ typedef typename
+ merge3<local_res, super_res, delegatee_res>::ret ret;
+ };
+
+} /* End of namespace find_rec_. */
+
+template <typename source, typename target>
+struct find_rec
+{
+ /* Result. */
+ typedef typename find_rec_::match_with<source, target>::ret ret;
+};
+
+
+/* --------------------------------------------- find_rec_in_supers. */
+
+namespace find_rec_in_supers_
+{
+ /* Forward declaration. */
+ template <typename source, typename target> struct match_with;
+
+ template <typename target>
+ struct match_with<stc::none, target>
+ {
+ typedef stc::none ret;
+ };
+
+ template <typename source, typename target>
+ struct match_with
+ {
+ typedef typename find_local<source, target>::ret local_res;
+ typedef typename find_rec<stc_super(source), target>::ret super_res;
+ typedef typename merge2<local_res, super_res>::ret ret;
+ };
+
+} /* End of namespace find_rec_in_supers_. */
+
+template <typename source, typename target>
+struct find_rec_in_supers
+{
+ /* Result. */
+ typedef typename
+ find_rec_in_supers_::match_with<source, target>::ret ret;
+};
+
+
+/* ----------------------------------------------------------- find. */
+
+namespace find_
+{
+ /* Forward declaration. */
+ template <typename T> struct match_with;
+
+ /* FIXME: We'd like to add a static abort here, but we can't, */
+ /* since stc::abstract is not a free parameter (enabling this */
+ /* abort statement would prevent any compilation). */
+ template <>
+ struct match_with<stc::abstract>
+ /* : mlc::abort_<stc::abstract, */
+ /* stc::ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT> */
+ {
+ };
+
+ /* FIXME: We'd like to add a static abort here, but we can't, */
+ /* since stc::not_delegated_abstract is not a free parameter */
+ /* (enabling this abort statement would prevent any */
+ /* compilation). */
+ template <>
+ struct match_with<stc::not_delegated_abstract>
+ /* : mlc::abort_<stc::not_delegated_abstract, */
+ /* stc::ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT> */
+ {
+ };
+
+ template <>
+ struct match_with<stc::not_delegated>
+ {
+ typedef stc::not_found ret;
+ };
- /// \brief Shortcuts for comparison with stc::not_found.
- ///
- /// Duplicate with their Metalic's homonyms, but still useful, since
- /// they deal with std::not_found (not mlc::not_found).
- /// \{
template <typename T>
- struct is_not_found_ : public mlc_is_a(T, stc::not_found)::bexpr
+ struct match_with< stc::final<T> >
{
+ typedef T ret;
};
template <typename T>
- struct is_found_ : public mlc_is_not_a(T, stc::not_found)::bexpr
+ struct match_with
{
+ typedef T ret;
};
- /// \}
- namespace ERROR
+} /* End of namespace find_. */
+
+
+/** Find a virtual type. */
+template <typename source, typename target>
+struct find_vtype
+{
+ typedef typename find_rec<source, target>::ret res;
+ /* Result. */
+ typedef typename find_::match_with<res>::ret ret;
+};
+
+
+/** Find a virtual type, and ensure it is found. */
+template <typename from, typename target>
+struct vtype
+{
+ typedef typename find_vtype<from, target>::ret res;
+ struct check_ : mlc::assert_< mlc::is_found_<res> >
+ {
+ typedef res ret;
+ };
+ typedef typename check_::ret ret;
+};
+
+
+/*------------.
+| Selectors. |
+`------------*/
+
+// FIXME: This part has been copied as-is from Th�o's version
+// (oln/stc/scoop.hxx).
+
+mlc_case_equipment_for_namespace(internal);
+
+
+namespace internal
+{
+
+
+ template < template <class> class abstraction,
+ unsigned num = 1 >
+ struct selector
{
- struct IN_find_VIRTUAL_TYPE_IS_ABSTRACT;
+ 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() {}
+ };
+
- struct IN_find_local_VIRTUAL_TYPE_MULTIPLY_DEFINED;
+ 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 of the implementation hierarchy. |
+`--------------------------------------------*/
+
+// FIXME: This part has been copied as-is from Th�o's version
+// (oln/stc/scoop.hxx).
+
+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() {}
+};
+
+
+/*----------------------------.
+| Automatic implementations. |
+`----------------------------*/
+
+// FIXME: This part has been copied (almost) as-is from Th�o's version
+// (oln/stc/scoop.hxx).
+
+namespace automatic
+{
+
+ /// set_impl
+ ///
+ /// To be defined by the client.
+ template < template <class> class abstraction, typename behavior,
+ typename E >
+ struct set_impl;
+
+
+ /// 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 */ };
+ /// \}
- struct IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
- struct IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL;
- struct IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED;
- struct IN_merge2_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
-
- struct IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
- struct IN_merge3_VIRTUAL_TYPE_REDEFINED_ABSTRACT;
- struct IN_merge3_LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT;
- struct IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL;
- struct IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED;
-
- } // end of namespace ERROR
-
-} // end of namespace stc
-
-
-#define stc_super(T) typename set_super_type< T >::ret
-
-// Based on doc/algorithm.ml.
-
-
-
-#define stc_scoop_equipment_for_namespace(SCOOPED_NAMESPACE) \
- \
-namespace SCOOPED_NAMESPACE \
-{ \
- \
- /* Declare delegatee_type. */ \
- mlc_decl_typedef(delegatee_type); \
- \
- \
- template <typename class_name> \
- struct set_super_type \
- { \
- }; \
- \
- template <typename class_name> \
- struct vtypes \
- { \
- }; \
- \
- template <typename class_name, typename type_name> \
- struct single_vtype \
- { \
- typedef mlc::not_found ret; \
- }; \
- \
- /* ----------------------------------------------------- find_local. */ \
- \
- /* Highly inspired from Th�o's get_stm! */ \
- \
- namespace find_local_ \
- { \
- /* Forward declaration. */ \
- template <typename T, typename U> struct match_with; \
- \
- template <typename T> \
- struct match_with <T, mlc::not_found> \
- { \
- typedef T ret; \
- }; \
- \
- template <typename U> \
- struct match_with <mlc::not_found, U> \
- { \
- typedef U ret; \
- }; \
- \
- template <> \
- struct match_with <mlc::not_found, mlc::not_found> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename T, typename U> \
- struct match_with : \
- mlc::abort_<T, \
- stc::ERROR::IN_find_local_VIRTUAL_TYPE_MULTIPLY_DEFINED> \
- { \
- }; \
- \
- } /* end of namespace find_local_ */ \
- \
- template <typename source, typename target> \
- struct find_local \
- { \
- typedef SCOOPED_NAMESPACE::vtypes<source> decl1; \
- typedef typename target::template from_<decl1>::ret res1; \
- \
- typedef SCOOPED_NAMESPACE::single_vtype<source, target> decl2; \
- typedef typename decl2::ret ret2; \
- \
- \
- /* Result. */ \
- typedef typename find_local_::match_with<res1, ret2>::ret ret; \
- }; \
- \
- \
- /* --------------------------------------------------------- merge2. */ \
- \
- \
- namespace merge2_ \
- { \
- /* Forward declaration. */ \
- template <typename T, typename U> struct match_with; \
- \
- \
- /* ----------------------------- */ \
- /* local_res == stc::not_found. */ \
- /* ----------------------------- */ \
- \
- stc_internal_match_pair_0p_with(stc::not_found, stc::not_found, \
- stc::not_found); \
- \
- stc_internal_match_pair_0p_with(stc::not_found, stc::abstract, \
- stc::not_found); \
- \
- stc_internal_match_pair_1p_with(U, \
- stc::not_found, stc::final<U>, \
- stc::final<U>); \
- \
- stc_internal_match_pair_1p_with(U, \
- stc::not_found, U, \
- U); \
- \
- \
- /* ---------------------------- */ \
- /* local_res == stc::abstract. */ \
- /* ---------------------------- */ \
- \
- stc_internal_match_pair_0p_with(stc::abstract, stc::not_found, \
- stc::abstract); \
- \
- stc_internal_match_pair_0p_with(stc::abstract, stc::abstract, \
- stc::abstract); \
- \
- stc_internal_match_pair_1p_with_error(U, \
- stc::abstract, stc::final<U>, \
- stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
- \
- stc_internal_match_pair_1p_with_error(U, \
- stc::abstract, U, \
- stc::ERROR::IN_merge2_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
- \
- \
- /* ---------------------------- */ \
- /* local_res == stc::final<T>. */ \
- /* ---------------------------- */ \
- \
- stc_internal_match_pair_1p_with(T, \
- stc::final<T>, stc::not_found, \
- stc::final<T>); \
- \
- stc_internal_match_pair_1p_with(T, \
- stc::final<T>, stc::abstract, \
- stc::final<T>); \
- \
- stc_internal_match_pair_2p_with_error(T, U, \
- stc::final<T>, stc::final<U>, \
- stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL); \
- \
- stc_internal_match_pair_2p_with(T, U, \
- stc::final<T>, U, \
- stc::final<T>); \
- \
- \
- /* ---------------- */ \
- /* local_res == T. */ \
- /* ---------------- */ \
- \
- stc_internal_match_pair_1p_with(T, \
- T, stc::not_found, \
- T); \
- \
- stc_internal_match_pair_1p_with(T, \
- T, stc::abstract, \
- T); \
- \
- stc_internal_match_pair_2p_with_error(T, U, \
- T, stc::final<U>, \
- stc::ERROR::IN_merge2_FINAL_VIRTUAL_TYPE_REDEFINED); \
- \
- template <typename T, typename U> \
- struct match_with \
- { \
- typedef T ret; \
- }; \
- \
- } /* end of namespace merge2_ */ \
- \
- template <typename local_res, typename super_res> \
- struct merge2 \
- { \
- /* Result. */ \
- typedef typename merge2_::match_with<local_res, super_res>::ret ret; \
- }; \
- \
- \
- /* --------------------------------------------------------- merge3. */ \
- \
- \
- namespace merge3_ \
- { \
- /* Forward declaration. */ \
- template <typename T, typename U, typename V> struct match_with; \
- \
- \
- /* ----------------------------- */ \
- /* local_res == stc::not_found. */ \
- /* ----------------------------- */ \
- \
- /* super_res == stc::not_found. */ \
- stc_internal_match_triple_0p_with( \
- stc::not_found, stc::not_found, stc::not_found, \
- stc::not_found); \
- \
- stc_internal_match_triple_0p_with( \
- stc::not_found, stc::not_found, stc::abstract, \
- stc::not_found); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_found, stc::not_found, stc::final<V>, \
- stc::final<V>); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_found, stc::not_found, V, \
- V); \
- \
- /* super_res == stc::abstract. */ \
- stc_internal_match_triple_0p_with( \
- stc::not_found, stc::abstract, stc::not_found, \
- stc::not_found); \
- \
- stc_internal_match_triple_0p_with( \
- stc::not_found, stc::abstract, stc::abstract, \
- stc::abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_found, stc::abstract, stc::final<V>, \
- stc::final<V>); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_found, stc::abstract, V, \
- V); \
- \
- /* super_res is a concrete type. */ \
- stc_internal_match_triple_2p_with(U, V, \
- stc::not_found, stc::final<U>, V, \
- stc::final<U>); \
- \
- stc_internal_match_triple_2p_with(U, V, \
- stc::not_found, U, V, \
- U); \
- \
- \
- /* ---------------------------- */ \
- /* local_res == stc::abstract. */ \
- /* ---------------------------- */ \
- \
- /* super_res == stc::not_found. */ \
- stc_internal_match_triple_0p_with( \
- stc::abstract, stc::not_found, stc::not_found, \
- stc::abstract); \
- \
- stc_internal_match_triple_0p_with( \
- stc::abstract, stc::not_found, stc::abstract, \
- stc::abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::not_found, stc::final<V>, \
- stc::final<V>); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::not_found, V, \
- V); \
- \
- \
- /* super_res == stc::abstract. */ \
- stc_internal_match_triple_0p_with( \
- stc::abstract, stc::abstract, stc::not_found, \
- stc::abstract); \
- \
- stc_internal_match_triple_0p_with( \
- stc::abstract, stc::abstract, stc::abstract, \
- stc::abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::abstract, stc::final<V>, \
- stc::final<V>); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::abstract, V, \
- V); \
- \
- \
- /* super_res == stc::not_delegated_abstract. */ \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::not_delegated_abstract, V, \
- stc::not_delegated_abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::abstract, stc::not_delegated, V, \
- stc::not_delegated_abstract); \
- \
- \
- /* super_res is a concrete type. */ \
- stc_internal_match_triple_2p_with_error(U, V, \
- stc::abstract, stc::final<U>, V, \
- stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
- \
- stc_internal_match_triple_2p_with_error(U, V, \
- stc::abstract, U, V, \
- stc::ERROR::IN_merge3_VIRTUAL_TYPE_REDEFINED_ABSTRACT); \
- \
- \
- /* --------------------------------- */ \
- /* local_res == stc::not_delegated. */ \
- /* --------------------------------- */ \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_delegated, stc::not_found, V, \
- stc::not_delegated); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_delegated, stc::abstract, V, \
- stc::not_delegated_abstract); \
- \
- stc_internal_match_triple_1p_with(V, \
- stc::not_delegated, stc::not_delegated_abstract, V, \
- stc::not_delegated_abstract); \
- \
- \
- /* ------------------------------------------ */ \
- /* local_res == stc::not_delegated_abstract. */ \
- /* ------------------------------------------ */ \
- \
- /* FIXME: Shouldn't we introduce a means to tag a vtype both as */ \
- /* abstract *and* not delegated? (Currently, the rule below */ \
- /* prevents this). */ \
- stc_internal_match_triple_2p_with_error(U, V, \
- stc::not_delegated_abstract, U, V, \
- stc::ERROR::IN_merge3_LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT); \
- \
- \
- /* ---------------------------- */ \
- /* local_res == stc::final<T>. */ \
- /* ---------------------------- */ \
- \
- stc_internal_match_triple_3p_with_error(T, U, V, \
- stc::final<T>, stc::final<U>, V, \
- stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED_FINAL); \
- \
- stc_internal_match_triple_3p_with(T, U, V, \
- stc::final<T>, U, V, \
- stc::final<T>); \
- \
- \
- /* ---------------- */ \
- /* local_res == T. */ \
- /* ---------------- */ \
- \
- stc_internal_match_triple_3p_with_error(T, U, V, \
- T, stc::final<U>, V, \
- stc::ERROR::IN_merge3_FINAL_VIRTUAL_TYPE_REDEFINED); \
- \
- template <typename T, typename U, typename V> \
- struct match_with \
- { \
- typedef T ret; \
- }; \
- \
- } /* end of namespace merge3_ */ \
- \
- \
- template <typename local_res, typename super_res, typename delegatee_res> \
- struct merge3 \
- { \
- /* Result. */ \
- typedef typename \
- merge3_::match_with<local_res, super_res, delegatee_res>::ret ret; \
- }; \
- \
- \
- /* ------------------------------------------------------ find_rec. */ \
- \
- /* Forward declarations. */ \
- template <typename source, typename target> struct find_rec; \
- template <typename source, typename target> struct find_rec_in_supers; \
- \
- \
- namespace find_rec_ \
- { \
- \
- namespace find_delegatee_res_ \
- { \
- /* Forward declaration. */ \
- template <typename delegatee, typename target> struct match_with; \
- \
- template <typename target> \
- struct match_with<stc::not_found, target> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename target> \
- struct match_with<stc::abstract, target> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename delegatee, typename target> \
- struct match_with \
- { \
- typedef typename find_rec<delegatee, target>::ret ret; \
- }; \
- \
- } /* end of namespace find_delegatee_res_ */ \
- \
- \
- /* Forward declaration. */ \
- template <typename source, typename target> struct match_with; \
- \
- template <typename target> \
- struct match_with<stc::none, target> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename source, typename target> \
- struct match_with \
- { \
- typedef typename find_local<source, target>::ret local_res; \
- typedef typename find_rec<stc_super(source), target>::ret super_res; \
- /* delegatee_type is the name of the (optional) virtual type */ \
- /* containing the (type of the) delgatee. */ \
- typedef typename \
- find_rec_in_supers<source, typedef_::delegatee_type>::ret delegatee; \
- \
- typedef typename \
- find_delegatee_res_::match_with<delegatee, target>::ret delegatee_res; \
- typedef typename \
- merge3<local_res, super_res, delegatee_res>::ret ret; \
- }; \
- \
- } /* end of namespace find_rec_ */ \
- \
- template <typename source, typename target> \
- struct find_rec \
- { \
- /* Result. */ \
- typedef typename find_rec_::match_with<source, target>::ret ret; \
- }; \
- \
- \
- /* --------------------------------------------- find_rec_in_supers. */ \
- \
- namespace find_rec_in_supers_ \
- { \
- /* Forward declaration. */ \
- template <typename source, typename target> struct match_with; \
- \
- template <typename target> \
- struct match_with<stc::none, target> \
- { \
- typedef stc::none ret; \
- }; \
- \
- template <typename source, typename target> \
- struct match_with \
- { \
- typedef typename find_local<source, target>::ret local_res; \
- typedef typename find_rec<stc_super(source), target>::ret super_res; \
- typedef typename merge2<local_res, super_res>::ret ret; \
- }; \
- \
- } /* end of namespace find_rec_in_supers_ */ \
- \
- template <typename source, typename target> \
- struct find_rec_in_supers \
- { \
- /* Result. */ \
- typedef typename \
- find_rec_in_supers_::match_with<source, target>::ret ret; \
- }; \
- \
- \
- /* ----------------------------------------------------------- find. */ \
- \
- namespace find_ \
- { \
- /* Forward declaration. */ \
- template <typename T> struct match_with; \
- \
- /* FIXME: We'd like to add a static abort here, but we can't, */ \
- /* since stc::abstract is not a free parameter (enabling this */ \
- /* abort statement would prevent any compilation). */ \
- template <> \
- struct match_with<stc::abstract> \
- /* : mlc::abort_<stc::abstract, \
- stc::ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT> */ \
- { \
- }; \
- \
- /* FIXME: We'd like to add a static abort here, but we can't, */ \
- /* since stc::not_delegated_abstract is not a free parameter */ \
- /* (enabling this abort statement would prevent any */ \
- /* compilation). */ \
- template <> \
- struct match_with<stc::not_delegated_abstract> \
- /* : mlc::abort_<stc::not_delegated_abstract, */ \
- /* stc::ERROR::IN_find_VIRTUAL_TYPE_IS_ABSTRACT> */ \
- { \
- }; \
- \
- template <> \
- struct match_with<stc::not_delegated> \
- { \
- typedef stc::not_found ret; \
- }; \
- \
- template <typename T> \
- struct match_with< stc::final<T> > \
- { \
- typedef T ret; \
- }; \
- \
- template <typename T> \
- struct match_with \
- { \
- typedef T ret; \
- }; \
- \
- } /* end of namespace find_ */ \
- \
- \
- /** Find a virtual type. */ \
- template <typename source, typename target> \
- struct find_vtype \
- { \
- typedef typename find_rec<source, target>::ret res; \
- /* Result. */ \
- typedef typename find_::match_with<res>::ret ret; \
- }; \
- \
- \
- /** Find a virtual type, and ensure it is found. */ \
- template <typename from, typename target> \
- struct vtype \
- { \
- typedef typename find_vtype<from, target>::ret res; \
- struct check_ : mlc::assert_< mlc::is_found_<res> > \
- { \
- typedef res ret; \
- }; \
- typedef typename check_::ret ret; \
- }; \
- \
-} /* end of SCOOPED_NAMESPACE */ \
- \
-struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_o_n;
-
-
-/*------------------.
-| Shortcuts macro. |
-`------------------*/
-
-// FIXME: Document all these macros.
-
-# define stc_find_vtype_(Namespace, Source, Target) \
- Namespace::find_vtype<Source, Namespace::typedef_::Target##_type>::ret
-
-# define stc_find_vtype(Namespace, Source, Target) \
- typename stc_find_vtype_(Namespace, Source, Target)
-
-// Dummy alias, for compatibility purpose (deferred virtual types are
-// not currently handled by this version of stc/scoop2.hh).
-# define stc_deferred_vtype(Namespace, From, Target) \
- stc_find_vtype(Namespace, From, Target)
-
-# define stc_vtype_(Namespace, From, Target) \
- Namespace::vtype<From, Namespace::typedef_::Target##_type>::ret
-
-# define stc_vtype(Namespace, From, Target) \
- typename stc_vtype_(Namespace, From, Target)
-
-# define stc_find_deduce_vtype_(Namespace, From, Target1, Target2) \
- Namespace::find_vtype< \
- Namespace::find_vtype< \
- From, \
- Namespace::typedef_::Target1##_type \
- >::ret, \
- Namespace::typedef_::Target2##_type \
- >::ret
-
-# define stc_find_deduce_vtype(Namespace, From, Target1, Target2) \
- typename Namespace::find_vtype< \
- typename Namespace::find_vtype< \
- From, \
- Namespace::typedef_::Target1##_type \
- >::ret, \
- Namespace::typedef_::Target2##_type \
- >::ret
-
-# define stc_deduce_deferred_vtype(Namespace, From, Target1, Target2) \
- stc_find_deduce_vtype(Namespace, From, Target1, Target2)
-
-# define stc_deduce_vtype_(Namespace, From, Target1, Target2) \
- Namespace::vtype< \
- Namespace::vtype< \
- From, \
- Namespace::typedef_::Target1##_type \
- >::ret, \
- Namespace::typedef_::Target2##_type \
- >::ret
-
-# define stc_deduce_vtype(Namespace, From, Target1, Target2) \
- typename Namespace::vtype< \
- typename Namespace::vtype< \
- From, \
- Namespace::typedef_::Target1##_type \
- >::ret, \
- Namespace::typedef_::Target2##_type \
- >::ret
+ /// get_impl
+ template < template <class> class abstraction, typename E >
+ struct get_impl : impl< abstraction, stc_find_type(E, behavior), E >
+ { /* depends upon behavior */ };
-#endif // ! STC_SCOOP_ALT_HH
+} // End of namespace automatic.
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add type of ''image restricted_to a subset''.
* tests/core/subset.cc: New.
* tests/core/Makefile.am: Update.
* oln/debug/println.hh: New.
* oln/core/internal/op_image_restricted_to_pset.hh: New.
* oln/debug/print.hh: Fix copyright.
* oln/core/concept/image.hh (bbox): Provide a final impl.
* oln/core/rle/rle_image.hh,
* oln/core/concept/image_identity.hh,
* oln/core/sparse/sparse_image.hh,
* oln/core/1d/image1d.hh
* oln/core/1d/image1d_b.hh
* oln/core/2d/image2d.hh
* oln/core/2d/image2d_b.hh: Update.
* oln/core/concept/neighborhood.hh (oln_decl_op_plus): Move to...
* oln/core/gen/neighb.hh: ...this file.
* oln/core/gen/op.hh (oln_decl_op_restricted_to, restricted_to):
New.
* oln/core/internal/point_set_base.hh (category): New.
* oln/core/internal/op_image_plus_nbh.hh: Add static assert.
* oln/core/internal/image_base.hh (include): Add
op_image_restricted_to_pset.hh.
oln/core/1d/image1d.hh | 9 -
oln/core/1d/image1d_b.hh | 8
oln/core/2d/image2d.hh | 9 -
oln/core/2d/image2d_b.hh | 8
oln/core/concept/image.hh | 9 -
oln/core/concept/image_identity.hh | 8
oln/core/concept/neighborhood.hh | 4
oln/core/gen/neighb.hh | 6
oln/core/gen/op.hh | 2
oln/core/internal/image_base.hh | 15 +
oln/core/internal/op_image_plus_nbh.hh | 5
oln/core/internal/op_image_restricted_to_pset.hh | 200 +++++++++++++++++++++++
oln/core/internal/point_set_base.hh | 2
oln/core/rle/rle_image.hh | 9 -
oln/core/sparse/sparse_image.hh | 8
oln/debug/print.hh | 2
oln/debug/println.hh | 61 +++++++
tests/core/Makefile.am | 2
tests/core/subset.cc | 43 ++++
19 files changed, 340 insertions(+), 70 deletions(-)
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 876)
+++ tests/core/Makefile.am (working copy)
@@ -26,6 +26,7 @@
image2d \
neighb2d \
npoints \
+ subset \
window2d \
at
@@ -36,6 +37,7 @@
image2d_SOURCES = image2d.cc
neighb2d_SOURCES = neighb2d.cc
npoints_SOURCES = npoints.cc
+subset_SOURCES = subset.cc
window2d_SOURCES = window2d.cc
# Methods.
Index: tests/core/subset.cc
--- tests/core/subset.cc (revision 0)
+++ tests/core/subset.cc (revision 0)
@@ -0,0 +1,43 @@
+// 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.
+
+#include <cassert>
+#include <oln/core/2d/image2d.hh>
+#include <oln/core/2d/neighb2d.hh>
+
+
+int main()
+{
+ using namespace oln;
+
+ image2d<int> ima(5, 5);
+
+ point2d p(1,1), q(3,3);
+ box2d b = init(from(p), to(q));
+
+ assert((ima | b).points().npoints() = 9); // FIXME: looks weird
+}
Index: oln/debug/println.hh
--- oln/debug/println.hh (revision 0)
+++ oln/debug/println.hh (revision 0)
@@ -0,0 +1,61 @@
+// 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_DEBUG_PRINTLN_HH
+# define OLN_DEBUG_PRINTLN_HH
+
+# include <oln/debug/print.hh>
+
+
+namespace oln
+{
+
+ namespace debug
+ {
+
+ template <typename I>
+ void println(const Image<I>& input, std::ostream& ostr = std::cout);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename I>
+ void println(const Image<I>& input, std::ostream& ostr)
+ {
+ print(exact(input), ostr);
+ ostr << std::endl;
+ }
+
+# endif // ! OLN_INCLUDE_ONLY
+
+
+ } // end of namespace oln::debug
+
+} // end of namespace oln
+
+
+#endif // ! OLN_DEBUG_PRINTLN_HH
Index: oln/debug/print.hh
--- oln/debug/print.hh (revision 876)
+++ oln/debug/print.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
Index: oln/core/rle/rle_image.hh
--- oln/core/rle/rle_image.hh (revision 876)
+++ oln/core/rle/rle_image.hh (working copy)
@@ -80,7 +80,6 @@
**
** method:
** pset impl_points() const : return image pset
- ** box impl_bbox() const : return image bbox
** bool impl_has(const point& p) const : rle_image has p?
** bool impl_owns_(const psite& p) const : same has impl_has
** void insert(const point& p, unsigned len, value val) : insert a new range on the image
@@ -105,7 +104,6 @@
rle_image();
pset impl_points() const;
- box impl_bbox() const;
bool impl_has(const point& p) const;
bool impl_owns_(const psite& p) const;
void insert(const point& p, unsigned len, value val);
@@ -130,13 +128,6 @@
}
template <typename P, typename T>
- typename rle_image<P, T>::box
- rle_image<P, T>::impl_bbox() const
- {
- return this->data_->first.bbox();
- }
-
- template <typename P, typename T>
bool
rle_image<P, T>::impl_has(const typename rle_image<P, T>::point& p) const
{
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 876)
+++ oln/core/concept/image.hh (working copy)
@@ -134,9 +134,11 @@
bool owns_(const psite& p) const;
rvalue operator()(const psite& p) const;
- box bbox() const;
pset points() const;
+ // With final impl:
+ box bbox() const;
+
protected:
Image();
};
@@ -357,7 +359,7 @@
typename Image<Exact>::box
Image<Exact>::bbox() const
{
- return exact(this)->impl_bbox();
+ return this->points().bbox(); // Final impl.
}
template <typename Exact>
@@ -551,8 +553,7 @@
{
}
-# endif
-
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/concept/neighborhood.hh
--- oln/core/concept/neighborhood.hh (revision 876)
+++ oln/core/concept/neighborhood.hh (working copy)
@@ -29,8 +29,6 @@
# define OLN_CORE_CONCEPT_NEIGHBORHOOD_HH
# include <oln/core/equipment.hh>
-# include <oln/core/internal/op_image_plus_nbh.hh>
-
@@ -52,8 +50,6 @@
}; // end of oln::Neighborhood<Exact>
- oln_decl_op_plus(Image, Neighborhood);
-
# ifndef OLN_INCLUDE_ONLY
Index: oln/core/concept/image_identity.hh
--- oln/core/concept/image_identity.hh (revision 876)
+++ oln/core/concept/image_identity.hh (working copy)
@@ -54,7 +54,6 @@
bool impl_owns_(const psite& p) const;
rvalue impl_read(const psite& p) const;
- box impl_bbox() const;
pset impl_points() const;
};
@@ -193,13 +192,6 @@
}
template <typename Exact>
- typename set_impl< Image, behavior::identity, Exact >::box
- set_impl< Image, behavior::identity, Exact >::impl_bbox() const
- {
- return exact(this)->image().bbox();
- }
-
- template <typename Exact>
typename set_impl< Image, behavior::identity, Exact >::pset
set_impl< Image, behavior::identity, Exact >::impl_points() const
{
Index: oln/core/sparse/sparse_image.hh
--- oln/core/sparse/sparse_image.hh (revision 876)
+++ oln/core/sparse/sparse_image.hh (working copy)
@@ -83,7 +83,6 @@
sparse_image();
pset impl_points() const;
- box impl_bbox() const;
bool impl_has(const point& p) const;
bool impl_owns_(const psite& p) const;
void insert(const point& p, unsigned len, const std::vector<value>& val);
@@ -109,13 +108,6 @@
}
template <typename P, typename T>
- typename sparse_image<P, T>::box
- sparse_image<P, T>::impl_bbox() const
- {
- return this->data_->first.bbox();
- }
-
- template <typename P, typename T>
bool
sparse_image<P, T>::impl_has(const typename sparse_image<P, T>::point& p) const
{
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 876)
+++ oln/core/1d/image1d.hh (working copy)
@@ -97,7 +97,6 @@
std::size_t impl_npoints() const;
- box1d impl_bbox() const;
box1d impl_points() const;
};
@@ -176,19 +175,13 @@
}
template <typename T>
- box1d image1d<T>::impl_bbox() const
+ box1d image1d<T>::impl_points() const
{
assert(this->has_data());
box1d b(this->data_->imin(), this->data_->imax());
return b;
}
- template <typename T>
- box1d image1d<T>::impl_points() const
- {
- return this->bbox();
- }
-
# endif
Index: oln/core/1d/image1d_b.hh
--- oln/core/1d/image1d_b.hh (revision 876)
+++ oln/core/1d/image1d_b.hh (working copy)
@@ -105,7 +105,6 @@
std::size_t impl_npoints() const;
- box1d impl_bbox() const;
box1d impl_points() const;
unsigned border() const;
@@ -184,13 +183,6 @@
}
template <typename T>
- box1d image1d_b<T>::impl_bbox() const
- {
- assert(this->has_data());
- return this->data_->third;
- }
-
- template <typename T>
box1d image1d_b<T>::impl_points() const
{
assert(this->has_data());
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 876)
+++ oln/core/2d/image2d.hh (working copy)
@@ -100,7 +100,6 @@
std::size_t impl_npoints() const;
- box2d impl_bbox() const;
box2d impl_points() const;
};
@@ -203,7 +202,7 @@
}
template <typename T>
- box2d image2d<T>::impl_bbox() const
+ box2d image2d<T>::impl_points() const
{
assert(this->has_data());
point2d
@@ -213,12 +212,6 @@
return b;
}
- template <typename T>
- box2d image2d<T>::impl_points() const
- {
- return this->bbox();
- }
-
template <typename T, typename D>
bool init_(image2d<T>* this_, const D& dat)
{
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 876)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -146,7 +146,6 @@
std::size_t impl_npoints() const;
- box2d impl_bbox() const;
box2d impl_points() const;
unsigned border() const;
@@ -244,13 +243,6 @@
}
template <typename T>
- box2d image2d_b<T>::impl_bbox() const
- {
- assert(this->has_data());
- return this->data_->box;
- }
-
- template <typename T>
box2d image2d_b<T>::impl_points() const
{
assert(this->has_data());
Index: oln/core/gen/neighb.hh
--- oln/core/gen/neighb.hh (revision 876)
+++ oln/core/gen/neighb.hh (working copy)
@@ -31,12 +31,18 @@
# include <oln/core/internal/dpoints_impl.hh>
# include <oln/core/internal/neighborhood_base.hh>
+# include <oln/core/internal/op_image_plus_nbh.hh>
namespace oln
{
+ // Op.
+ oln_decl_op_plus(Image, Neighborhood);
+
+
+
// Fwd decl.
template <typename Dp> class neighb_;
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 876)
+++ oln/core/gen/op.hh (working copy)
@@ -73,6 +73,7 @@
# define oln_decl_op_plus(Lconcept, Rconcept) oln_decl_op_(plus, Lconcept, +, Rconcept)
# define oln_decl_op_such_as(Lconcept, Rconcept) oln_decl_op_(such_as, Lconcept, |, Rconcept)
+# define oln_decl_op_restricted_to(Lconcept, Rconcept) oln_decl_op_( restricted_to, Lconcept, |, Rconcept)
// ...
@@ -104,6 +105,7 @@
struct plus;
struct such_as;
+ struct restricted_to;
/// \}
Index: oln/core/internal/point_set_base.hh
--- oln/core/internal/point_set_base.hh (revision 876)
+++ oln/core/internal/point_set_base.hh (working copy)
@@ -58,6 +58,8 @@
typedef stc_deferred(point) point__;
typedef stc_deferred(fwd_piter) fwd_piter__;
+ typedef stc::final< stc::is<Point_Set> > category;
+
typedef stc::final< box_<point__> > box;
typedef stc::final<stc_type(point__, grid)> grid;
typedef stc::final<fwd_piter__> piter;
Index: oln/core/internal/op_image_restricted_to_pset.hh
--- oln/core/internal/op_image_restricted_to_pset.hh (revision 0)
+++ oln/core/internal/op_image_restricted_to_pset.hh (revision 0)
@@ -0,0 +1,200 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_OP_IMAGE_RESTRICTED_TO_PSET_HH
+# define OLN_CORE_INTERNAL_OP_IMAGE_RESTRICTED_TO_PSET_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/concept/point_set.hh>
+# include <oln/core/gen/op.hh>
+
+
+namespace oln
+{
+
+# define current \
+ special_op_< stc::is<Image>, I, restricted_to, stc::is<Point_Set>, S >
+
+
+// /// Fwd decls.
+// template <typename Exact> struct Image;
+// template <typename Exact> struct Point_Set;
+
+
+ /// Super type.
+ template <typename I, typename S>
+ struct super_trait_< internal::current >
+ {
+ typedef internal::image_extension_< op_<I, restricted_to, S> > ret;
+ };
+
+
+ /// Virtual types.
+ template <typename I, typename S>
+ struct vtypes< internal::current >
+ {
+ typedef op_<I, restricted_to, S> Exact;
+ typedef stc_type(I, point) point__;
+
+ typedef I delegatee;
+ typedef internal::pair<I,S> data;
+
+ typedef S pset;
+
+ typedef op_<oln_plain(I), restricted_to, S> plain;
+ typedef op_<pl::rec<I>, restricted_to, S> skeleton;
+ };
+
+
+ namespace internal
+ {
+
+ /// Implementation class the result of "Image I | Point_Set S".
+
+ template <typename I, typename S>
+ class special_op_< stc::is<Image>, I, restricted_to, stc::is<Point_Set>, S >
+ :
+ public internal::image_extension_< op_<I, restricted_to, S> >
+ {
+ typedef internal::image_extension_< op_<I, restricted_to, S> > super;
+ public:
+ stc_using(pset);
+ stc_using(box);
+ stc_using(data);
+ stc_using(delegatee);
+
+ delegatee& impl_image();
+ const delegatee& impl_image() const;
+
+ pset impl_points() const;
+
+ protected:
+ special_op_();
+ special_op_(I& ima, S& subset);
+ };
+
+ } // end of namespace oln::internal
+
+
+ // init
+
+ template <typename I, typename S, typename D>
+ bool init_(internal::current* target, const D& dat);
+
+ template <typename S, typename I>
+ bool init(Point_Set<S>& target,
+ with_t,
+ const internal::current& dat);
+
+ template <typename I, typename S>
+ bool init(Image<I>& target,
+ with_t,
+ const internal::current& dat);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ namespace internal
+ {
+
+ template <typename I, typename S>
+ current::special_op_()
+ {
+ }
+
+ template <typename I, typename S>
+ current::special_op_(I& ima, S& subset)
+ {
+ this->data_ = new data(ima, subset);
+ }
+
+ template <typename I, typename S>
+ typename current::delegatee&
+ current::impl_image()
+ {
+ assert(this->has_data());
+ return this->data_->first;
+ }
+
+ template <typename I, typename S>
+ const typename current::delegatee&
+ current::impl_image() const
+ {
+ assert(this->has_data());
+ return this->data_->first;
+ }
+
+ template <typename I, typename S>
+ typename current::pset
+ current::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->second;
+ }
+
+ } // end of namespace oln::internal
+
+
+ // init
+
+ template <typename I, typename S, typename D>
+ bool init_(internal::current* this_, const D& dat)
+ {
+ precondition(not this_->has_data());
+ this_->data__() = new typename op_<I, restricted_to, S>::data;
+ bool image_ok = init(this_->data__()->first, with, dat);
+ bool subset_ok = init(this_->data__()->second, with, dat);
+ postcondition(image_ok);
+ postcondition(subset_ok);
+ return image_ok and subset_ok;
+ }
+
+ template <typename S, typename I>
+ bool init_(Point_Set<S>* this_,
+ const internal::current& data)
+ {
+ *this_ = data.points();
+ return true;
+ }
+
+ template <typename I, typename S>
+ bool init(Image<I>* this_,
+ const internal::current& data)
+ {
+ *this_ = data.image();
+ return true;
+ }
+
+# endif // OLN_INCLUDE_ONLY
+
+# undef current
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_OP_IMAGE_RESTRICTED_TO_PSET_HH
Index: oln/core/internal/op_image_plus_nbh.hh
--- oln/core/internal/op_image_plus_nbh.hh (revision 876)
+++ oln/core/internal/op_image_plus_nbh.hh (working copy)
@@ -84,7 +84,8 @@
template <typename I, typename N>
class special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
:
- public internal::image_extension_< op_<I, plus, N> >
+ public internal::image_extension_< op_<I, plus, N> >,
+ private mlc::assert_< mlc_is_not_a(I, Image_with_Nbh) > // FIXME: Add err msg.
{
typedef internal::image_extension_< op_<I, plus, N> > super;
public:
@@ -167,8 +168,6 @@
// init
- // FIXME: N is nbh?
-
template <typename I, typename N, typename D>
bool init_(internal::current* this_, const D& dat)
{
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 876)
+++ oln/core/internal/image_base.hh (working copy)
@@ -461,8 +461,21 @@
} // end of namespace oln
-// FIXME: Bad!
+
+
+/// \{
+/// FIXME: Bad!
+
# include <oln/core/internal/f_ch_value.hh>
+# include <oln/core/internal/op_image_restricted_to_pset.hh>
+
+namespace oln
+{
+ oln_decl_op_restricted_to(Image, Point_Set);
+
+} // end of namespace oln
+
+/// \}
1
0
15 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add external initialization through ''init(target, with, data)''.
* oln/core/internal/utils.hh (value1, value2, value3, value4):
Rename as...
(first, second, third, fourth): ...these.
* oln/core/init.hh (init): New version.
(with_t, with, init_): New.
* oln/core/1d/image1d.hh (plain, skeleton): New.
* oln/core/1d/image1d_b.hh: Likewise and update.
* oln/core/2d/neighb2d.hh (OLN_ENABLE_DEFAULT): New.
(init_): New.
* oln/core/2d/array2d.hh: Add FIXMEs.
* oln/core/2d/image2d.hh (init_): New.
* oln/core/2d/image2d_b.hh: Likewise.
* oln/core/2d/box2d.hh (init__): Change sig.
* oln/core/2d/point2d.hh (init__): Replace by...
(point2d): ...this new ctor.
* oln/core/gen/box.hh: Likewise.
* oln/core/equipment.hh (include): Add init.hh.
* oln/core/gen/op.hh (op_): New ctor.
* oln/core/gen/single_value_image.hh: Update.
* oln/core/concept/point_set.hh (box): New instant value.
* oln/core/concept/grid.hh (include): Remove.
* oln/core/concept/point.hh (include): Add grid.hh.
(point): New instant value.
* oln/core/concept/value.hh: Fix.
* oln/core/internal/initializer.hh (operator*): Rename as...
(value): ...this.
(init__): Secure.
* oln/core/internal/op_image_plus_nbh.hh (current): Move.
(init_): New.
Update.
* oln/core/internal/instant_value.hh (oln_decl_instant_value):
Move type definitions into internal.
(operator M<W>): Add FIXME.
* oln/core/internal/image_base.hh (ima): New instant value.
(data__): New method.
(init_): New.
1d/image1d.hh | 3 +
1d/image1d_b.hh | 21 +++++-----
2d/array2d.hh | 2
2d/box2d.hh | 47 ++++++++++++-----------
2d/image2d.hh | 14 ++++++
2d/image2d_b.hh | 14 ++++++
2d/neighb2d.hh | 23 ++++++++++-
2d/point2d.hh | 37 ++++--------------
concept/grid.hh | 1
concept/point.hh | 3 +
concept/point_set.hh | 6 ++
concept/value.hh | 3 -
equipment.hh | 2
gen/box.hh | 44 +++++++--------------
gen/op.hh | 10 ++++
gen/single_value_image.hh | 10 ++--
init.hh | 85 ++++++++++++++++++++++++++++++++++++++++++
internal/image_base.hh | 47 ++++++++++++++++++++++-
internal/initializer.hh | 59 +++++++++++++++++++++--------
internal/instant_value.hh | 22 ++++++++--
internal/op_image_plus_nbh.hh | 78 ++++++++++++++++++++++++++++++++++----
internal/utils.hh | 46 +++++++++++-----------
22 files changed, 428 insertions(+), 149 deletions(-)
Index: oln/core/concept/point_set.hh
--- oln/core/concept/point_set.hh (revision 875)
+++ oln/core/concept/point_set.hh (working copy)
@@ -28,13 +28,17 @@
#ifndef OLN_CORE_CONCEPT_POINT_SET_HH
# define OLN_CORE_CONCEPT_POINT_SET_HH
-# include <ostream>
+# include <iostream>
# include <oln/core/concept/point.hh>
+# include <oln/core/concept/iterator.hh> // for "for_all"
namespace oln
{
+ /// Instant value.
+ oln_decl_instant_value(box);
+
/// Concept-class "Point_Set".
Index: oln/core/concept/grid.hh
--- oln/core/concept/grid.hh (revision 875)
+++ oln/core/concept/grid.hh (working copy)
@@ -30,7 +30,6 @@
# define OLN_CORE_CONCEPT_GRID_HH
# include <oln/core/equipment.hh>
-# include <oln/core/internal/instant_value.hh>
namespace oln
Index: oln/core/concept/point.hh
--- oln/core/concept/point.hh (revision 875)
+++ oln/core/concept/point.hh (working copy)
@@ -30,12 +30,15 @@
# define OLN_CORE_CONCEPT_POINT_HH
# include <mlc/value.hh>
+# include <oln/core/concept/grid.hh>
# include <oln/core/concept/operators.hh>
namespace oln
{
+ /// Instant value.
+ oln_decl_instant_value(point);
/// Concept-class "Point".
Index: oln/core/concept/value.hh
--- oln/core/concept/value.hh (revision 875)
+++ oln/core/concept/value.hh (working copy)
@@ -47,7 +47,8 @@
# ifndef OLN_INCLUDE_ONLY
- Value::Value()
+ template <typename Exact>
+ Value<Exact>::Value()
{
}
Index: oln/core/init.hh
--- oln/core/init.hh (revision 875)
+++ oln/core/init.hh (working copy)
@@ -38,6 +38,11 @@
{
+ template <typename D>
+ internal::initializer_<D>
+ init(const D& d);
+
+
template <template<class> class M, typename V>
internal::initializer_< internal::singleton< M<V> > >
init(const internal::instant_value_<M,V>& v);
@@ -61,9 +66,49 @@
// ...
+ const struct with_t {} with = with_t();
+
+
+ /*
+ *
+ * // To be specialized.
+ * template <typename This_, typename Data>
+ * bool init_(This_* this_, const Data& data); // FIXME: give code? err?
+ *
+ */
+
+
+ // The init versions below calls the above init_ routine.
+ // FIXME: Add oln::Any<*> to signature?
+
+
+ // Regular version.
+ template <typename Target, typename Data>
+ bool init(Target& target, with_t, const Data& data);
+
+ // Assignment.
+ template <typename T>
+ bool init(T& target, with_t, const T& data);
+
+ // Unconst data version.
+ template <typename Target, typename Data>
+ bool init(Target& target, with_t, Data& data);
+
+ // Guard: we cannot have "const Target".
+ template <typename Target, typename Data>
+ bool init(const Target& target, with_t, const Data& data);
+
+
# ifndef OLN_INCLUDE_ONLY
+ template <typename D>
+ internal::initializer_<D>
+ init(const D& d)
+ {
+ return d;
+ }
+
template <template<class> class M, typename V>
internal::initializer_< internal::singleton< M<V> > >
init(const internal::instant_value_<M,V>& v)
@@ -96,6 +141,46 @@
// ...
+
+
+ // Regular version.
+ template <typename Target, typename Data>
+ bool init(Target& target, with_t, const Data& data)
+ {
+ return init_(&target, data);
+ }
+
+ // Assignment.
+ template <typename T>
+ bool init(T& target, with_t, const T& data)
+ {
+ target = data;
+ return true;
+ }
+
+ // Unconst data version.
+ template <typename Target, typename Data>
+ bool init(Target& target, with_t, Data& data)
+ {
+ return init_(&target, const_cast<const Data&>(data));
+ }
+
+
+ namespace ERROR
+ {
+ template <typename T>
+ struct initialization_of_temporary_or_const_object_;
+ }
+
+ // Guard: we cannot have "const Target".
+ template <typename Target, typename Data>
+ bool init(const Target&, with_t, const Data&)
+ {
+ mlc::abort_< Target, ERROR::initialization_of_temporary_or_const_object_<Target> >::check();
+ return false;
+ }
+
+
# endif // OLN_INCLUDE_ONLY
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 875)
+++ oln/core/1d/image1d.hh (working copy)
@@ -56,6 +56,9 @@
typedef box1d pset;
typedef array1d_<value, coord> data;
+
+ typedef image1d<T> plain;
+ typedef image1d<pl::value> skeleton;
};
Index: oln/core/1d/image1d_b.hh
--- oln/core/1d/image1d_b.hh (revision 875)
+++ oln/core/1d/image1d_b.hh (working copy)
@@ -63,6 +63,9 @@
typedef internal::triplet< array1d_<T, int>,
unsigned,
box_<point1d> > data;
+
+ typedef image1d_b<T> plain;
+ typedef image1d_b<pl::value> skeleton;
};
@@ -140,21 +143,21 @@
bool image1d_b<T>::impl_owns_(const point1d& p) const
{
assert(this->has_data());
- return this->data_->value1.has(p.ind());
+ return this->data_->first.has(p.ind());
}
template <typename T>
bool image1d_b<T>::impl_has(const point1d& p) const
{
assert(this->has_data());
- return this->data_->value3.has(p);
+ return this->data_->third.has(p);
}
template <typename T>
const T& image1d_b<T>::impl_read(const point1d& p) const
{
assert(this->has_data());
- return this->data_->value1(p.ind());
+ return this->data_->first(p.ind());
}
template <typename T>
@@ -162,14 +165,14 @@
{
assert(this->has_data());
assert(i < this->npoints());
- return this->data_->value1[i];
+ return this->data_->first[i];
}
template <typename T>
T& image1d_b<T>::impl_read_write(const point1d& p)
{
assert(this->has_data());
- return this->data_->value1(p.ind());
+ return this->data_->first(p.ind());
}
template <typename T>
@@ -177,28 +180,28 @@
{
assert(this->has_data());
assert(i < this->npoints());
- return this->data_->value1[i];
+ return this->data_->first[i];
}
template <typename T>
box1d image1d_b<T>::impl_bbox() const
{
assert(this->has_data());
- return this->data_->value3;
+ return this->data_->third;
}
template <typename T>
box1d image1d_b<T>::impl_points() const
{
assert(this->has_data());
- return this->data_->value3;
+ return this->data_->third;
}
template <typename T>
unsigned image1d_b<T>::border() const
{
assert(this->has_data());
- return this->data_->value2;
+ return this->data_->second;
}
# endif
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 875)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -40,6 +40,15 @@
typedef neighb_<dpoint2d> neighb2d;
+# ifdef OLN_ENABLE_DEFAULT
+
+ // Default is c4.
+ template <typename D>
+ bool init_(neighb2d* this_, const D&);
+
+# endif // OLN_ENABLE_DEFAULT
+
+
namespace internal
{
@@ -100,12 +109,24 @@
# ifndef OLN_INCLUDE_ONLY
+# ifdef OLN_ENABLE_DEFAULT
+
+ /// Default is c4.
+ template <typename D>
+ bool init_(neighb2d* this_, const D&)
+ {
+ *this_ = c4;
+ return true;
+ }
+
+# endif // OLN_ENABLE_DEFAULT
+
const neighb2d c4 = internal::mk_c4();
const neighb2d c8 = internal::mk_c8();
const neighb2d c2r = internal::mk_c2_row();
const neighb2d c2c = internal::mk_c2_col();
-# endif
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/2d/array2d.hh
--- oln/core/2d/array2d.hh (revision 875)
+++ oln/core/2d/array2d.hh (working copy)
@@ -99,6 +99,7 @@
precondition(imax >= imin and jmax >= jmin);
ilen_ = imax - imin + 1;
jlen_ = jmax - jmin + 1;
+ // FIXME: Test that ilen_ and jlen_ are not huge!
allocate_();
}
@@ -110,6 +111,7 @@
jlen_(jlen)
{
precondition(ilen > 0 and jlen > 0);
+ // FIXME: Test that ilen_ and jlen_ are not huge!
imax_ = imin_ + ilen_;
jmax_ = jmin_ + ilen_;
allocate_();
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 875)
+++ oln/core/2d/image2d.hh (working copy)
@@ -104,6 +104,8 @@
box2d impl_points() const;
};
+ template <typename T, typename D>
+ bool init_(image2d<T>* this_, const D& dat);
# ifndef OLN_INCLUDE_ONLY
@@ -217,6 +219,18 @@
return this->bbox();
}
+ template <typename T, typename D>
+ bool init_(image2d<T>* this_, const D& dat)
+ {
+ precondition(not this_->has_data());
+ box2d b;
+ bool box_ok = init(b, with, dat);
+ postcondition(box_ok);
+ this_->data__() = new typename image2d<T>::data(b.pmin().row(), b.pmin().col(),
+ b.pmax().row(), b.pmax().col());
+ return box_ok;
+ }
+
# endif
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 875)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -152,6 +152,8 @@
unsigned border() const;
};
+ template <typename T, typename D>
+ bool init_(image2d_b<T>* this_, const D& dat);
# ifndef OLN_INCLUDE_ONLY
@@ -262,6 +264,18 @@
return this->data_->border;
}
+ template <typename T, typename D>
+ bool init_(image2d_b<T>* this_, const D& dat)
+ {
+ precondition(not this_->has_data());
+ box2d b;
+ bool box_ok = init(b, with, dat);
+ postcondition(box_ok);
+ unsigned border = 2; // FIXME: Use init!
+ this_->data__() = new typename image2d_b<T>::data(b.pmin(), b.pmax(), border);
+ return box_ok;
+ }
+
# endif
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 875)
+++ oln/core/2d/box2d.hh (working copy)
@@ -28,6 +28,7 @@
#ifndef OLN_CORE_2D_BOX2D_HH
# define OLN_CORE_2D_BOX2D_HH
+# include <oln/core/concept/point_set.hh> // for internal::tag::box_t
# include <oln/core/2d/point2d.hh>
@@ -46,13 +47,13 @@
namespace internal
{
- template <typename C>
- void init__(box2d& b,
- const initializer_< pair< nrows_t<C>, ncols_t<C> > >& data);
-
- template <typename C>
- void init__(box2d& b,
- const initializer_< triplet< from_t<point2d>, nrows_t<C>, ncols_t<C> > >& data);
+ template <typename U>
+ bool init__(tag::box_t, box2d& b,
+ const pair< nrows_t<U>, ncols_t<U> >& data);
+
+ template <typename U>
+ bool init__(tag::box_t, box2d& b,
+ const triplet< from_t<point2d>, nrows_t<U>, ncols_t<U> >& data);
} // end of namespace oln::internal
@@ -70,29 +71,31 @@
namespace internal
{
- template <typename C>
- void init__(box2d& b,
- const initializer_< pair< nrows_t<C>, ncols_t<C> > >& data)
- {
- C nrows = data->value1.value;
- C ncols = data->value2.value;
- precondition(nrows > 0 and ncols > 0);
+ template <typename U>
+ bool init__(tag::box_t, box2d& b,
+ const pair< nrows_t<U>, ncols_t<U> >& data)
+ {
+ unsigned nrows = data.first.value;
+ unsigned ncols = data.second.value;
+ precondition(nrows != 0 and ncols != 0);
b.pmin().row() = 0;
b.pmin().col() = 0;
b.pmax().row() = nrows - 1;
b.pmax().col() = ncols - 1;
+ return true;
}
- template <typename C>
- void init__(box2d& b,
- const initializer_< triplet< from_t<point2d>, nrows_t<C>, ncols_t<C> > >& data)
- {
- C nrows = data->value2.value;
- C ncols = data->value3.value;
- precondition(nrows > 0 and ncols > 0);
- b.pmin() = data->value1.value;
+ template <typename U>
+ bool init__(tag::box_t, box2d& b,
+ const triplet< from_t<point2d>, nrows_t<U>, ncols_t<U> >& data)
+ {
+ unsigned nrows = data.second.value;
+ unsigned ncols = data.third.value;
+ precondition(nrows != 0 and ncols != 0);
+ b.pmin() = data.first.value;
b.pmax().row() = b.pmin().row() + nrows - 1;
b.pmax().col() = b.pmin().col() + ncols - 1;
+ return true;
}
} // end of namespace oln::internal
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 875)
+++ oln/core/2d/point2d.hh (working copy)
@@ -31,7 +31,6 @@
# include <oln/core/2d/grid2d.hh>
# include <oln/core/internal/point2d.hh>
-# include <oln/core/init.hh>
namespace oln
@@ -60,25 +59,18 @@
};
- /// init__
- namespace internal
- {
- template <typename C>
- void init__(point2d& p,
- const initializer_< pair< row_t<C>, col_t<C> > >& data);
- }
-
-
/// Usual 2D point class.
class point2d : public internal::point2d_< point2d >
{
+ typedef internal::initializer_<
+ internal::pair< internal::row_t<int>, internal::col_t<int> >
+ > row_col_t;
public:
/// Ctors.
point2d();
- point2d(int row, int col);
- template <typename D>
- point2d(const internal::initializer_<D>& data);
+ point2d(int row, int col); // FIXME: Remove!
+ point2d(const row_col_t& dat);
};
@@ -89,27 +81,16 @@
{
}
- point2d::point2d(int row, int col)
+ point2d::point2d(int row, int col) // FIXME: Remove!
{
this->row() = row;
this->col() = col;
}
- template <typename D>
- point2d::point2d(const internal::initializer_<D>& data)
+ point2d::point2d(const point2d::row_col_t& dat)
{
- internal::init__(*this, data);
- }
-
- namespace internal
- {
- template <typename C>
- void init__(point2d& p,
- const initializer_< pair< row_t<C>, col_t<C> > >& data)
- {
- p.row() = data->value1.value; // FIXME: first
- p.col() = data->value2.value; // FIXME: second
- }
+ this->row() = dat->first.value;
+ this->col() = dat->second.value;
}
# endif
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 875)
+++ oln/core/equipment.hh (working copy)
@@ -30,7 +30,7 @@
# include <mlc/contract.hh>
# include <oln/stc/scoop.hh> // FIXME: Remove "oln/" later.
-
+# include <oln/core/init.hh>
# define oln_typename_shortcut__(Type, Alias) typename Type::Alias
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 875)
+++ oln/core/gen/box.hh (working copy)
@@ -32,7 +32,6 @@
# include <oln/core/concept/point.hh>
# include <oln/core/concept/iterator_on_points.hh>
# include <oln/core/internal/point_set_base.hh>
-# include <oln/core/init.hh>
namespace oln
@@ -64,15 +63,6 @@
};
- /// init__
- namespace internal
- {
- template <typename P>
- void init__(box_<P>& b,
- const initializer_< pair< from_t<P>, to_t<P> > >& data);
- }
-
-
/// Generic box class based on a point class.
template <typename P>
@@ -81,6 +71,11 @@
{
typedef box_<P> current;
typedef internal::point_set_base_<current> super;
+
+ typedef internal::initializer_<
+ internal::pair< internal::from_t<P>, internal::to_t<P> >
+ > from_to_t;
+
public:
stc_using(point);
@@ -94,6 +89,8 @@
box_();
box_(const P& pmin, const P& pmax);
+ box_(const from_to_t& data);
+
template <typename D>
box_(const internal::initializer_<D>& data);
@@ -227,10 +224,18 @@
}
template <typename P>
+ box_<P>::box_(const typename box_<P>::from_to_t& dat)
+ {
+ this->pmin_ = dat->first.value;
+ this->pmax_ = dat->second.value;
+ }
+
+ template <typename P>
template <typename D>
box_<P>::box_(const internal::initializer_<D>& data)
{
- internal::init__(*this, data);
+ bool box_ok = internal::init__(internal::tag::box_t(), *this, data.value());
+ postcondition(box_ok);
}
template <typename P>
@@ -293,23 +298,6 @@
}
- // -------------------- init__
-
-
- namespace internal
- {
-
- template <typename P>
- void init__(box_<P>& b,
- const initializer_< pair< from_t<P>, to_t<P> > >& data)
- {
- b.pmin() = data->value1.value;
- b.pmax() = data->value2.value;
- }
-
- }
-
-
// -------------------- box_fwd_piter_<P>
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 875)
+++ oln/core/gen/op.hh (working copy)
@@ -140,6 +140,8 @@
public:
op_();
op_(L& l, R& r);
+ template <typename D>
+ op_(const internal::initializer_<D>& data);
}; // end of op_<L, OpName, R>
@@ -158,6 +160,14 @@
{
}
+ template <typename L, typename OpName, typename R>
+ template <typename D>
+ op_<L, OpName, R>::op_(const internal::initializer_<D>& data)
+ {
+ bool op_ok = this->super::init__(data);
+ postcondition(op_ok);
+ }
+
# endif
# undef super
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 875)
+++ oln/core/gen/single_value_image.hh (working copy)
@@ -120,7 +120,7 @@
single_value_image<Ps, T>::impl_owns_(const typename single_value_image<Ps, T>::point& p) const
{
assert(this->has_data());
- return this->data_->value1.has(p);
+ return this->data_->first.has(p);
}
template <typename Ps, typename T>
@@ -128,7 +128,7 @@
single_value_image<Ps, T>::impl_has(const typename single_value_image<Ps, T>::point& p) const
{
assert(this->has_data());
- return this->data_->value1.has(p);
+ return this->data_->first.has(p);
}
template <typename Ps, typename T>
@@ -136,7 +136,7 @@
single_value_image<Ps, T>::impl_read(const typename single_value_image<Ps, T>::point&) const
{
assert(this->has_data());
- return this->data_->value2;
+ return this->data_->second;
}
template <typename Ps, typename T>
@@ -144,7 +144,7 @@
single_value_image<Ps, T>::impl_points() const
{
assert(this->has_data());
- return this->data_->value1;
+ return this->data_->first;
}
template <typename Ps, typename T>
@@ -152,7 +152,7 @@
single_value_image<Ps, T>::change_value(const T& new_value)
{
assert(this->has_data());
- this->data_->value2 = new_value;
+ this->data_->second = new_value;
}
# endif // OLN_INCLUDE_ONLY
Index: oln/core/internal/initializer.hh
--- oln/core/internal/initializer.hh (revision 875)
+++ oln/core/internal/initializer.hh (working copy)
@@ -37,12 +37,24 @@
{
template <typename S>
- struct bad_initialization_of_
+ struct no_proper_initialization_found_for_
+ {
+ template <typename D>
+ struct with_data_being_;
+ };
+
+ template <typename S>
+ struct bad_initialization_call_for_
{
template <typename D>
struct with_;
};
+ template <typename S>
+ struct initialization_call_instead_of_assignment_
+ {
+ };
+
} // end of namespace oln::ERROR
@@ -55,19 +67,25 @@
struct initializer_
{
initializer_(const D& data);
- const D& operator*() const;
const D* operator->() const;
+ const D& value() const;
protected:
D data_;
};
+ // Decl: explicit error when not defined.
template <typename Tag, typename Subject, typename D>
- void init__(const Tag& t, Subject& s, const initializer_<D>& d);
+ bool init__(const Tag& t, Subject& s, const D& d);
- template <typename Subject, typename D>
- void init__(Subject& s, const initializer_<D>& d);
+ // Guard: init is not for assignment.
+ template <typename Tag, typename D>
+ bool init__(const Tag& t, D& subject, const D& data);
+
+ // Guard: explicit error cause wrong type of last arg.
+ template <typename Tag, typename Subject, typename D>
+ bool init__(const Tag& t, Subject& s, const initializer_<D>& d);
@@ -79,29 +97,40 @@
{}
template <typename D>
+ const D*
+ initializer_<D>::operator->() const
+ {
+ return &(this->data_);
+ }
+
+ template <typename D>
const D&
- initializer_<D>::operator*() const
+ initializer_<D>::value() const
{
return this->data_;
}
- template <typename D>
- const D*
- initializer_<D>::operator->() const
+ template <typename Tag, typename D>
+ bool init__(const Tag&, D& subject, const D& data)
{
- return &(this->data_);
+ mlc::abort_<Tag, typename ERROR::initialization_call_instead_of_assignment_<D> >::check();
+ return false;
}
template <typename Tag, typename Subject, typename D>
- void init__(const Tag&, Subject&, const initializer_<D>&)
+ bool init__(const Tag&, Subject&, const D&)
{
- mlc::abort_<D, typename ERROR::bad_initialization_of_<Subject>::template with_<D> >::check();
+ mlc::abort_<Tag, typename ERROR::no_proper_initialization_found_for_<Subject>
+ ::template with_data_being_<D> >::check();
+ return false;
}
- template <typename Subject, typename D>
- void init__(Subject&, const initializer_<D>&)
+ template <typename Tag, typename Subject, typename D>
+ bool init__(const Tag&, Subject& s, const initializer_<D>& d)
{
- mlc::abort_<D, typename ERROR::bad_initialization_of_<Subject>::template with_<D> >::check();
+ mlc::abort_<Tag, typename ERROR::bad_initialization_call_for_<Subject>
+ ::template with_<D> >::check();
+ return false;
}
# endif // OLN_INCLUDE_ONLY
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 875)
+++ oln/core/internal/utils.hh (working copy)
@@ -61,12 +61,12 @@
{
pair()
{}
- pair(T1 value1, T2 value2)
- : value1(value1),
- value2(value2)
+ pair(T1 first, T2 second)
+ : first(first),
+ second(second)
{}
- T1 value1;
- T2 value2;
+ T1 first;
+ T2 second;
};
@@ -77,14 +77,14 @@
{
triplet()
{}
- triplet(T1 value1, T2 value2, T3 value3)
- : value1(value1),
- value2(value2),
- value3(value3)
- {}
- T1 value1;
- T2 value2;
- T3 value3;
+ triplet(T1 first, T2 second, T3 third)
+ : first(first),
+ second(second),
+ third(third)
+ {}
+ T1 first;
+ T2 second;
+ T3 third;
};
@@ -95,16 +95,16 @@
{
quartet()
{}
- quartet(T1 value1, T2 value2, T3 value3, T4 value4)
- : value1(value1),
- value2(value2),
- value3(value3),
- value4(value4)
- {}
- T1 value1;
- T2 value2;
- T3 value3;
- T4 value4;
+ quartet(T1 first, T2 second, T3 third, T4 fourth)
+ : first(first),
+ second(second),
+ third(third),
+ fourth(fourth)
+ {}
+ T1 first;
+ T2 second;
+ T3 third;
+ T4 fourth;
};
Index: oln/core/internal/op_image_plus_nbh.hh
--- oln/core/internal/op_image_plus_nbh.hh (revision 875)
+++ oln/core/internal/op_image_plus_nbh.hh (working copy)
@@ -28,6 +28,7 @@
#ifndef OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
# define OLN_CORE_INTERNAL_OP_IMAGE_PLUS_NBH_HH
+# include <oln/core/concept/neighborhood.hh>
# include <oln/core/gen/op.hh>
# include <oln/core/gen/dpoints_piter.hh>
# include <oln/core/internal/image_base.hh>
@@ -36,6 +37,13 @@
namespace oln
{
+# define current \
+ special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
+
+ // Instant value.
+ oln_decl_instant_value(nbh);
+
+
/// Fwd decls.
template <typename Exact> struct Image;
template <typename Exact> struct Neighborhood;
@@ -43,7 +51,7 @@
/// Super type.
template <typename I, typename N>
- struct super_trait_< internal::special_op_<stc::is<Image>, I, plus, stc::is<Neighborhood>, N> >
+ struct super_trait_< internal::current >
{
typedef internal::image_extension_< op_<I, plus, N> > ret;
};
@@ -51,7 +59,7 @@
/// Virtual types.
template <typename I, typename N>
- struct vtypes< internal::special_op_<stc::is<Image>, I, plus, stc::is<Neighborhood>, N> >
+ struct vtypes< internal::current >
{
typedef op_<I, plus, N> Exact;
typedef stc_type(I, point) point__;
@@ -94,11 +102,30 @@
special_op_(I& ima, N& n);
};
+ } // end of namespace oln::internal
+
+
+ // init
+
+ template <typename I, typename N, typename D>
+ bool init_(internal::current* target, const D& dat);
+
+ template <typename N, typename I>
+ bool init(Neighborhood<N>& target,
+ with_t,
+ const internal::current& dat);
+
+ template <typename I, typename N>
+ bool init(Image<I>& target,
+ with_t,
+ const internal::current& dat);
+
+
# ifndef OLN_INCLUDE_ONLY
-# define current \
- special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
+ namespace internal
+ {
template <typename I, typename N>
current::special_op_()
@@ -116,7 +143,7 @@
current::impl_image()
{
assert(this->has_data());
- return this->data_->value1;
+ return this->data_->first;
}
template <typename I, typename N>
@@ -124,7 +151,7 @@
current::impl_image() const
{
assert(this->has_data());
- return this->data_->value1;
+ return this->data_->first;
}
template <typename I, typename N>
@@ -132,14 +159,47 @@
current::impl_nbhood() const
{
assert(this->has_data());
- return this->data_->value2;
+ return this->data_->second;
}
-# undef current
+ } // end of namespace oln::internal
+
+
+ // init
+
+ // FIXME: N is nbh?
+
+ template <typename I, typename N, typename D>
+ bool init_(internal::current* this_, const D& dat)
+ {
+ precondition(not this_->has_data());
+ this_->data__() = new typename op_<I, plus, N>::data;
+ bool ima_ok = init(this_->data__()->first, with, dat);
+ bool nbh_ok = init(this_->data__()->second, with, dat);
+ postcondition(ima_ok);
+ postcondition(nbh_ok);
+ return ima_ok and nbh_ok;
+ }
+
+ template <typename N, typename I>
+ bool init_(Neighborhood<N>* this_,
+ const internal::current& data)
+ {
+ *this_ = data.nbhood();
+ return true;
+ }
+
+ template <typename I, typename N>
+ bool init(Image<I>* this_,
+ const internal::current& data)
+ {
+ *this_ = data.image();
+ return true;
+ }
# endif // OLN_INCLUDE_ONLY
- } // end of namespace oln::internal
+# undef current
} // end of namespace oln
Index: oln/core/internal/instant_value.hh
--- oln/core/internal/instant_value.hh (revision 875)
+++ oln/core/internal/instant_value.hh (working copy)
@@ -31,16 +31,26 @@
# define oln_decl_instant_value(Name) \
\
+namespace internal \
+{ \
+ \
template <typename V> \
-struct Name##_t : public internal::instant_value_< Name##_t, V> \
+ struct Name##_t : public instant_value_< Name##_t, V> \
{ \
Name##_t(const V& v) { this->value = v; } \
}; \
\
+ namespace tag \
+ { \
+ struct Name##_t {}; \
+ } \
+ \
+} \
+ \
template <typename V> \
-Name##_t<V> Name(const V& v) \
+internal::Name##_t<V> Name(const V& v) \
{ \
- return Name##_t<V>(v); \
+ return internal::Name##_t<V>(v); \
} \
\
struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_u_m_n
@@ -61,8 +71,10 @@
V value;
/*
+ // FIXME: do not compile with g++-3!!!
+
template <typename W>
- operator M<W>() const; // FIXME: do not compile with g++-3!!!
+ operator M<W>() const;
*/
};
@@ -70,6 +82,8 @@
# ifndef OLN_INCLUDE_ONLY
/*
+ // FIXME: do not compile with g++-3!!!
+
template <template<class> class M, typename V>
template <typename W>
instant_value_<M,V>::operator M<W>() const
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 875)
+++ oln/core/internal/image_base.hh (working copy)
@@ -53,6 +53,11 @@
+ // Instant value.
+ oln_decl_instant_value(ima);
+
+
+
/// Fwd decls.
namespace internal
@@ -215,6 +220,9 @@
bool has_data() const;
+ // pseudo-private:
+ tracked_ptr<data>& data__();
+
protected:
image_base_();
@@ -323,6 +331,14 @@
{
}
+ template <typename Exact>
+ tracked_ptr<typename image_base_<Exact>::data>&
+ image_base_<Exact>::data__()
+ {
+ // there is no test here since it is OK even if data_ is unset
+ return this->data_;
+ }
+
/// primitive_image_<Exact>
template <typename Exact>
@@ -407,12 +423,41 @@
}
-# endif
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln::internal
+
+ // init
+
+
+ template <typename P, typename I>
+ bool init_(box_<P>* this_, const internal::image_base_<I>& data);
+
+ template <typename Target, typename I>
+ bool init_(Target* this_, const internal::single_image_morpher_<I>& data);
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename P, typename I>
+ bool init_(box_<P>* this_, const internal::image_base_<I>& data)
+ {
+ *this_ = data.bbox();
+ return true;
+ }
+
+ template <typename Target, typename I>
+ bool init_(Target* this_, const internal::single_image_morpher_<I>& data)
+ {
+ return init(*this_, with, data.image());
+ }
+
+# endif // OLN_INCLUDE_ONLY
+
+
} // end of namespace oln
1
0
Index: ChangeLog
from Nicolas Ballas <ballas(a)lrde.epita.fr>
New sparse_image class, not working yet.
* oln/core/sparse: New.
* oln/core/sparse/sparse_image.hh: New.
sparse_image.hh | 168 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 168 insertions(+)
Index: oln/core/sparse/sparse_image.hh
--- oln/core/sparse/sparse_image.hh (revision 0)
+++ oln/core/sparse/sparse_image.hh (revision 0)
@@ -0,0 +1,168 @@
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// 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 SPARSE_IMAGE_HH_
+# define SPARSE_IMAGE_HH_
+
+# include <vector>
+
+namespace oln
+{
+ // Fwd decl.
+ template <typename P, typename T>
+ struct sparse_image;
+
+ // Super type.
+ template <typename P, typename T>
+ struct super_trait_< sparse_image<P, T> >
+ {
+ typedef sparse_image<P, T> current;
+ typedef internal::primitive_image_<current> ret;
+ };
+
+ // Virtual types
+ template <typename P, typename T>
+ struct vtypes< sparse_image<P, T> >
+ {
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef P point;
+ typedef typename P::coord coord;
+
+ typedef rle_psite<P> psite;
+
+ typedef rle_pset<point> pset;
+
+ //FIXME:
+ typedef mlc::none plain;
+
+ typedef std::pair< pset, std::map<point, std::vector<value> > > data;
+ };
+
+ template < typename P, typename T>
+ class sparse_image : public internal::primitive_image_< sparse_image<P, T> >
+ {
+ typedef sparse_image<P, T> current;
+ typedef internal::primitive_image_< sparse_image<P, T> > super;
+ public:
+ stc_using(pset);
+ stc_using(box);
+ stc_using(point);
+ stc_using(value);
+ stc_using(rvalue);
+ stc_using(lvalue);
+ stc_using(psite);
+ stc_using(data);
+
+ sparse_image();
+
+ pset impl_points() const;
+ box impl_bbox() const;
+ bool impl_has(const point& p) const;
+ bool impl_owns_(const psite& p) const;
+ void insert(const point& p, unsigned len, const std::vector<value>& val);
+ rvalue impl_read(const psite& p) const;
+ lvalue impl_read_write(const psite& p);
+
+ };
+
+# ifndef OLN_INCLUDE_ONLY
+
+
+ template <typename P, typename T>
+ sparse_image<P, T>::sparse_image()
+ {
+ this->data_ = new data;
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::pset
+ sparse_image<P, T>::impl_points() const
+ {
+ return this->data_->first;
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::box
+ sparse_image<P, T>::impl_bbox() const
+ {
+ return this->data_->first.bbox();
+ }
+
+ template <typename P, typename T>
+ bool
+ sparse_image<P, T>::impl_has(const typename sparse_image<P, T>::point& p) const
+ {
+ return this->data_->first.has(p);
+ }
+
+ template <typename P, typename T>
+ bool
+ sparse_image<P, T>::impl_owns_(const typename sparse_image<P, T>::psite& p) const
+ {
+ return this->data_->first.has(p.start_);
+ }
+
+ template <typename P, typename T>
+ void
+ sparse_image<P, T>::insert(const point& p, unsigned len, const std::vector<typename sparse_image<P, T>::value>& val)
+ {
+ this->data_->first.insert(p, len);
+ this->data_->second[p] = val;
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::rvalue
+ sparse_image<P, T>::impl_read(const sparse_image<P, T>::psite& ps) const
+ {
+ typename std::map<point, value>::const_iterator irun;
+
+ irun = this->data_->second.find(ps.start_);
+ assert(irun != this->data_->second.end() && ps.index_ < this->data_->first.range_len_(ps.start_));
+ return irun->second[ps.index_];
+ }
+
+ template <typename P, typename T>
+ typename sparse_image<P, T>::lvalue
+ sparse_image<P, T>::impl_read_write(const sparse_image<P, T>::psite& ps)
+ {
+ typename std::map<point, value>::const_iterator irun;
+
+ irun = this->data_->second.find(ps.start_);
+ assert(irun != this->data_->second.end() && ps.index_ < this->data_->first.range_len_(ps.start_));
+ return irun->second[ps.index_];
+ }
+
+
+# endif /* !OLN_INCLUDE_ONLY */
+
+
+} // end of namespace oln
+
+#endif /* !SPARSE_IMAGE_HH_ */
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Remove dead code.
* oln/core/abstract/image/hybrid/classical.hh,
* oln/core/abstract/image/type/binary.hh,
* oln/core/abstract/image/type/data.hh,
* oln/core/abstract/image/type/grey_level.hh,
* oln/core/abstract/image/type/integre.hh,
* oln/core/abstract/image/type/color.hh,
* oln/core/abstract/image/type/hierarchy.hh,
* oln/core/abstract/image/type/label.hh,
* oln/core/abstract/image/mutability/hierarchy.hh,
* oln/core/abstract/image/hierarchies.hh,
* oln/core/abstract/image/computability/hierarchy.hh,
* oln/core/abstract/image/dimension/1d.hh,
* oln/core/abstract/image/dimension/2d.hh,
* oln/core/abstract/image/dimension/3d.hh,
* oln/core/abstract/image/dimension/hierarchy.hh,
* oln/core/abstract/image/all.hh,
* oln/core/abstract/image/neighborhood/hierarchy.hh,
* oln/core/abstract/image/point_wise_accessibility/hierarchy.hh,
* oln/core/abstract/image/bbox/hierarchy.hh,
* oln/core/abstract/image/value_wise_accessibility/hierarchy.hh,
* oln/core/abstract/fwd_decls.hh,
* oln/core/abstract/array.hh,
* oln/core/abstract/internal/image_impl.hh,
* oln/core/automatic/image/image.hh,
* oln/core/automatic/image/image1d.hh,
* oln/core/automatic/image/image2d.hh,
* oln/core/automatic/image/image3d.hh,
* oln/core/automatic/image/image_being_point_wise_random_accessible.hh,
* oln/core/automatic/image/image_being_value_wise_random_accessible.hh,
* oln/core/automatic/image/image_having_neighborhood.hh,
* oln/core/automatic/image/mutable_image.hh,
* oln/core/automatic/image/mutable_image1d.hh,
* oln/core/automatic/image/mutable_image2d.hh,
* oln/core/automatic/image/mutable_image3d.hh,
* oln/core/automatic/impl.hh,
* oln/core/automatic/topology/topology_being_random_accessible.hh,
* oln/core/automatic/topology/topology_having_bbox.hh,
* oln/core/automatic/topology/topology_having_neighborhood.hh,
* oln/core/automatic/topology/topology_having_subset.hh,
* oln/core/iterator_vtypes.hh,
* oln/core/spe/row.hh,
* oln/core/spe/col.hh,
* oln/core/spe/slice.hh,
* oln/core/type_fun/plain.hh,
* oln/core/type_fun/ch_value.hh,
* oln/core/type_fun/slice.hh: Remove files.
* oln/core/abstract/functions.hh: Rename as...
* oln/core/concept/functions.hh: ...this and update.
* oln/core/concept/image.hh: Add doc.
* oln/core/abstract/image/hybrid,
* oln/core/abstract/image/type,
* oln/core/abstract/image/mutability,
* oln/core/abstract/image/computability,
* oln/core/abstract/image/dimension,
* oln/core/abstract/image/neighborhood,
* oln/core/abstract/image/point_wise_accessibility,
* oln/core/abstract/image/bbox,
* oln/core/abstract/image/value_wise_accessibility,
* oln/core/abstract/image,
* oln/core/abstract/internal,
* oln/core/abstract,
* oln/core/automatic/image,
* oln/core/automatic/topology,
* oln/core/spe,
* oln/core/type_fun: Remove directories.
functions.hh | 96 ++++++++++++++++++++++++++++++++---------------------------
image.hh | 6 +++
2 files changed, 59 insertions(+), 43 deletions(-)
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 871)
+++ oln/core/concept/image.hh (working copy)
@@ -76,6 +76,12 @@
|
|
|
+ o -- + -- Plain_Image
+ | |
+ | + -- Computed_Image
+ |
+ |
+ |
o -- + -- Gray_Level_Image
| |
| + -- Color_Image
Index: oln/core/concept/functions.hh
--- oln/core/concept/functions.hh (revision 870)
+++ oln/core/concept/functions.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -25,18 +25,16 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
-#ifndef OLN_CORE_ABSTRACT_FUNCTIONS_HH
-# define OLN_CORE_ABSTRACT_FUNCTIONS_HH
+#ifndef OLN_CORE_CONCEPT_FUNCTIONS_HH
+# define OLN_CORE_CONCEPT_FUNCTIONS_HH
-# include <stc/any.hh>
-# include <oln/core/type.hh>
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/image/mutability/hierarchy.hh>
+# include <oln/core/equipment.hh>
namespace oln
{
+ /*
// Fwd decl.
namespace morpher {
@@ -45,109 +43,121 @@
}
namespace value { template <typename I, typename F> class two_way; }
+ */
- namespace abstract
+ template <typename Exact>
+ struct Function : public Any<Exact>
{
+ protected:
+ Function();
+ };
+
// Point -> Value.
- template <typename E>
- struct fun_p2v : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_p2v : public Function<Exact>
{
protected:
- fun_p2v();
+ Function_p2v();
};
// Value -> Value.
- template <typename E>
- struct fun_v2v : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_v2v : public Function<Exact>
{
protected:
- fun_v2v();
+ Function_v2v();
};
+ /*
+
// Value1 -> Value2 *and* Value2 -> Value1.
- template <typename E>
- struct fun_v2w2v : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_v2w2v : public Function<Exact>
{
public:
template <typename I>
- oln::morpher::two_way<I, E>
+ oln::morpher::two_way<I, Exact>
operator()(oln::abstract::mutable_image<I>& input) const;
protected:
- fun_v2w2v();
+ Function_v2w2v();
};
// (Image, Point) -> Value2 *and* (Image, Point, Value2) -> Value1.
- template <typename E>
- struct fun_rw : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_rw : public Function<Exact>
{
public:
template <typename I>
- oln::morpher::two_way_rw<I, E>
+ oln::morpher::two_way_rw<I, Exact>
operator()(oln::abstract::mutable_image<I>& input) const;
protected:
- fun_rw();
+ Function_rw();
};
+ */
+
// Point -> Point.
- template <typename E>
- struct fun_p2p : public virtual stc::any__simple<E>,
- public oln::type
+ template <typename Exact>
+ struct Function_p2p : public Function<Exact>
{
protected:
- fun_p2p();
+ Function_p2p();
};
# ifndef OLN_INCLUDE_ONLY
- template <typename E>
- fun_p2v<E>::fun_p2v()
+ template <typename Exact>
+ Function<Exact>::Function()
{
}
- template <typename E>
- fun_v2v<E>::fun_v2v()
+ template <typename Exact>
+ Function_p2v<Exact>::Function_p2v()
{
}
- template <typename E>
- fun_v2w2v<E>::fun_v2w2v()
+ template <typename Exact>
+ Function_v2v<Exact>::Function_v2v()
{
}
- template <typename E>
- fun_rw<E>::fun_rw()
+ /*
+
+ template <typename Exact>
+ Function_v2w2v<Exact>::Function_v2w2v()
{
}
- template <typename E>
- fun_p2p<E>::fun_p2p()
+ template <typename Exact>
+ Function_rw<Exact>::Function_rw()
{
}
-# endif
+ */
+
+ template <typename Exact>
+ Function_p2p<Exact>::Function_p2p()
+ {
+ }
- } // end of namespace oln::abstract
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
-#endif // ! OLN_CORE_ABSTRACT_FUNCTIONS_HH
+#endif // ! OLN_CORE_CONCEPT_FUNCTIONS_HH
1
0
870: Add oln_plain_value, update level::apply, and provide a sample test code.
by Thierry Geraud 13 Mar '07
by Thierry Geraud 13 Mar '07
13 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add oln_plain_value, update level::apply, and provide a sample test code.
* oln/core/internal/f_ch_value.hh (oln_plain_value): New.
* oln/core/internal/image_base.hh (include): Add f_ch_value.
* oln/level/apply.hh: Inactivate almost the whole code.
(apply): Update a single version.
* tests/core/apply.cc: New.
* tests/core/Makefile.am: Update.
oln/core/internal/f_ch_value.hh | 4
oln/core/internal/image_base.hh | 5 +
oln/level/apply.hh | 173 ++++++++++++++++++++--------------------
tests/core/Makefile.am | 4
tests/core/apply.cc | 46 ++++++++++
5 files changed, 146 insertions(+), 86 deletions(-)
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 869)
+++ tests/core/Makefile.am (working copy)
@@ -19,6 +19,7 @@
check_PROGRAMS = \
+ apply \
dpoint2d \
point2d \
grid \
@@ -41,5 +42,8 @@
# Methods.
at_SOURCES = at.cc
+# FIXME: Temp!
+apply_SOURCES = apply.cc
+
TESTS = $(check_PROGRAMS)
Index: tests/core/apply.cc
--- tests/core/apply.cc (revision 0)
+++ tests/core/apply.cc (revision 0)
@@ -0,0 +1,46 @@
+// 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.
+
+// FIXME: Move this file into tests/level/.
+
+#include <oln/core/2d/image2d.hh>
+#include <oln/level/apply.hh>
+
+namespace my
+{
+ bool negate(bool b)
+ {
+ return not b;
+ }
+}
+
+int main()
+{
+ using namespace oln;
+ image2d<bool> ima(3,3);
+ ima = level::apply(my::negate, ima);
+}
Index: oln/level/apply.hh
--- oln/level/apply.hh (revision 869)
+++ oln/level/apply.hh (working copy)
@@ -29,9 +29,7 @@
#ifndef OLN_LEVEL_APPLY_HH
# define OLN_LEVEL_APPLY_HH
-# include <oln/core/abstract/image.hh>
-# include <oln/core/abstract/iterator.hh>
-# include <oln/core/abstract/functions.hh>
+# include <oln/core/concept/image.hh>
namespace oln
@@ -41,22 +39,23 @@
{
/// Fwd decl.
- template <typename I, typename V>
- oln_plain_value(I, V)
- apply(const abstract::image<I>& input, V (*fun)(const oln_value(I)&));
-
- /// Fwd decl.
- template <typename I, typename F>
- oln_plain_value(I, typename F::result_value)
- apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun);
-
- /// Fwd decl.
- template <typename I, typename V>
- void apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&));
-
- /// Fwd decl.
- template <typename I, typename F>
- void apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun);
+ template <typename R, typename A, typename I>
+ oln_plain_value(I, R)
+ apply(R (*fun)(A), const Image<I>& input);
+
+
+// /// Fwd decl.
+// template <typename I, typename F>
+// oln_plain_value(I, typename F::result_value)
+// apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun);
+
+// /// Fwd decl.
+// template <typename I, typename V>
+// void apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&));
+
+// /// Fwd decl.
+// template <typename I, typename F>
+// void apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun);
# ifndef OLN_INCLUDE_ONLY
@@ -65,85 +64,87 @@
{
/// Generic version.
- template <typename I, typename V>
- oln_plain_value(I, V)
- apply(const abstract::image<I>& input, V (*fun)(const oln_value(I)&))
- {
- oln_plain_value(I, V) output(input.topo());
- oln_piter(I) p(input.topo());
- for_all(p)
- output(p) = fun(input(p));
- return output;
- }
- /// Generic version.
- template <typename I, typename F>
- oln_plain_value(I, typename F::result_value)
- apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun)
+ template <typename R, typename A, typename I>
+ oln_plain_value(I, R)
+ apply(R (*fun)(A), const Image<I>& input)
{
- oln_plain_value(I, typename F::result_value) output(input.topo());
- oln_piter(I) p(input.topo());
+ oln_plain_value(I, R) output(input.points());
+ oln_piter(I) p(input.points());
for_all(p)
- output(p) = fun.exact()(input(p));
+ output(p) = fun(input(p));
return output;
}
- /// Generic version.
- template <typename I, typename V>
- void
- apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&))
- {
- oln_piter(I) p(input.topo());
- for_all(p)
- input(p) = fun(input(p));
- }
-
- /// Generic version.
- template <typename I, typename F>
- void
- apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun)
- {
- oln_piter(I) p(input.topo());
- for_all(p)
- input(p) = fun.exact()(input(p));
- }
+// /// Generic version.
+// template <typename I, typename F>
+// oln_plain_value(I, typename F::result_value)
+// apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun)
+// {
+// oln_plain_value(I, typename F::result_value) output(input.topo());
+// oln_piter(I) p(input.topo());
+// for_all(p)
+// output(p) = fun.exact()(input(p));
+// return output;
+// }
+
+
+// /// Generic version.
+// template <typename I, typename V>
+// void
+// apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&))
+// {
+// oln_piter(I) p(input.topo());
+// for_all(p)
+// input(p) = fun(input(p));
+// }
+
+// /// Generic version.
+// template <typename I, typename F>
+// void
+// apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun)
+// {
+// oln_piter(I) p(input.topo());
+// for_all(p)
+// input(p) = fun.exact()(input(p));
+// }
} // end of namespace oln::level::impl
/// Facade.
- template <typename I, typename V>
- oln_plain_value(I, V)
- apply(const abstract::image<I>& input, V (*fun)(const oln_value(I)&))
- {
- return impl::apply(input, fun);
- }
-
- /// Facade.
- template <typename I, typename F>
- oln_plain_value(I, typename F::result_value)
- apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun)
- {
- return impl::apply(input, fun);
- }
-
-
- /// Facade.
- template <typename I, typename V>
- void
- apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&))
- {
- return impl::apply_inplace(input, fun);
- }
-
- /// Facade.
- template <typename I, typename F>
- void
- apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun)
- {
- return impl::apply_inplace(input, fun);
- }
+ template <typename R, typename A, typename I>
+ oln_plain_value(I, R)
+ apply(R (*fun)(A), const Image<I>& input)
+ {
+ return impl::apply(fun, exact(input));
+ }
+
+// /// Facade.
+// template <typename I, typename F>
+// oln_plain_value(I, typename F::result_value)
+// apply(const abstract::image<I>& input, const abstract::fun_v2v<F>& fun)
+// {
+// return impl::apply(input, fun);
+// }
+
+
+// /// Facade.
+// template <typename I, typename V>
+// void
+// apply_inplace(abstract::mutable_image<I>& input, V (*fun)(const oln_value(I)&))
+// {
+// return impl::apply_inplace(input, fun);
+// }
+
+// /// Facade.
+// template <typename I, typename F>
+// void
+// apply_inplace(abstract::mutable_image<I>& input, const abstract::fun_v2v<F>& fun)
+// {
+// return impl::apply_inplace(input, fun);
+// }
# endif
Index: oln/core/internal/f_ch_value.hh
--- oln/core/internal/f_ch_value.hh (revision 869)
+++ oln/core/internal/f_ch_value.hh (working copy)
@@ -38,6 +38,10 @@
typename oln::internal::f_ch_value_< stc_type_in(oln, I, skeleton), T >::ret
+# define oln_plain_value(I, T) \
+typename oln::internal::f_ch_value_< stc_type_in(oln, oln_plain(I), skeleton), T >::ret
+
+
namespace oln
{
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 869)
+++ oln/core/internal/image_base.hh (working copy)
@@ -416,4 +416,9 @@
} // end of namespace oln
+// FIXME: Bad!
+# include <oln/core/internal/f_ch_value.hh>
+
+
+
#endif // ! OLN_CORE_INTERNAL_IMAGE_BASE_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add plain and ch_value functions on images.
* oln/core/internal/f_ch_value.hh,
* oln/core/internal/f_pset_plain.hh: New.
* tests/core/neighb2d.cc: Fix.
* tests/core/Makefile.am: Fix.
* oln/core/concept/image.hh (plain): New.
* oln/core/equipment.hh (plain, skeleton): New.
(oln_plain): New.
* oln/core/2d/image2d.hh: Update.
* oln/core/2d/image2d_b.hh: Update.
* oln/core/gen/op.hh (op_): New ctor.
* oln/core/gen/single_value_image.hh: Update.
* oln/core/internal/op_image_plus_nbh.hh: Separate decl and impl.
(special_op_): New ctor.
* oln/core/internal/instant_value.hh: Inactivate code that does not
compile with g++-3.
* oln/core/internal/image_base.hh (pl::value, pl::rec): New.
(image_base_): Update.
* oln/stc/scoop.hh (stc_type_in_, stc_type_in): New.
oln/core/2d/image2d.hh | 3
oln/core/2d/image2d_b.hh | 3
oln/core/concept/image.hh | 1
oln/core/equipment.hh | 3
oln/core/gen/op.hh | 6 +
oln/core/gen/single_value_image.hh | 6 +
oln/core/internal/f_ch_value.hh | 101 +++++++++++++++++++++++++++++++++
oln/core/internal/f_pset_plain.hh | 71 +++++++++++++++++++++++
oln/core/internal/image_base.hh | 21 ++++++
oln/core/internal/instant_value.hh | 6 +
oln/core/internal/op_image_plus_nbh.hh | 55 ++++++++++++++++-
oln/stc/scoop.hh | 4 +
tests/core/Makefile.am | 1
tests/core/neighb2d.cc | 1
14 files changed, 272 insertions(+), 10 deletions(-)
Index: tests/core/neighb2d.cc
--- tests/core/neighb2d.cc (revision 868)
+++ tests/core/neighb2d.cc (working copy)
@@ -60,6 +60,5 @@
// 2 + 3 + 2 +
// 3 + 4 + 3 +
// 2 + 3 + 2 = 24
- std::cout << test::run(ima + c4) << std::endl;
assert(test::run(ima + c4) = 24);
}
Index: tests/core/Makefile.am
--- tests/core/Makefile.am (revision 868)
+++ tests/core/Makefile.am (working copy)
@@ -25,7 +25,6 @@
image2d \
neighb2d \
npoints \
- neighb2d \
window2d \
at
Index: oln/core/concept/image.hh
--- oln/core/concept/image.hh (revision 868)
+++ oln/core/concept/image.hh (working copy)
@@ -123,6 +123,7 @@
stc_typename(pset);
// stc_typename(output); // FIXME: Uncomment!
+ stc_typename(plain);
bool owns_(const psite& p) const;
rvalue operator()(const psite& p) const;
Index: oln/core/equipment.hh
--- oln/core/equipment.hh (revision 868)
+++ oln/core/equipment.hh (working copy)
@@ -95,11 +95,13 @@
// p
stc_decl_associated_type( piter );
+ stc_decl_associated_type( plain );
stc_decl_associated_type( point );
stc_decl_associated_type( pset );
stc_decl_associated_type( psite );
# define oln_piter(T) oln_typename_shortcut__(T, piter)
+# define oln_plain(T) oln_typename_shortcut__(T, plain)
# define oln_point(T) oln_typename_shortcut__(T, point)
// q
@@ -114,6 +116,7 @@
// s
stc_decl_associated_type( std_container );
+ stc_decl_associated_type( skeleton );
// t
stc_decl_associated_type( tag );
Index: oln/core/2d/image2d.hh
--- oln/core/2d/image2d.hh (revision 868)
+++ oln/core/2d/image2d.hh (working copy)
@@ -56,6 +56,9 @@
typedef box2d pset;
typedef array2d_<value, coord> data;
+
+ typedef image2d<T> plain;
+ typedef image2d<pl::value> skeleton;
};
Index: oln/core/2d/image2d_b.hh
--- oln/core/2d/image2d_b.hh (revision 868)
+++ oln/core/2d/image2d_b.hh (working copy)
@@ -101,6 +101,9 @@
typedef box2d pset;
typedef internal::array_b_<point2d, T> data;
+ typedef image2d_b<T> plain;
+ typedef image2d_b<pl::value> skeleton;
+
// FIXME: wrong qiter!!!
};
Index: oln/core/gen/op.hh
--- oln/core/gen/op.hh (revision 868)
+++ oln/core/gen/op.hh (working copy)
@@ -138,6 +138,7 @@
class op_ : public super
{
public:
+ op_();
op_(L& l, R& r);
}; // end of op_<L, OpName, R>
@@ -147,6 +148,11 @@
# ifndef OLN_INCLUDE_ONLY
template <typename L, typename OpName, typename R>
+ op_<L, OpName, R>::op_()
+ {
+ }
+
+ template <typename L, typename OpName, typename R>
op_<L, OpName, R>::op_(L& l, R& r)
: super (l, r)
{
Index: oln/core/gen/single_value_image.hh
--- oln/core/gen/single_value_image.hh (revision 868)
+++ oln/core/gen/single_value_image.hh (working copy)
@@ -30,6 +30,7 @@
# include <oln/core/internal/image_base.hh>
# include <oln/core/internal/utils.hh>
+# include <oln/core/internal/f_pset_plain.hh>
namespace oln
@@ -54,6 +55,9 @@
typedef const T& rvalue;
typedef internal::pair<Ps, T> data;
+
+ typedef oln_f_pset_plain(Ps, T) plain;
+ typedef single_value_image<Ps, pl::value> skeleton;
};
@@ -151,7 +155,7 @@
this->data_->value2 = new_value;
}
-# endif
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/internal/f_ch_value.hh
--- oln/core/internal/f_ch_value.hh (revision 0)
+++ oln/core/internal/f_ch_value.hh (revision 0)
@@ -0,0 +1,101 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_F_CH_VALUE_HH
+# define OLN_CORE_INTERNAL_F_CH_VALUE_HH
+
+# include <oln/core/internal/image_base.hh>
+
+
+#define oln_ch_value_(I, T) \
+oln::internal::f_ch_value_< stc_type_in_(oln, I, skeleton), T >::ret
+
+#define oln_ch_value(I, T) \
+typename oln::internal::f_ch_value_< stc_type_in(oln, I, skeleton), T >::ret
+
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ template <typename I, typename T> struct f_ch_value_;
+
+
+ template <template <class> class tc,
+ typename T>
+ struct f_ch_value_< tc<pl::value>,
+ T >
+ {
+ typedef tc<T> ret;
+ };
+
+
+ template <template <class, class> class tcc, typename t,
+ typename T>
+ struct f_ch_value_< tcc<t, pl::value>,
+ T >
+ {
+ typedef tcc<t, T> ret;
+ };
+
+
+ template <template <class> class tc, typename t,
+ typename T>
+ struct f_ch_value_< tc< pl::rec<t> >,
+ T >
+ {
+ typedef tc< oln_ch_value(t, T) > ret;
+ };
+
+
+ template <template <class, class> class tcc, typename t1, typename t2,
+ typename T>
+ struct f_ch_value_< tcc< pl::rec<t1>, t2 >,
+ T >
+ {
+ typedef tcc< oln_ch_value(t1, T), t2 > ret;
+ };
+
+
+ template <template <class, class, class> class tccc, typename t1, typename t2, typename t3,
+ typename T>
+ struct f_ch_value_< tccc< pl::rec<t1>, t2, t3 >,
+ T >
+ {
+ typedef tccc< oln_ch_value(t1, T), t2, t3 > ret;
+ };
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_F_CH_VALUE_HH
Index: oln/core/internal/f_pset_plain.hh
--- oln/core/internal/f_pset_plain.hh (revision 0)
+++ oln/core/internal/f_pset_plain.hh (revision 0)
@@ -0,0 +1,71 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
+# define OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
+
+# include <oln/core/concept/point_set.hh>
+
+
+#define oln_f_pset_plain(Ps, T) typename oln::internal::f_pset_plain_< Ps, T >::ret
+
+
+namespace oln
+{
+
+ // Fwd decls.
+ struct grid2d_rec;
+ template <typename P> class box_;
+ typedef box_<point2d> box2d;
+ template <typename T> class image2d_b;
+
+
+ namespace internal
+ {
+
+ template <typename Gr, typename Ps, typename T>
+ struct f_pset_plain__;
+
+ template <typename T>
+ struct f_pset_plain__< grid2d_rec, box2d, T >
+ {
+ typedef image2d_b<T> ret;
+ };
+
+ template <typename Ps, typename T>
+ struct f_pset_plain_ : private mlc::assert_< mlc_is_a(Ps, Point_Set) >,
+ public f_pset_plain__< stc_type(Ps, grid), Ps, T >
+
+ {
+ };
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_F_PSET_PLAIN_HH
Index: oln/core/internal/op_image_plus_nbh.hh
--- oln/core/internal/op_image_plus_nbh.hh (revision 868)
+++ oln/core/internal/op_image_plus_nbh.hh (working copy)
@@ -62,6 +62,9 @@
typedef N nbh;
typedef dpoints_fwd_piter_<point__> fwd_niter;
typedef dpoints_bkd_piter_<point__> bkd_niter;
+
+ typedef op_<oln_plain(I), plus, N> plain;
+ typedef op_<pl::rec<I>, plus, N> skeleton;
};
@@ -81,18 +84,60 @@
stc_using(data);
stc_using(delegatee);
- delegatee& impl_image() { assert(this->has_data()); return this->data_->value1; }
- const delegatee& impl_image() const { assert(this->has_data()); return this->data_->value1; }
+ delegatee& impl_image();
+ const delegatee& impl_image() const;
- nbh impl_nbhood() const { assert(this->has_data()); return this->data_->value2; }
+ nbh impl_nbhood() const;
protected:
- special_op_(I& ima, N& n)
+ special_op_();
+ special_op_(I& ima, N& n);
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+# define current \
+ special_op_< stc::is<Image>, I, plus, stc::is<Neighborhood>, N >
+
+ template <typename I, typename N>
+ current::special_op_()
+ {
+ }
+
+ template <typename I, typename N>
+ current::special_op_(I& ima, N& n)
{
this->data_ = new data(ima, n);
}
- };
+ template <typename I, typename N>
+ typename current::delegatee&
+ current::impl_image()
+ {
+ assert(this->has_data());
+ return this->data_->value1;
+ }
+
+ template <typename I, typename N>
+ const typename current::delegatee&
+ current::impl_image() const
+ {
+ assert(this->has_data());
+ return this->data_->value1;
+ }
+
+ template <typename I, typename N>
+ typename current::nbh
+ current::impl_nbhood() const
+ {
+ assert(this->has_data());
+ return this->data_->value2;
+ }
+
+# undef current
+
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln::internal
Index: oln/core/internal/instant_value.hh
--- oln/core/internal/instant_value.hh (revision 868)
+++ oln/core/internal/instant_value.hh (working copy)
@@ -60,13 +60,16 @@
{
V value;
+ /*
template <typename W>
- operator M<W>() const;
+ operator M<W>() const; // FIXME: do not compile with g++-3!!!
+ */
};
# ifndef OLN_INCLUDE_ONLY
+ /*
template <template<class> class M, typename V>
template <typename W>
instant_value_<M,V>::operator M<W>() const
@@ -74,6 +77,7 @@
M<W> tmp(this->value);
return tmp;
}
+ */
# endif // OLN_INCLUDE_ONLY
Index: oln/core/internal/image_base.hh
--- oln/core/internal/image_base.hh (revision 868)
+++ oln/core/internal/image_base.hh (working copy)
@@ -40,6 +40,19 @@
namespace oln
{
+
+ // FIXME: Experimental code below.
+
+ namespace pl // placeholder for short
+ {
+ struct value;
+ template <typename t> struct rec;
+ }
+
+ // End of experimental code.
+
+
+
/// Fwd decls.
namespace internal
@@ -116,7 +129,9 @@
typedef stc::abstract rvalue;
// FIXME: Uncomment below!
- // typedef stc::abstract output;
+ // typedef stc::abstract ...
+ typedef stc::abstract skeleton;
+ typedef stc::abstract plain;
typedef stc::abstract data;
@@ -155,7 +170,11 @@
{
typedef stc::abstract delegatee;
typedef stc::abstract behavior;
+
+ // not delegated:
typedef stc::not_delegated data;
+ typedef stc::not_delegated plain;
+ typedef stc::not_delegated skeleton;
};
template <typename Exact>
Index: oln/stc/scoop.hh
--- oln/stc/scoop.hh (revision 868)
+++ oln/stc/scoop.hh (working copy)
@@ -99,6 +99,10 @@
# define stc_type_(From, Type) vtype<From, typedef_::Type>::ret
# define stc_type(From, Type) typename stc_type_(From, Type)
+# define stc_type_in_(Namespace, From, Type) Namespace::vtype<From, Namespace::typedef_::Type>::ret
+# define stc_type_in(Namespace, From, Type) typename stc_type_in_(Namespace, From, Type)
+
+
# define stc_get_type_(Type) vtype<Exact, typedef_::Type>::ret
# define stc_get_type(Type) typename stc_get_type_(Type)
1
0
13 Mar '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add initialization material; extend point2d and box2d with it.
* oln/core/init.hh,
* oln/core/internal/initializer.hh,
* oln/core/internal/instant_value.hh: New.
* oln/core/concept/grid.hh (from, to): New.
* oln/core/2d/grid2d.hh (row, col),
(drow, dcol, nrows, ncols): New.
* oln/core/2d/box2d.hh (init__): New.
* oln/core/2d/point2d.hh (init__): New.
* oln/core/gen/box.hh (init__): New.
(operator<<): New.
* oln/core/internal/utils.hh: Add FIXME.
2d/box2d.hh | 65 +++++++++++++++++++++++++-
2d/grid2d.hh | 9 +++
2d/point2d.hh | 30 ++++++++++++
concept/grid.hh | 6 ++
gen/box.hh | 43 ++++++++++++++++-
init.hh | 105 ++++++++++++++++++++++++++++++++++++++++++
internal/initializer.hh | 115 ++++++++++++++++++++++++++++++++++++++++++++++
internal/instant_value.hh | 85 ++++++++++++++++++++++++++++++++++
internal/utils.hh | 6 ++
9 files changed, 460 insertions(+), 4 deletions(-)
Index: oln/core/concept/grid.hh
--- oln/core/concept/grid.hh (revision 867)
+++ oln/core/concept/grid.hh (working copy)
@@ -30,11 +30,17 @@
# define OLN_CORE_CONCEPT_GRID_HH
# include <oln/core/equipment.hh>
+# include <oln/core/internal/instant_value.hh>
namespace oln
{
+ /// Instant values.
+ oln_decl_instant_value(from);
+ oln_decl_instant_value(to);
+
+
/// Concept-class "Grid".
template <typename Exact>
Index: oln/core/init.hh
--- oln/core/init.hh (revision 0)
+++ oln/core/init.hh (revision 0)
@@ -0,0 +1,105 @@
+// 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_INIT_HH
+# define OLN_CORE_INIT_HH
+
+# include <oln/core/internal/utils.hh>
+# include <oln/core/internal/instant_value.hh>
+# include <oln/core/internal/initializer.hh>
+
+
+
+namespace oln
+{
+
+
+ template <template<class> class M, typename V>
+ internal::initializer_< internal::singleton< M<V> > >
+ init(const internal::instant_value_<M,V>& v);
+
+
+ template <template<class> class M1, typename V1,
+ template<class> class M2, typename V2>
+ internal::initializer_< internal::pair< M1<V1>, M2<V2> > >
+ init(const internal::instant_value_<M1,V1>& v1,
+ const internal::instant_value_<M2,V2>& v2);
+
+
+ template <template<class> class M1, typename V1,
+ template<class> class M2, typename V2,
+ template<class> class M3, typename V3>
+ internal::initializer_< internal::triplet< M1<V1>, M2<V2>, M3<V3> > >
+ init(const internal::instant_value_<M1,V1>& v1,
+ const internal::instant_value_<M2,V2>& v2,
+ const internal::instant_value_<M3,V3>& v3);
+
+ // ...
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <template<class> class M, typename V>
+ internal::initializer_< internal::singleton< M<V> > >
+ init(const internal::instant_value_<M,V>& v)
+ {
+ internal::singleton< M<V> > tmp(v.value);
+ return tmp;
+ }
+
+ template <template<class> class M1, typename V1,
+ template<class> class M2, typename V2>
+ internal::initializer_< internal::pair< M1<V1>, M2<V2> > >
+ init(const internal::instant_value_<M1,V1>& v1,
+ const internal::instant_value_<M2,V2>& v2)
+ {
+ internal::pair< M1<V1>, M2<V2> > tmp(v1.value, v2.value);
+ return tmp;
+ }
+
+ template <template<class> class M1, typename V1,
+ template<class> class M2, typename V2,
+ template<class> class M3, typename V3>
+ internal::initializer_< internal::triplet< M1<V1>, M2<V2>, M3<V3> > >
+ init(const internal::instant_value_<M1,V1>& v1,
+ const internal::instant_value_<M2,V2>& v2,
+ const internal::instant_value_<M3,V3>& v3)
+ {
+ internal::triplet< M1<V1>, M2<V2>, M3<V3> > tmp(v1.value, v2.value, v3.value);
+ return tmp;
+ }
+
+ // ...
+
+# endif // OLN_INCLUDE_ONLY
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INIT_HH
Property changes on: oln/core/init.hh
___________________________________________________________________
Name: svn:executable
+ *
Index: oln/core/2d/grid2d.hh
--- oln/core/2d/grid2d.hh (revision 867)
+++ oln/core/2d/grid2d.hh (working copy)
@@ -32,6 +32,7 @@
# include <oln/core/concept/grid.hh>
+
# define OLN_ENV_2D
@@ -39,6 +40,14 @@
namespace oln
{
+ /// Instant values.
+ oln_decl_instant_value(row);
+ oln_decl_instant_value(col);
+ oln_decl_instant_value(drow);
+ oln_decl_instant_value(dcol);
+ oln_decl_instant_value(nrows);
+ oln_decl_instant_value(ncols);
+
/// \{
/// Fwd decls.
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 867)
+++ oln/core/2d/box2d.hh (working copy)
@@ -28,18 +28,79 @@
#ifndef OLN_CORE_2D_BOX2D_HH
# define OLN_CORE_2D_BOX2D_HH
-# include <oln/core/gen/box.hh>
# include <oln/core/2d/point2d.hh>
namespace oln
{
+ // Fwd decl.
+ template <typename P> class box_;
+
+
// FIXME: box2d should be an actual type, not an alias...
typedef box_<point2d> box2d;
+
+ /// init__
+ namespace internal
+ {
+
+ template <typename C>
+ void init__(box2d& b,
+ const initializer_< pair< nrows_t<C>, ncols_t<C> > >& data);
+
+ template <typename C>
+ void init__(box2d& b,
+ const initializer_< triplet< from_t<point2d>, nrows_t<C>, ncols_t<C> > >& data);
+
+ } // end of namespace oln::internal
+
} // end of namespace oln
-#endif // ! OLN_CORE_2D_BOX2D_HH
+# include <oln/core/gen/box.hh>
+
+# ifndef OLN_INCLUDE_ONLY
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ template <typename C>
+ void init__(box2d& b,
+ const initializer_< pair< nrows_t<C>, ncols_t<C> > >& data)
+ {
+ C nrows = data->value1.value;
+ C ncols = data->value2.value;
+ precondition(nrows > 0 and ncols > 0);
+ b.pmin().row() = 0;
+ b.pmin().col() = 0;
+ b.pmax().row() = nrows - 1;
+ b.pmax().col() = ncols - 1;
+ }
+
+ template <typename C>
+ void init__(box2d& b,
+ const initializer_< triplet< from_t<point2d>, nrows_t<C>, ncols_t<C> > >& data)
+ {
+ C nrows = data->value2.value;
+ C ncols = data->value3.value;
+ precondition(nrows > 0 and ncols > 0);
+ b.pmin() = data->value1.value;
+ b.pmax().row() = b.pmin().row() + nrows - 1;
+ b.pmax().col() = b.pmin().col() + ncols - 1;
+ }
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+# endif // OLN_INCLUDE_ONLY
+
+
+#endif // ! OLN_CORE_2D_BOX2D_HH
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 867)
+++ oln/core/2d/point2d.hh (working copy)
@@ -31,6 +31,7 @@
# include <oln/core/2d/grid2d.hh>
# include <oln/core/internal/point2d.hh>
+# include <oln/core/init.hh>
namespace oln
@@ -59,13 +60,25 @@
};
+ /// init__
+ namespace internal
+ {
+ template <typename C>
+ void init__(point2d& p,
+ const initializer_< pair< row_t<C>, col_t<C> > >& data);
+ }
+
+
/// Usual 2D point class.
class point2d : public internal::point2d_< point2d >
{
public:
+
/// Ctors.
point2d();
point2d(int row, int col);
+ template <typename D>
+ point2d(const internal::initializer_<D>& data);
};
@@ -82,6 +95,23 @@
this->col() = col;
}
+ template <typename D>
+ point2d::point2d(const internal::initializer_<D>& data)
+ {
+ internal::init__(*this, data);
+ }
+
+ namespace internal
+ {
+ template <typename C>
+ void init__(point2d& p,
+ const initializer_< pair< row_t<C>, col_t<C> > >& data)
+ {
+ p.row() = data->value1.value; // FIXME: first
+ p.col() = data->value2.value; // FIXME: second
+ }
+ }
+
# endif
Index: oln/core/gen/box.hh
--- oln/core/gen/box.hh (revision 867)
+++ oln/core/gen/box.hh (working copy)
@@ -32,11 +32,13 @@
# include <oln/core/concept/point.hh>
# include <oln/core/concept/iterator_on_points.hh>
# include <oln/core/internal/point_set_base.hh>
+# include <oln/core/init.hh>
namespace oln
{
+
// Forward declarations.
template <typename P> class box_;
template <typename P> class box_fwd_piter_;
@@ -62,6 +64,15 @@
};
+ /// init__
+ namespace internal
+ {
+ template <typename P>
+ void init__(box_<P>& b,
+ const initializer_< pair< from_t<P>, to_t<P> > >& data);
+ }
+
+
/// Generic box class based on a point class.
template <typename P>
@@ -83,6 +94,8 @@
box_();
box_(const P& pmin, const P& pmax);
+ template <typename D>
+ box_(const internal::initializer_<D>& data);
unsigned impl_npoints() const;
bool impl_has(const P& p) const;
@@ -99,6 +112,11 @@
}; // end of class oln::box_<P>
+ template <typename P>
+ std::ostream& operator<<(std::ostream& ostr, const box_<P>& b)
+ {
+ return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }";
+ }
// -------------------- iterators on box_<P>
@@ -209,6 +227,13 @@
}
template <typename P>
+ template <typename D>
+ box_<P>::box_(const internal::initializer_<D>& data)
+ {
+ internal::init__(*this, data);
+ }
+
+ template <typename P>
unsigned
box_<P>::impl_npoints() const
{
@@ -268,6 +293,22 @@
}
+ // -------------------- init__
+
+
+ namespace internal
+ {
+
+ template <typename P>
+ void init__(box_<P>& b,
+ const initializer_< pair< from_t<P>, to_t<P> > >& data)
+ {
+ b.pmin() = data->value1.value;
+ b.pmax() = data->value2.value;
+ }
+
+ }
+
// -------------------- box_fwd_piter_<P>
@@ -407,7 +448,7 @@
return &p_;
}
-# endif
+# endif // OLN_INCLUDE_ONLY
} // end of namespace oln
Index: oln/core/internal/initializer.hh
--- oln/core/internal/initializer.hh (revision 0)
+++ oln/core/internal/initializer.hh (revision 0)
@@ -0,0 +1,115 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_INITIALIZER_HH
+# define OLN_CORE_INTERNAL_INITIALIZER_HH
+
+
+namespace oln
+{
+
+
+ namespace ERROR
+ {
+
+ template <typename S>
+ struct bad_initialization_of_
+ {
+ template <typename D>
+ struct with_;
+ };
+
+ } // end of namespace oln::ERROR
+
+
+
+ namespace internal
+ {
+
+
+ template <typename D>
+ struct initializer_
+ {
+ initializer_(const D& data);
+ const D& operator*() const;
+ const D* operator->() const;
+
+ protected:
+ D data_;
+ };
+
+
+ template <typename Tag, typename Subject, typename D>
+ void init__(const Tag& t, Subject& s, const initializer_<D>& d);
+
+ template <typename Subject, typename D>
+ void init__(Subject& s, const initializer_<D>& d);
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename D>
+ initializer_<D>::initializer_(const D& data)
+ : data_(data)
+ {}
+
+ template <typename D>
+ const D&
+ initializer_<D>::operator*() const
+ {
+ return this->data_;
+ }
+
+ template <typename D>
+ const D*
+ initializer_<D>::operator->() const
+ {
+ return &(this->data_);
+ }
+
+ template <typename Tag, typename Subject, typename D>
+ void init__(const Tag&, Subject&, const initializer_<D>&)
+ {
+ mlc::abort_<D, typename ERROR::bad_initialization_of_<Subject>::template with_<D> >::check();
+ }
+
+ template <typename Subject, typename D>
+ void init__(Subject&, const initializer_<D>&)
+ {
+ mlc::abort_<D, typename ERROR::bad_initialization_of_<Subject>::template with_<D> >::check();
+ }
+
+# endif // OLN_INCLUDE_ONLY
+
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_INITIALIZER_HH
Property changes on: oln/core/internal/initializer.hh
___________________________________________________________________
Name: svn:executable
+ *
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 867)
+++ oln/core/internal/utils.hh (working copy)
@@ -35,6 +35,11 @@
namespace internal
{
+
+ // FIXME: Rename attributes as first / second / third / fourth?
+
+
+
/// Simple singleton class.
template <typename T>
@@ -109,4 +114,3 @@
#endif // ! OLN_CORE_INTERNAL_UTILS_HH
-
Index: oln/core/internal/instant_value.hh
--- oln/core/internal/instant_value.hh (revision 0)
+++ oln/core/internal/instant_value.hh (revision 0)
@@ -0,0 +1,85 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_INSTANT_VALUE_HH
+# define OLN_CORE_INTERNAL_INSTANT_VALUE_HH
+
+
+# define oln_decl_instant_value(Name) \
+ \
+template <typename V> \
+struct Name##_t : public internal::instant_value_< Name##_t, V> \
+{ \
+ Name##_t(const V& v) { this->value = v; } \
+}; \
+ \
+template <typename V> \
+Name##_t<V> Name(const V& v) \
+{ \
+ return Name##_t<V>(v); \
+} \
+ \
+struct e_n_d___w_i_t_h___s_e_m_i_c_o_l_u_m_n
+
+
+
+namespace oln
+{
+
+ namespace internal
+ {
+
+ /// Class internal::instant_value_<M,V>.
+
+ template <template<class> class M, typename V>
+ struct instant_value_
+ {
+ V value;
+
+ template <typename W>
+ operator M<W>() const;
+ };
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <template<class> class M, typename V>
+ template <typename W>
+ instant_value_<M,V>::operator M<W>() const
+ {
+ M<W> tmp(this->value);
+ return tmp;
+ }
+
+# endif // OLN_INCLUDE_ONLY
+
+ } // end of namespace oln::internal
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_INSTANT_VALUE_HH
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Tiny fix.
* mlc/typedef.hh (result): Rename as...
(result_): ...this; disambiguation.
* mlc/cmp.hh (assert_found_),
(assert_not_found_): New.
cmp.hh | 10 ++++++++++
typedef.hh | 18 +++++++++---------
2 files changed, 19 insertions(+), 9 deletions(-)
Index: mlc/typedef.hh
--- mlc/typedef.hh (revision 866)
+++ mlc/typedef.hh (working copy)
@@ -161,29 +161,29 @@
static no selector(...); \
\
template <class T, bool found_> \
- struct result; \
+ struct result_; \
\
template <class T> \
- struct result <T, true> { \
+ struct result_ <T, true> { \
typedef typename T::TypedefName ret; \
}; \
\
template <class T> \
- struct result <T, false> { \
+ struct result_ <T, false> { \
typedef mlc::not_found ret; \
}; \
\
template <class T, bool found_> \
- struct result2; \
+ struct result_2; \
\
template <class T> \
- struct result2 <T, true> { \
+ struct result_2 <T, true> { \
typedef mlc::pair_<mlc::found, \
typename T::TypedefName> ret; \
}; \
\
template <class T> \
- struct result2 <T, false> { \
+ struct result_2 <T, false> { \
typedef mlc::pair_<mlc::not_found, \
mlc::dummy> ret; \
}; \
@@ -205,11 +205,11 @@
}; \
public: \
typedef \
- typename helper_::result<T, found_>::ret \
+ typename helper_::result_<T, found_>::ret \
ret; \
\
typedef \
- typename helper_::result2<T, found_>::ret \
+ typename helper_::result_2<T, found_>::ret \
ret2; \
}; \
\
@@ -235,7 +235,7 @@
\
} \
\
-struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n \
+struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_o_n
/*! \macro mlc_typedef(Type, TypedefName)
Index: mlc/cmp.hh
--- mlc/cmp.hh (revision 866)
+++ mlc/cmp.hh (working copy)
@@ -161,6 +161,16 @@
struct is_found_ : public mlc_is_not_a(T, mlc::not_found)::bexpr
{
};
+
+ template <typename T, typename err = no_error_message>
+ struct assert_found_ : public assert_< is_found_<T>, err >
+ {
+ };
+
+ template <typename T, typename err = no_error_message>
+ struct assert_not_found_ : public assert_< is_not_found_<T>, err >
+ {
+ };
/// \}
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add 1D classes and remove some dead code.
* oln/core/internal/utils.hh (triplet): New.
* oln/core/1d/image1d_b.hh,
* oln/core/1d/grid1d.hh,
* oln/core/1d/box1d.hh,
* oln/core/internal/dpoint1d.hh,
* oln/core/internal/point1d.hh: New.
* tests/core/grid.cc,
* oln/core/1d/neighb1d.hh,
* oln/core/1d/dpoint1d.hh,
* oln/core/1d/array1d.hh,
* oln/core/1d/image1d.hh,
* oln/core/1d/window1d.hh,
* oln/core/1d/point1d.hh: Update.
* oln/core/aliases.hh,
* oln/core/fwd_decls.hh,
* oln/core/1d/aliases.hh,
* oln/core/1d/topo1d.hh,
* oln/core/1d/fwd_decls.hh,
* oln/core/2d/aliases.hh,
* oln/core/2d/topo2d.hh,
* oln/core/2d/fwd_decls.hh,
* oln/core/3d/aliases.hh,
* oln/core/3d/topo3d.hh,
* oln/core/3d/fwd_decls.hh,
* oln/core/gen/fwd_decls.hh: Remove.
* oln/core/2d/box2d.hh,
* oln/core/2d/neighb2d.hh,
* oln/core/2d/window2d.hh (include): Remove aliases.
* oln/core/internal/point2d.hh (grid_): Remove fwd decl.
oln/core/1d/array1d.hh | 149 ++++++++++++++++++++---------
oln/core/1d/box1d.hh | 45 +++++++++
oln/core/1d/dpoint1d.hh | 91 +++++-------------
oln/core/1d/grid1d.hh | 93 ++++++++++++++++++
oln/core/1d/image1d.hh | 154 ++++++++++++++++++------------
oln/core/1d/image1d_b.hh | 210 ++++++++++++++++++++++++++++++++++++++++++
oln/core/1d/neighb1d.hh | 10 +-
oln/core/1d/point1d.hh | 107 +++++----------------
oln/core/1d/window1d.hh | 18 ++-
oln/core/2d/box2d.hh | 2
oln/core/2d/neighb2d.hh | 2
oln/core/2d/window2d.hh | 2
oln/core/internal/dpoint1d.hh | 108 +++++++++++++++++++++
oln/core/internal/point1d.hh | 108 +++++++++++++++++++++
oln/core/internal/point2d.hh | 1
oln/core/internal/utils.hh | 48 ++++++++-
tests/core/grid.cc | 4
17 files changed, 880 insertions(+), 272 deletions(-)
Index: tests/core/grid.cc
--- tests/core/grid.cc (revision 865)
+++ tests/core/grid.cc (working copy)
@@ -30,8 +30,8 @@
#include <cassert>
#include <oln/core/2d/grid2d.hh>
// FIXME: Disabled.
-// #include <oln/core/1d/aliases.hh>
-// #include <oln/core/3d/aliases.hh>
+// #include <oln/core/1d/grid1d.hh>
+// #include <oln/core/3d/grid3d.hh>
int
Index: oln/core/1d/neighb1d.hh
--- oln/core/1d/neighb1d.hh (revision 865)
+++ oln/core/1d/neighb1d.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
@@ -36,6 +36,7 @@
namespace oln
{
+ // FIXME: neighb2d should be an actual type, not an alias...
typedef neighb_<dpoint1d> neighb1d;
@@ -49,10 +50,9 @@
neighb1d mk_c2()
{
- neighb1d the_;
- the_
- .add(dpoint1d(1));
- return the_;
+ neighb1d tmp;
+ tmp.take(dpoint1d(1));
+ return tmp;
}
# endif
Index: oln/core/1d/dpoint1d.hh
--- oln/core/1d/dpoint1d.hh (revision 865)
+++ oln/core/1d/dpoint1d.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,103 +29,66 @@
#ifndef OLN_CORE_1D_DPOINT1D_HH
# define OLN_CORE_1D_DPOINT1D_HH
-# include <mlc/int.hh>
-# include <oln/core/1d/point1d.hh>
-# include <oln/core/internal/dpoint_nd.hh>
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/internal/dpoint1d.hh>
namespace oln
{
- typedef dpoint1d_<int> dpoint1d;
-
- /// Fwd decls.
- template <unsigned D> struct grid_;
- typedef grid_<1> grid1d;
- template <typename C> struct point1d_;
- typedef point1d_<int> point1d;
+ struct point1d;
+ struct dpoint1d;
/// Super type.
- template<typename C>
- struct set_super_type< dpoint1d_<C> >
+ template<>
+ struct super_trait_< dpoint1d >
{
- typedef internal::dpoint_nd< dpoint1d_<C> > ret;
+ typedef internal::dpoint1d_< dpoint1d > ret;
};
- /// Virtual types associated to oln::dpoint1d_<C>.
- template <typename C>
- struct vtypes< dpoint1d_<C> >
- {
- typedef grid1d grid_type;
- typedef point1d point_type;
- typedef C coord_type;
- typedef mlc::uint_<1> dim_type;
-
- typedef mlc::uint_<0> index_comp_type;
+ /// Virtual types.
+ template <>
+ struct vtypes< dpoint1d >
+ {
+ typedef grid1d grid;
+ typedef int coord;
+ typedef point1d point;
};
- /// General 1D dpoint class.
- template <typename C>
- class dpoint1d_
- : public internal::dpoint_nd< dpoint1d_<C> >
+ /// Usual 1D dpoint class.
+ class dpoint1d : public internal::dpoint1d_< dpoint1d >
{
- typedef dpoint1d_<C> self_t;
- typedef internal::dpoint_nd<self_t> super_t;
-
- using super_t::v_;
-
public:
-
- /// Ctor.
- dpoint1d_();
-
- /// Ctor.
- dpoint1d_(const xtd::vec<1,C>& v);
-
- /// Ctor.
- dpoint1d_(C index);
-
- C index() const;
- C& index();
+ /// Ctors.
+ dpoint1d();
+ dpoint1d(int ind);
};
# ifndef OLN_INCLUDE_ONLY
- template <typename C>
- dpoint1d_<C>::dpoint1d_()
+ dpoint1d::dpoint1d()
{
}
- /// Ctor.
- template <typename C>
- dpoint1d_<C>::dpoint1d_(const xtd::vec<1,C>& v)
- : super_t(v)
+ dpoint1d::dpoint1d(int ind)
{
+ this->ind() = ind;
}
- /// Ctor.
- template <typename C>
- dpoint1d_<C>::dpoint1d_(C index)
- : super_t(xtd::mk_vec(index))
- {
- }
-
- template <typename C>
- C dpoint1d_<C>::index() const { return v_[0]; }
-
- template <typename C>
- C& dpoint1d_<C>::index() { return v_[0]; }
-
# endif
} // end of namespace oln
+// dpoint1d goes with point1d so:
+# include <oln/core/1d/point1d.hh>
+
+
#endif // ! OLN_CORE_1D_DPOINT1D_HH
Index: oln/core/1d/array1d.hh
--- oln/core/1d/array1d.hh (revision 865)
+++ oln/core/1d/array1d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2003, 2004, 2006 EPITA Research and Development
-// Laboratory
+// Copyright (C) 2001, 2003, 2004, 2006, 2007 EPITA Research and
+// Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,40 +29,51 @@
#ifndef OLN_CORE_1D_ARRAY1D_HH
# define OLN_CORE_1D_ARRAY1D_HH
-# include <cstdlib>
+# include <cstddef>
# include <mlc/contract.hh>
-# include <oln/core/abstract/array.hh>
namespace oln
{
/// General 1D array class.
- template <typename value_t, typename coord_t = int>
- class array1d : public abstract::array
+
+ template <typename T, typename C = int>
+ class array1d_
{
public:
/// Ctor.
- array1d(coord_t min, coord_t max);
+ array1d_(C imin, C imax);
+
/// Ctor.
- array1d(coord_t len);
+ array1d_(C len);
/// Dtor.
- ~array1d();
+ ~array1d_();
+
+ const T& operator()(C i) const;
+ T& operator()(C i);
+
+ const T& operator[](std::size_t ind) const;
+ T& operator[](std::size_t ind);
- value_t operator()(coord_t i) const;
- value_t& operator()(coord_t i);
+ bool has(C i) const;
- bool has(coord_t i) const;
+ std::size_t memsize() const;
+ std::size_t ncells() const;
- size_t memsize() const;
+ C imin() const;
+ C imax() const;
+
+ const T* buffer() const;
+ T* buffer();
protected:
- coord_t min_, max_;
- coord_t len_;
- value_t* buffer_;
+ C imin_, imax_;
+ C len_;
+ T* buffer_;
private:
@@ -74,65 +85,113 @@
# ifndef OLN_INCLUDE_ONLY
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::array1d(coord_t min, coord_t max) :
- min_(min), max_(max)
+ template <typename T, typename C>
+ array1d_<T, C>::array1d_(C imin, C imax) :
+ imin_(imin),
+ imax_(imax)
{
- precondition(max >= min);
- len_ = max - min + 1;
+ precondition(imax >= imin);
+ len_ = imax - imin + 1;
allocate_();
}
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::array1d(coord_t len) :
- min_(0), len_(len)
+ template <typename T, typename C>
+ array1d_<T, C>::array1d_(C len) :
+ imin_(0),
+ len_(len)
{
precondition(len > 0);
- max_ = min_ + len_;
+ imax_ = imin_ + len_;
allocate_();
}
- template <typename value_t, typename coord_t>
- array1d<value_t, coord_t>::~array1d()
+ template <typename T, typename C>
+ array1d_<T, C>::~array1d_()
{
deallocate_();
}
- template <typename value_t, typename coord_t>
- value_t array1d<value_t, coord_t>::operator()(coord_t i) const
+ template <typename T, typename C>
+ const T& array1d_<T, C>::operator()(C i) const
{
precondition(has(i));
- return buffer_[i - min_];
+ return buffer_[i];
}
- template <typename value_t, typename coord_t>
- value_t& array1d<value_t, coord_t>::operator()(coord_t i)
+ template <typename T, typename C>
+ T& array1d_<T, C>::operator()(C i)
{
precondition(has(i));
- return buffer_[i - min_];
+ return buffer_[i];
+ }
+
+ template <typename T, typename C>
+ const T& array1d_<T, C>::operator[](std::size_t ind) const
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < len_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ T& array1d_<T, C>::operator[](std::size_t ind)
+ {
+ precondition(buffer_ != 0);
+ precondition(ind < len_);
+ return buffer_[ind];
+ }
+
+ template <typename T, typename C>
+ bool array1d_<T, C>::has(C i) const
+ {
+ return i >= imin_ and i <= imax_;
+ }
+
+
+ template <typename T, typename C>
+ C array1d_<T, C>::imin() const
+ {
+ return imin_;
+ }
+
+ template <typename T, typename C>
+ C array1d_<T, C>::imax() const
+ {
+ return imax_;
+ }
+
+ template <typename T, typename C>
+ const T* array1d_<T, C>::buffer() const
+ {
+ return buffer_;
+ }
+
+ template <typename T, typename C>
+ T* array1d_<T, C>::buffer()
+ {
+ return buffer_;
}
- template <typename value_t, typename coord_t>
- bool array1d<value_t, coord_t>::has(coord_t i) const
+ template <typename T, typename C>
+ std::size_t array1d_<T, C>::ncells() const
{
- return
- i >= min_ and i <= max_;
+ return len_;
}
- template <typename value_t, typename coord_t>
- size_t array1d<value_t, coord_t>::memsize() const
+ template <typename T, typename C>
+ std::size_t array1d_<T, C>::memsize() const
{
- return size_t(len_) * sizeof(value_t);
+ return len_ * sizeof(T);
}
- template <typename value_t, typename coord_t>
- void array1d<value_t, coord_t>::allocate_()
+ template <typename T, typename C>
+ void array1d_<T, C>::allocate_()
{
- buffer_ = new value_t[size_t(len_)];
+ buffer_ = new T[len_];
}
- template <typename value_t, typename coord_t>
- void array1d<value_t, coord_t>::deallocate_()
+ template <typename T, typename C>
+ void array1d_<T, C>::deallocate_()
{
precondition(buffer_ != 0);
delete[] buffer_;
Index: oln/core/1d/image1d.hh
--- oln/core/1d/image1d.hh (revision 865)
+++ oln/core/1d/image1d.hh (working copy)
@@ -1,5 +1,5 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
-// Development Laboratory
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 EPITA
+// Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -29,73 +29,73 @@
#ifndef OLN_CORE_1D_IMAGE1D_HH
# define OLN_CORE_1D_IMAGE1D_HH
-# include <oln/core/image_entry.hh>
-# include <oln/core/gen/grid.hh>
-# include <oln/core/internal/tracked_ptr.hh>
+# include <oln/core/internal/image_base.hh>
# include <oln/core/1d/array1d.hh>
-# include <oln/core/1d/point1d.hh>
-# include <oln/core/1d/topo1d.hh>
-// For fwd_piter and bkd_piter virtual types.
-# include <oln/core/iterator_vtypes.hh>
+# include <oln/core/1d/box1d.hh>
namespace oln
{
- // Forward declaration.
+ // Fwd decl.
template <typename T> class image1d;
- /// Virtual types associated to oln::image1d<T>.
+ /// Virtual types.
template <typename T>
struct vtypes< image1d<T> >
{
- typedef topo1d topo_type;
+ typedef point1d point;
- typedef point1d point_type;
+ typedef int coord;
+ typedef unsigned index;
- typedef mlc::false_ is_computed_type;
- typedef T value_type;
- typedef T& lvalue_type;
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box1d pset;
+ typedef array1d_<value, coord> data;
};
- /// Super type declaration.
+ /// Super type.
template <typename T>
- struct set_super_type< image1d<T> >
+ struct super_trait_< image1d<T> >
{
- typedef image1d<T> self_t;
- typedef image_entry<self_t> ret;
+ typedef image1d<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
};
/// General 1D image class.
+
template <typename T>
- class image1d : public image_entry< image1d<T> >
+ class image1d : public internal::plain_primitive_image_< image1d<T> >
{
- typedef image1d<T> self_t;
- typedef array1d<T> array_t;
-
+ typedef image1d<T> current;
+ typedef internal::plain_primitive_image_<current> super;
public:
+ stc_using(data);
- /// Ctor using sizes.
- image1d(unsigned nindices, unsigned border = 2);
+ image1d();
+ image1d(const box1d& b);
+ image1d(unsigned n);
- /// Ctor using an existing topology.
- image1d(const topo1d& topo);
+ bool impl_owns_(const point1d& p) const;
- const topo1d& impl_topo() const;
+ bool impl_has(const point1d& p) const;
- T impl_op_read(const point1d& p) const;
- T& impl_op_readwrite(const point1d& p);
+ const T& impl_read(const point1d& p) const;
+ const T& impl_index_read(unsigned i) const;
- T* adr_at(int index);
- const T* adr_at(int index) const;
+ T& impl_read_write(const point1d& p);
+ T& impl_index_read_write(unsigned i);
- private:
+ std::size_t impl_npoints() const;
- topo1d topo_;
- internal::tracked_ptr<array_t> data_;
+ box1d impl_bbox() const;
+ box1d impl_points() const;
};
@@ -103,57 +103,87 @@
# ifndef OLN_INCLUDE_ONLY
template <typename T>
- image1d<T>::image1d(unsigned nindices, unsigned border)
- : topo_(bbox1d(point1d(0), point1d(nindices - 1)), border),
- data_(new array_t(0 - border,
- nindices - 1 + border))
+ image1d<T>::image1d()
+ {
+ }
+
+ template <typename T>
+ image1d<T>::image1d(const box1d& b)
+ {
+ this->data_ = new data(b.pmin().ind(), b.pmax().ind());
+ }
+
+ template <typename T>
+ image1d<T>::image1d(unsigned n)
+ {
+ precondition(n != 0);
+ this->data_ = new data(0, n - 1);
+ }
+
+ template <typename T>
+ bool image1d<T>::impl_owns_(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->has(p.ind());
+ }
+
+ template <typename T>
+ bool image1d<T>::impl_has(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->has(p.ind());
+ }
+
+ template <typename T>
+ const T& image1d<T>::impl_read(const point1d& p) const
{
+ assert(this->has_data());
+ return this->data_->operator()(p.ind());
}
template <typename T>
- image1d<T>::image1d(const topo1d& topo)
- : topo_(topo),
- data_(new array_t(topo.bbox().pmin().index(),
- topo.bbox().pmax().index()))
+ const T& image1d<T>::impl_index_read(unsigned i) const
{
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->operator[](i);
}
template <typename T>
- const topo1d& image1d<T>::impl_topo() const
+ T& image1d<T>::impl_read_write(const point1d& p)
{
- return topo_;
+ assert(this->has_data());
+ return this->data_->operator()(p.ind());
}
template <typename T>
- T image1d<T>::impl_op_read(const point1d& p) const
+ T& image1d<T>::impl_index_read_write(unsigned i)
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.index());
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->operator[](i);
}
template <typename T>
- T& image1d<T>::impl_op_readwrite(const point1d& p)
+ std::size_t image1d<T>::impl_npoints() const
{
- precondition(data_ != 0);
- precondition(topo_.has_large(p));
- return data_->operator()(p.index());
+ // faster than the default code given by primitive_image_
+ assert(this->has_data());
+ return this->data_->ncells();
}
template <typename T>
- T* image1d<T>::adr_at(int index)
+ box1d image1d<T>::impl_bbox() const
{
- precondition(data_ != 0);
- precondition(data_->has(index));
- return &(data_->operator()(index));
+ assert(this->has_data());
+ box1d b(this->data_->imin(), this->data_->imax());
+ return b;
}
template <typename T>
- const T* image1d<T>::adr_at(int index) const
+ box1d image1d<T>::impl_points() const
{
- precondition(data_ != 0);
- precondition(data_->has(index));
- return &(data_->operator()(index));
+ return this->bbox();
}
# endif
Index: oln/core/1d/image1d_b.hh
--- oln/core/1d/image1d_b.hh (revision 0)
+++ oln/core/1d/image1d_b.hh (revision 0)
@@ -0,0 +1,210 @@
+// 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_1D_IMAGE1D_B_HH
+# define OLN_CORE_1D_IMAGE1D_B_HH
+
+# include <oln/core/internal/image_base.hh>
+# include <oln/core/internal/utils.hh>
+# include <oln/core/1d/array1d.hh>
+# include <oln/core/1d/box1d.hh>
+
+
+namespace oln
+{
+
+
+ // FIXME: Conversely to image2d_b, we use here the triplet class
+ // instead of the array_b_ class.
+
+
+ // Fwd decl.
+ template <typename T> class image1d_b;
+
+
+ /// Virtual types.
+ template <typename T>
+ struct vtypes< image1d_b<T> >
+ {
+ typedef point1d point;
+
+ typedef int coord;
+ typedef unsigned index;
+
+ typedef T value;
+ typedef const T& rvalue;
+ typedef T& lvalue;
+
+ typedef box1d pset;
+ typedef internal::triplet< array1d_<T, int>,
+ unsigned,
+ box_<point1d> > data;
+ };
+
+
+ /// Super type.
+ template <typename T>
+ struct super_trait_< image1d_b<T> >
+ {
+ typedef image1d_b<T> current;
+ typedef internal::plain_primitive_image_<current> ret;
+ };
+
+
+ /// General 1D image class.
+
+ template <typename T>
+ class image1d_b : public internal::plain_primitive_image_< image1d_b<T> >
+ {
+ typedef image1d_b<T> current;
+ typedef internal::plain_primitive_image_<current> super;
+ typedef array1d_<T, int> array_t;
+ public:
+ stc_using(data);
+
+ image1d_b();
+ image1d_b(const box1d& b, unsigned border = 2);
+ image1d_b(unsigned n, unsigned border = 2);
+
+ bool impl_owns_(const point1d& p) const;
+
+ bool impl_has(const point1d& p) const;
+
+ const T& impl_read(const point1d& p) const;
+ const T& impl_index_read(unsigned i) const;
+
+ T& impl_read_write(const point1d& p);
+ T& impl_index_read_write(unsigned i);
+
+ std::size_t impl_npoints() const;
+
+ box1d impl_bbox() const;
+ box1d impl_points() const;
+
+ unsigned border() const;
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename T>
+ image1d_b<T>::image1d_b()
+ {
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(const box1d& b, unsigned border)
+ {
+ this->data_ = new data(array_t(b.pmin().ind() - border,
+ b.pmax().ind() + border),
+ border,
+ b);
+ }
+
+ template <typename T>
+ image1d_b<T>::image1d_b(unsigned n, unsigned border)
+ {
+ precondition(n != 0);
+ this->data_ = new data(array_t(- border,
+ n - 1 + border),
+ border,
+ box1d(0, n - 1));
+ }
+
+ template <typename T>
+ bool image1d_b<T>::impl_owns_(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1.has(p.ind());
+ }
+
+ template <typename T>
+ bool image1d_b<T>::impl_has(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value3.has(p);
+ }
+
+ template <typename T>
+ const T& image1d_b<T>::impl_read(const point1d& p) const
+ {
+ assert(this->has_data());
+ return this->data_->value1(p.ind());
+ }
+
+ template <typename T>
+ const T& image1d_b<T>::impl_index_read(unsigned i) const
+ {
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->value1[i];
+ }
+
+ template <typename T>
+ T& image1d_b<T>::impl_read_write(const point1d& p)
+ {
+ assert(this->has_data());
+ return this->data_->value1(p.ind());
+ }
+
+ template <typename T>
+ T& image1d_b<T>::impl_index_read_write(unsigned i)
+ {
+ assert(this->has_data());
+ assert(i < this->npoints());
+ return this->data_->value1[i];
+ }
+
+ template <typename T>
+ box1d image1d_b<T>::impl_bbox() const
+ {
+ assert(this->has_data());
+ return this->data_->value3;
+ }
+
+ template <typename T>
+ box1d image1d_b<T>::impl_points() const
+ {
+ assert(this->has_data());
+ return this->data_->value3;
+ }
+
+ template <typename T>
+ unsigned image1d_b<T>::border() const
+ {
+ assert(this->has_data());
+ return this->data_->value2;
+ }
+
+# endif
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_IMAGE1D_B_HH
Index: oln/core/1d/grid1d.hh
--- oln/core/1d/grid1d.hh (revision 0)
+++ oln/core/1d/grid1d.hh (revision 0)
@@ -0,0 +1,93 @@
+// 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_1D_GRID1D_HH
+# define OLN_CORE_1D_GRID1D_HH
+
+# include <mlc/int.hh>
+# include <oln/core/concept/grid.hh>
+
+
+# define OLN_ENV_1D
+
+
+
+namespace oln
+{
+
+
+ /// \{
+ /// Fwd decls.
+
+ template <typename Exact> struct Grid_1D;
+ struct grid1d;
+
+ /// \}
+
+
+ /// \{
+ /// Grid_1D.
+
+ template <typename Exact>
+ struct vtypes< Grid_1D<Exact> >
+ {
+ typedef mlc::uint_<1> dim;
+ };
+
+ template <typename Exact>
+ struct Grid_1D : public Grid<Exact>
+ {
+ protected:
+ Grid_1D() {}
+ };
+
+ /// \}
+
+
+ /// \{
+ /// Super type.
+
+ template<>
+ struct super_trait_< grid1d >
+ {
+ typedef Grid_1D< grid1d > ret;
+ };
+
+ /// \}
+
+
+
+ /// One-dimensional grid struct.
+
+ struct grid1d : public Grid_1D< grid1d >
+ {};
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_GRID1D_HH
Index: oln/core/1d/window1d.hh
--- oln/core/1d/window1d.hh (revision 865)
+++ oln/core/1d/window1d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006 EPITA Research and Development Laboratory
+// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,18 @@
#ifndef OLN_CORE_1D_WINDOW1D_HH
# define OLN_CORE_1D_WINDOW1D_HH
-// Headers required for the complete definition of oln::window1d
-// (i.e., oln::window_<dpoint1d>).
-# include <oln/core/1d/aliases.hh>
-# include <oln/core/1d/dpoint1d.hh>
# include <oln/core/gen/window.hh>
+# include <oln/core/1d/dpoint1d.hh>
+
+
+namespace oln
+{
+
+ // FIXME: window1d should be an actual type, not an alias...
+ typedef window_<dpoint1d> window1d;
+
+
+} // end of namespace oln
+
#endif // ! OLN_CORE_1D_WINDOW1D_HH
Index: oln/core/1d/box1d.hh
--- oln/core/1d/box1d.hh (revision 0)
+++ oln/core/1d/box1d.hh (revision 0)
@@ -0,0 +1,45 @@
+// 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_1D_BOX1D_HH
+# define OLN_CORE_1D_BOX1D_HH
+
+# include <oln/core/gen/box.hh>
+# include <oln/core/1d/point1d.hh>
+
+
+namespace oln
+{
+
+ // FIXME: box1d should be an actual type, not an alias...
+ typedef box_<point1d> box1d;
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_1D_BOX1D_HH
+
Index: oln/core/1d/point1d.hh
--- oln/core/1d/point1d.hh (revision 865)
+++ oln/core/1d/point1d.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,119 +29,66 @@
#ifndef OLN_CORE_1D_POINT1D_HH
# define OLN_CORE_1D_POINT1D_HH
-# include <mlc/int.hh>
-# include <oln/core/internal/point_nd.hh>
+# include <oln/core/1d/grid1d.hh>
+# include <oln/core/internal/point1d.hh>
namespace oln
{
- /// Fwd decls.
- template <unsigned D> struct grid_;
- template <typename C> struct dpoint1d_;
- template <typename C> struct point1d_;
-
-
- typedef grid_<1> grid1d;
- typedef dpoint1d_<int> dpoint1d;
- typedef point1d_<int> point1d;
-
-
-
- /* FIXME: Is this the right place for these functions (on types)?
- In particular, the function on dpoint1d should be near the
- definition of dpoint1d, not point1d's. */
- /// Specializations of functions point and dpoint :
- /// \f$(n, coord) \rightarrow type\f$ for \f$n = 1\f$.
- /// \{
- template <typename C> struct point_ <1, C> { typedef point1d_<C> ret; };
- template <typename C> struct dpoint_ <1, C> { typedef dpoint1d_<C> ret; };
- /// \}
+ struct point1d;
+ struct dpoint1d;
/// Super type.
- template<typename C>
- struct set_super_type< point1d_<C> >
+ template<>
+ struct super_trait_< point1d >
{
- typedef internal::point_nd< point1d_<C> > ret;
+ typedef internal::point1d_< point1d > ret;
};
- /// Virtual types associated to oln::point1d_<C>.
- template <typename C>
- struct vtypes< point1d_<C> >
- {
- typedef grid1d grid_type;
- typedef dpoint1d dpoint_type;
- typedef C coord_type;
- typedef mlc::uint_<1> dim_type;
-
- typedef mlc::uint_<0> index_comp_type;
+ /// Virtual types.
+ template <>
+ struct vtypes< point1d >
+ {
+ typedef grid1d grid;
+ typedef int coord;
+ typedef dpoint1d dpoint;
};
- /// General 1D point class.
- template <typename C>
- class point1d_ : public internal::point_nd< point1d_<C> >
+ /// Usual 1D point class.
+ class point1d : public internal::point1d_< point1d >
{
- typedef point1d_<C> self_t;
- typedef internal::point_nd<self_t> super_t;
-
- using super_t::v_;
-
public:
-
- /// Ctor.
- point1d_();
-
- /// Ctor.
- point1d_(C index);
-
- /// Ctor.
- point1d_(const xtd::vec<1,C>& v);
-
- /// Dtor.
- ~point1d_()
- {
- }
-
- C index() const;
- C& index();
+ /// Ctors.
+ point1d();
+ point1d(int ind);
};
# ifndef OLN_INCLUDE_ONLY
-
- template <typename C>
- point1d_<C>::point1d_()
- {
- }
-
- template <typename C>
- point1d_<C>::point1d_(C index)
- : super_t (xtd::mk_vec(index))
+ point1d::point1d()
{
}
- template <typename C>
- point1d_<C>::point1d_(const xtd::vec<1,C>& v)
- : super_t(v)
+ point1d::point1d(int ind)
{
+ this->ind() = ind;
}
- template <typename C>
- C point1d_<C>::index() const { return v_[0]; }
-
- template <typename C>
- C& point1d_<C>::index() { return v_[0]; }
-
# endif
} // end of namespace oln
+// point1d goes with dpoint1d so:
+# include <oln/core/1d/dpoint1d.hh>
+
+
#endif // ! OLN_CORE_1D_POINT1D_HH
Index: oln/core/2d/neighb2d.hh
--- oln/core/2d/neighb2d.hh (revision 865)
+++ oln/core/2d/neighb2d.hh (working copy)
@@ -31,13 +31,13 @@
# include <oln/core/gen/neighb.hh>
# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: neighb2d should be an actual type, not an alias...
+ typedef neighb_<dpoint2d> neighb2d;
namespace internal
Index: oln/core/2d/window2d.hh
--- oln/core/2d/window2d.hh (revision 865)
+++ oln/core/2d/window2d.hh (working copy)
@@ -30,13 +30,13 @@
# include <oln/core/gen/window.hh>
# include <oln/core/2d/dpoint2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: window2d should be an actual type, not an alias...
+ typedef window_<dpoint2d> window2d;
window2d mk_square(unsigned odd_len);
Index: oln/core/2d/box2d.hh
--- oln/core/2d/box2d.hh (revision 865)
+++ oln/core/2d/box2d.hh (working copy)
@@ -30,13 +30,13 @@
# include <oln/core/gen/box.hh>
# include <oln/core/2d/point2d.hh>
-# include <oln/core/2d/aliases.hh>
namespace oln
{
// FIXME: box2d should be an actual type, not an alias...
+ typedef box_<point2d> box2d;
} // end of namespace oln
Index: oln/core/internal/dpoint1d.hh
--- oln/core/internal/dpoint1d.hh (revision 0)
+++ oln/core/internal/dpoint1d.hh (revision 0)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_DPOINT1D_HH
+# define OLN_CORE_INTERNAL_DPOINT1D_HH
+
+# include <oln/core/internal/dpoint_base.hh>
+
+
+namespace oln
+{
+
+
+ /// Fwd decls.
+ namespace internal { template <typename Exact> struct dpoint1d_; }
+
+
+ /// Super type.
+ template<typename Exact>
+ struct super_trait_< internal::dpoint1d_<Exact> >
+ {
+ typedef internal::dpoint_base_<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::dpoint1d_<Exact> >
+ {
+ };
+
+
+ namespace internal
+ {
+
+
+ template <typename Exact>
+ class dpoint1d_ : public dpoint_base_<Exact>
+ {
+ typedef dpoint_base_<Exact> super;
+
+ public:
+ stc_using(coord);
+
+ coord ind() const;
+ coord& ind();
+
+ protected:
+ dpoint1d_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ dpoint1d_<Exact>::dpoint1d_()
+ {
+ }
+
+ template <typename Exact>
+ typename dpoint1d_<Exact>::coord
+ dpoint1d_<Exact>::ind() const
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename dpoint1d_<Exact>::coord &
+ dpoint1d_<Exact>::ind()
+ {
+ return this->v_[0];
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_DPOINT1D_HH
Index: oln/core/internal/utils.hh
--- oln/core/internal/utils.hh (revision 865)
+++ oln/core/internal/utils.hh (working copy)
@@ -42,8 +42,8 @@
{
singleton()
{}
- singleton(T val)
- : value(val)
+ singleton(T value)
+ : value(value)
{}
T value;
};
@@ -56,15 +56,53 @@
{
pair()
{}
- pair(T1 val1, T2 val2)
- : value1(val1),
- value2(val2)
+ pair(T1 value1, T2 value2)
+ : value1(value1),
+ value2(value2)
{}
T1 value1;
T2 value2;
};
+ /// Simple triplet class.
+
+ template <typename T1, typename T2, typename T3>
+ struct triplet
+ {
+ triplet()
+ {}
+ triplet(T1 value1, T2 value2, T3 value3)
+ : value1(value1),
+ value2(value2),
+ value3(value3)
+ {}
+ T1 value1;
+ T2 value2;
+ T3 value3;
+ };
+
+
+ /// Simple quartet class.
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ struct quartet
+ {
+ quartet()
+ {}
+ quartet(T1 value1, T2 value2, T3 value3, T4 value4)
+ : value1(value1),
+ value2(value2),
+ value3(value3),
+ value4(value4)
+ {}
+ T1 value1;
+ T2 value2;
+ T3 value3;
+ T4 value4;
+ };
+
+
} // end of namespace oln::internal
} // end of namespace oln
Index: oln/core/internal/point1d.hh
--- oln/core/internal/point1d.hh (revision 0)
+++ oln/core/internal/point1d.hh (revision 0)
@@ -0,0 +1,108 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+#ifndef OLN_CORE_INTERNAL_POINT1D_HH
+# define OLN_CORE_INTERNAL_POINT1D_HH
+
+# include <oln/core/internal/point_base.hh>
+
+
+namespace oln
+{
+
+
+ /// Fwd decls.
+ namespace internal { template <typename Exact> struct point1d_; }
+
+
+ /// Super type.
+ template<typename Exact>
+ struct super_trait_< internal::point1d_<Exact> >
+ {
+ typedef internal::point_base_<Exact> ret;
+ };
+
+
+ /// Virtual types.
+ template <typename Exact>
+ struct vtypes< internal::point1d_<Exact> >
+ {
+ };
+
+
+ namespace internal
+ {
+
+
+ template <typename Exact>
+ class point1d_ : public point_base_<Exact>
+ {
+ typedef point_base_<Exact> super;
+
+ public:
+ stc_using(coord);
+
+ coord ind() const;
+ coord& ind();
+
+ protected:
+ point1d_();
+ };
+
+
+
+# ifndef OLN_INCLUDE_ONLY
+
+ template <typename Exact>
+ point1d_<Exact>::point1d_()
+ {
+ }
+
+ template <typename Exact>
+ typename point1d_<Exact>::coord
+ point1d_<Exact>::ind() const
+ {
+ return this->v_[0];
+ }
+
+ template <typename Exact>
+ typename point1d_<Exact>::coord &
+ point1d_<Exact>::ind()
+ {
+ return this->v_[0];
+ }
+
+# endif
+
+
+ } // end of namespace oln::internal
+
+
+} // end of namespace oln
+
+
+#endif // ! OLN_CORE_INTERNAL_POINT1D_HH
Index: oln/core/internal/point2d.hh
--- oln/core/internal/point2d.hh (revision 865)
+++ oln/core/internal/point2d.hh (working copy)
@@ -37,7 +37,6 @@
/// Fwd decls.
- template <unsigned D> struct grid_;
namespace internal { template <typename Exact> struct point2d_; }
1
0