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
- 9625 discussions
Index: static/ChangeLog
===================================================================
--- static/ChangeLog (révision 723)
+++ static/ChangeLog (révision 724)
@@ -109,7 +109,7 @@
2006-11-14 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Simplify scoop facilities.
-
+
* stc/scoop.hh: Rename as...
* stc/was.scoop.hh: ...this new file.
* stc/scoop.hh: New version.
@@ -178,7 +178,7 @@
2006-09-27 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Enforce safety in some SCOOP tools.
-
+
* stc/scoop.hh (stc_set_nth_super, stc_set_super): Add
"end of semicolon" safety.
(stc_virtual_typedef): Use oln_check_type_of instead of
@@ -304,7 +304,7 @@
2006-09-06 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
New macro to declare virtual types in abstract classes.
-
+
* stc/vtypes.hh (stc_virtual_typedef): New.
2006-09-04 Roland Levillain <roland(a)lrde.epita.fr>
@@ -313,7 +313,7 @@
* stc/vtypes.hh (vtypes, single_vtype, ext_vtype): Rename as...
(vtypes_in_category, single_vtype_in_category, ext_vtype_in_category):
- ...this.
+ ...this.
(vtypes_, single_vtype_, ext_vtype_): Rename as...
(vtypes, single_vtype, ext_vtype): ...this.
(packed_vtypes): Rename as...
@@ -329,7 +329,7 @@
recursions when their definitions involve the knowledge of the
exact type of the class these virtual types belong to.
- * static/stc/vtypes.hh (single_vtype, single_vtype_): New template
+ * stc/vtypes.hh (single_vtype, single_vtype_): New template
class.
(internal::tag::single): New.
(internal::tag::external): Rename as...
@@ -340,18 +340,18 @@
Check the return type of the algorithm.
More documentation.
s/external/extended/.
- * static/tests/vtypes.cc: Conform to the new terminology.
- * static/tests/vtypes-multiple-supers.cc: Adjust.
+ * tests/vtypes.cc: Conform to the new terminology.
+ * tests/vtypes-multiple-supers.cc: Adjust.
* tests/vtypes-and-exact.cc: Likewise.
Aesthetic changes.
(main): Exercize stc::is_any_.
- * static/stc/valist_aggregator.hh (valist_aggregator): Use virtual
+ * stc/valist_aggregator.hh (valist_aggregator): Use virtual
inheritance.
2006-09-01 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add materials to handle types without category.
-
+
* stc/vtypes.hh (stc_equip_namespace_with_vtypes): Add
ext_vtype_ and packed_vtypes_ for types without category.
(ext_vtype, packed_vtypes): Add specializations for
@@ -360,13 +360,13 @@
2006-08-30 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Fix missing typedefs and handle types without category.
-
+
* stc/any.hh (any__best_speed): Add typedef exact_type.
(any__best_memory): Likewise.
* stc/vtypes.hh (stc_equip_namespace_with_vtypes): Add 'vtypes_'
and the specialization 'vtypes<void, from_type>' for definitions
of associated types from types that do not have any category.
-
+
2006-06-15 Roland Levillain <roland(a)lrde.epita.fr>
Document method checks in Static tour.
@@ -406,8 +406,8 @@
* tests/tour.cc (static_hierarchy_with_any): More on the retrieval
of and the conversion to the exact type.
(main): Run dynamic tests.
- (static_hierarchy_with_any::A)
- (static_hierarchy_with_a_non_leaf_concrete_class::A)
+ (static_hierarchy_with_any::A)
+ (static_hierarchy_with_a_non_leaf_concrete_class::A)
(static_hierarchy_with_methods::A): Use stc::any instead of
stc::any__simple.
Index: olena/ChangeLog
===================================================================
--- olena/ChangeLog (révision 723)
+++ olena/ChangeLog (révision 724)
@@ -23,7 +23,7 @@
[!OLENA_USE_NEW_SCOOP2]: Define it.
(single_vtype<abstract::iterator_on_points<E>, typedef_::coord_type>)
[OLENA_USE_NEW_SCOOP2]: Define it.
- * oln/core/abstract/point.hh (oln, oln):
+ * oln/core/abstract/point.hh (oln, oln):
(vtypes< abstract::point<E> >::coord_type)
(vtypes< abstract::point<E> >::vec_type)
[!OLENA_USE_NEW_SCOOP2]: Define them.
@@ -136,9 +136,10 @@
2006-12-04 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Propagate scoop update to oln.
-
+
* oln/core/macros.hh
- (oln_type_of_, oln_type_of, oln_deduce_type_of): Update and rename as...
+ (oln_type_of_, oln_type_of, oln_deduce_type_of): Update and rename
+ as...
(oln_vtype_, oln_vtype, oln_deduce_vtype): ...these.
(oln_deferred_vtype, oln_deduce_deferred_vtype): New.
(oln_find_vtype, oln_find_deferred_vtype): New.
@@ -154,13 +155,17 @@
* oln/core/typedefs.hh: Likewise.
* oln/core/automatic/impl.hh: Likewise.
* oln/core/automatic/image/image.hh: Likewise.
- * oln/core/automatic/image/image_being_point_wise_random_accessible.hh: Likewise.
+ * oln/core/automatic/image/image_being_point_wise_random_accessible.hh:
+ Likewise.
* oln/core/automatic/image/image_having_neighborhood.hh: Likewise.
- * oln/core/automatic/image/image_being_value_wise_random_accessible.hh: Likewise.
+ * oln/core/automatic/image/image_being_value_wise_random_accessible.hh:
+ Likewise.
* oln/core/automatic/topology/topology_having_bbox.hh: Likewise.
* oln/core/automatic/topology/topology_having_subset.hh: Likewise.
- * oln/core/automatic/topology/topology_being_random_accessible.hh: Likewise.
- * oln/core/automatic/topology/topology_having_neighborhood.hh: Likewise.
+ * oln/core/automatic/topology/topology_being_random_accessible.hh:
+ Likewise.
+ * oln/core/automatic/topology/topology_having_neighborhood.hh:
+ Likewise.
* oln/core/spe/row.hh: Likewise.
* oln/core/spe/col.hh: Likewise.
* oln/core/spe/slice.hh: Likewise.
@@ -173,13 +178,16 @@
* oln/core/abstract/image/dimension/1d.hh: Likewise.
* oln/core/abstract/image/dimension/2d.hh: Likewise.
* oln/core/abstract/image/dimension/3d.hh: Likewise.
- * oln/core/abstract/image/point_wise_accessibility/hierarchy.hh: Likewise.
- * oln/core/abstract/point_set/point_set_being_random_accessible.hh: Likewise.
+ * oln/core/abstract/image/point_wise_accessibility/hierarchy.hh:
+ Likewise.
+ * oln/core/abstract/point_set/point_set_being_random_accessible.hh:
+ Likewise.
* oln/core/abstract/point_set/point_set_having_known_size.hh: Likewise.
* oln/core/abstract/point_set/point_set_being_connected.hh: Likewise.
* oln/core/abstract/point_set/point_set_having_bbox.hh: Likewise.
* oln/core/abstract/topology/topology_having_bbox.hh: Likewise.
- * oln/core/abstract/topology/topology_being_random_accessible.hh: Likewise.
+ * oln/core/abstract/topology/topology_being_random_accessible.hh:
+ Likewise.
* oln/core/abstract/topology/topology_having_subset.hh: Likewise.
* oln/core/abstract/topology/topology_having_neighborhood.hh: Likewise.
* oln/core/abstract/internal/image_impl.hh: Likewise.
@@ -216,7 +224,7 @@
- stc::abstract instead of mlc::undefined;
- stc::final when possible;
- 'deferred' versions of vtype access when required.
-
+
* oln/core/point_set_entry.hh: Update.
(set_super_type): New.
(vtypes): Update.
@@ -233,19 +241,20 @@
* oln/core/abstract/window.hh: Likewise.
Remove obsolete definitions of now final vtypes.
-
+
* tests/core/image_entry.cc: Update.
* oln/core/1d/image1d.hh: Likewise.
* oln/core/2d/image2d.hh: Likewise.
* oln/core/3d/image3d.hh: Likewise.
-
+
Update tests with the 'find' version of vtype access.
-
+
* oln/core/abstract/image/mutability/hierarchy.hh: Update.
* oln/core/abstract/image/dimension/hierarchy.hh: Likewise.
* oln/core/abstract/image/neighborhood/hierarchy.hh: Likewise.
* oln/core/abstract/image/bbox/hierarchy.hh: Likewise.
- * oln/core/abstract/image/value_wise_accessibility/hierarchy.hh: Likewise.
+ * oln/core/abstract/image/value_wise_accessibility/hierarchy.hh:
+ Likewise.
Update from 'delegated' to 'delegatee'.
@@ -257,7 +266,7 @@
* oln/core/typedefs.hh (delegated_type): Add commentary.
Misc.
-
+
* tests/core/at.cc: Cosmetic change.
* oln/core/gen/bbox.hh (vtypes): Fix typo.
* oln/core/gen/pset_list.hh: Likewise.
@@ -299,12 +308,12 @@
(oln::vtypes< internal::point_nd<E> >::vec_type): Fix typedef.
* oln/core/internal/point_nd.hh
(oln::vtypes< internal::point_nd<E> >::vec_t): Remove typedef.
- (oln::vtypes< internal::point_nd<E> >::vec_type): Fix typedef.
+ (oln::vtypes< internal::point_nd<E> >::vec_type): Fix typedef.
2006-11-14 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Now call simplified scoop macros.
-
+
* oln/core/macros.hh
(oln_deduce_direct_type_of_, oln_deduce_direct_type_of): Remove.
(oln_check_type_of, oln_check_type_of_): Remove.
@@ -312,14 +321,14 @@
(oln_deduce): New; shortcut to oln_deduce_type_of.
Add missing shortcuts.
-
+
* oln/core/typedefs.hh (oln_dim, oln_dim_): New.
(oln_vec, oln_vec_): New.
(oln_bbox, oln_bbox_): New.
(include): Fix and add fwd decls.
Move single_vtype definitions into vtypes structures.
-
+
* oln/core/point_set_entry.hh: Update.
(single_vtype): Move into...
(vtypes): ...this.
@@ -341,10 +350,10 @@
* oln/morpher/thru_mfun.hh: Likewise.
* oln/morpher/stack_rw.hh: Likewise.
* oln/morpher/internal/image_value_morpher.hh: Likewise.
-
+
Prevent problems due to mutual recursion (thru inheritance
and dependent types).
-
+
* oln/core/abstract/image.hh (decl): Disable static checks.
* oln/core/abstract/image/bbox/hierarchy.hh: Update.
(decl): Disable static check.
@@ -354,13 +363,13 @@
Disable static check.
* oln/core/gen/bkd_piter_bbox.hh: Update.
Disable static check.
-
+
For safety purpose.
-
+
* oln/basics2d.hh (include): Move iterator_vtypes up.
Decouple some files from specific code.
-
+
* oln/core/automatic/image/mutable_image1d.hh
(include): Remove dependency to specific point header.
(tmp): Update.
@@ -385,7 +394,7 @@
* tests/core/dpoint2d.cc: Likewise.
Update.
-
+
* tests/morphers/with_lut.cc: Cosmetics.
* tests/core/image_entry.cc: Update.
* oln/io/pnm.hh: Use shortcuts.
@@ -457,7 +466,7 @@
Introduce oln::value::lut_value_proxy.
- * olena/oln/value/lut_value_proxy.hh: New.
+ * oln/value/lut_value_proxy.hh: New.
* oln/core/typedefs.hh (mutable_fwd_viter_type): Remove virtual
type declaration.
(value_proxy_type, mutable_value_proxy_type): New virtual types
@@ -495,7 +504,7 @@
Remove oln::mutable_fwd_viter_lut and clean up oln::fwd_viter_lut.
- * olena/oln/core/abstract/iterator_on_values.hh: New.
+ * oln/core/abstract/iterator_on_values.hh: New.
* oln/core/internal/fwd_viter_lut.hh:
(oln::internal::fwd_viter_lut<Exact>): Inherit from
oln::abstract::iterator_on_values<Exact>.
@@ -536,7 +545,7 @@
2006-11-07 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add point-set types based on std containers.
-
+
* oln/core/gen/piter_on_std_based_pset.hh: New.
* oln/core/gen/pset_list.hh: New.
* oln/core/gen/pset_vec.hh: New.
@@ -561,11 +570,11 @@
* oln/core/abstract/functions.hh (fun_rw): Update.
* oln/morpher/count_rw.hh (count_rw): Move impl into guards.
* oln/morpher/stack_rw.hh (include): Update.
-
+
2006-11-06 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add morpher::stack_rw.
-
+
* tests/morphers/stack_rw_morpher.cc: New.
* tests/morphers/Makefile.am: Update.
* oln/morpher/stack_rw.hh: New.
@@ -669,7 +678,7 @@
...this.
* oln/value/proxy.hh: Fix header guards.
(oln/core/typedefs.hh): Include it.
- * oln/Makefile.am (nobase_oln_HEADERS): Add
+ * oln/Makefile.am (nobase_oln_HEADERS): Add
core/abstract/image/computability/hierarchy.hh,
core/abstract/image/value_wise_accessibility/hierarchy.hh,
core/automatic/image/image_being_value_wise_random_accessible.hh,
@@ -745,13 +754,13 @@
2006-10-25 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Oops.
-
+
* oln/value/two_way.hh: New.
2006-10-25 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Tiny fix just before pastis.
-
+
* oln/basics1d.hh (include): Add missing headers.
* oln/basics2d.hh: Likewise.
* oln/basics3d.hh: Likewise.
@@ -759,7 +768,7 @@
2006-10-25 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add two-way morpher.
-
+
* tests/morphers/two_way_morpher.cc: New.
* tests/morphers/Makefile.am: Update.
* oln/morpher/two_way.hh: New.
@@ -772,7 +781,7 @@
2006-10-25 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add oln::level::apply_inplace.
-
+
* tests/level/apply_inplace.cc: New.
* oln/level/assign.hh: Typo.
* oln/level/apply.hh (apply_inplace): New.
@@ -782,7 +791,7 @@
2006-10-25 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add oln abstract functions + move slice vtype definitions.
-
+
* oln/level/assign.hh: New.
* oln/level/apply.hh: New.
* oln/level/clone.hh: New.
@@ -801,7 +810,7 @@
2006-10-25 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Introduce ids for images and better oln::morpher::count_rw_.
-
+
* tests/morphers/count_rw_morpher.cc: Add sample code in comments.
* oln/core/abstract/iterator_on_points.hh (operator<<): New.
* oln/core/abstract/image.hh (image, operator=): New.
@@ -827,7 +836,7 @@
2006-10-24 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add point-wise values.
-
+
* tests/core/pw_value.cc: New.
* tests/core/Makefile.am: Update.
* oln/core/gen/pw_value.hh: New.
@@ -836,7 +845,7 @@
2006-10-24 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add a morpher to count read-write ops.
-
+
* tests/morphers/count_rw_morpher.cc: New.
* tests/morphers/Makefile.am: Update.
* oln/morpher/count_rw.hh: New.
@@ -850,7 +859,7 @@
* oln/morpher/internal/image_value_morpher.hh
(image_value_morpher): New overloading for ctor.
(image_): Add & to its type.
-
+
2006-10-24 Roland Levillain <roland(a)lrde.epita.fr>
Add a morpher adding a look-up table to an image.
@@ -889,14 +898,14 @@
Fix debug track and disambiguate the 'at' method overloading
in const and mutable nD images.
-
+
* oln/core/abstract/array.hh: New.
* oln/debug/track.hh (n_arrays): New.
(include): Fix.
* oln/core/abstract/image.hh (image): New cpy ctor so fix
n_images tracking.
* oln/core/abstract/image/dimension/1d.hh: Disambiguate by
- changing inheritance to virtual + inserting a using directive.
+ changing inheritance to virtual + inserting a using directive.
* oln/core/abstract/image/dimension/2d.hh: Likewise.
* oln/core/abstract/image/dimension/3d.hh: Likewise.
* oln/core/1d/array1d.hh (array1d): Add inheritance.
@@ -908,7 +917,7 @@
Add stack morpher and remove the hack related to indexed mutable
access.
-
+
* tests/morphers/stack_morpher.cc: New.
* tests/morphers/Makefile.am: Update.
* oln/debug/track.hh: New.
@@ -991,7 +1000,7 @@
2006-10-20 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add morpher based on mutators.
-
+
* tests/value/accessor.cc: New.
* tests/value/Makefile.am: Update.
* oln/morpher/thru_mfun.hh: New.
@@ -1041,7 +1050,7 @@
* oln/Makefile.am (nobase_oln_HEADERS): Add
core/1d/topo1d.hh, core/2d/topo2d.hh, core/3d/topo3d.hh,
core/gen/piter_isubset.hh, core/type_fun/slice_piter.hh and
- morpher/slice.hh.
+ morpher/slice.hh.
* tests/morphers/slice_morpher.cc: New test.
* tests/morphers/Makefile.am (check_PROGRAMS): Add slice_morpher.
(slice_morpher_SOURCES): New.
@@ -1061,7 +1070,7 @@
2006-10-17 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add forward declaration files.
-
+
* oln/core/aliases.hh: New.
* oln/core/fwd_decls.hh: New.
* oln/core/1d/fwd_decls.hh: New.
@@ -1071,7 +1080,7 @@
* oln/morpher/fwd_decls.hh: New.
* oln/debug/typename.hh: New.
* oln/Makefile.am: Update.
-
+
Sketch the mechanism for 'plain' and 'ch_value'.
* oln/core/type_fun/plain.hh: New.
@@ -1127,7 +1136,7 @@
2006-10-17 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Replace the 'is_mutable' property by checking the 'lvalue' type.
-
+
* oln/core/automatic/image/image_being_mutable.hh: Rename as...
* oln/core/automatic/image/mutable_image.hh: ...this.
(image_being_mutable): Rename as...
@@ -1150,7 +1159,7 @@
2006-10-17 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add computability image hierarchy.
-
+
* oln/core/abstract/image/computability: New.
* oln/core/abstract/image/computability/hierarchy.hh: New.
* oln/core/typedefs.hh (is_computed_type): New.
@@ -1172,7 +1181,7 @@
2006-10-17 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Adjust lvalue so that it handles a '&' when needed.
-
+
* oln/core/automatic/image/image1d.hh (impl_at): Adjust.
* oln/core/automatic/image/image2d.hh: Likewise.
* oln/core/automatic/image/image3d.hh: Likewise.
@@ -1217,7 +1226,7 @@
2006-10-16 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add value cast image morpher.
-
+
* tests/value_cast.cc: New.
* tests/Makefile.am: Update.
* oln/morpher/value_cast.hh: New.
@@ -1228,7 +1237,7 @@
2006-10-16 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add binary value type plus update image hierarchy plugs.
-
+
* oln/value/tags.hh: New.
* oln/value/bin.hh: New.
* oln/value/all.hh: New.
@@ -1239,11 +1248,11 @@
* oln/value/greylevel.hh (greylevel_): New conversion operator.
(gl1): Remove; now replaced by value::bin.
* oln/Makefile.am: Update.
-
+
2006-10-16 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add grey-level types.
-
+
* tests/grey.cc: New.
* tests/Makefile.am: Update.
* oln/value/default.hh: New.
@@ -1451,7 +1460,7 @@
2006-10-12 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
Add image accessors with indices.
-
+
* tests/at.cc: New.
* oln/core/automatic/image1d.hh: New.
* oln/core/automatic/image2d.hh: New.
@@ -1459,7 +1468,7 @@
* tests/Makefile.am (check_PROGRAMS): Add 'at'.
Move io_pnm to get consistent with SOURCES list.
(at_SOURCES): New.
- * oln/core/typedefs.hh (oln_psite, oln_psite_): New.
+ * oln/core/typedefs.hh (oln_psite, oln_psite_): New.
* oln/core/automatic/image_being_mutable.hh
(lvalue_t, psite_t): Remove; use oln_lvalue and oln_psite instead.
(impl_op_readwrite): Update sig.
1
0
723: Add temporary helpers to support the new SCOOP 2 implementation.
by Roland Levillain 26 Jan '07
by Roland Levillain 26 Jan '07
26 Jan '07
https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Add temporary helpers to support the new SCOOP 2 implementation.
The macro OLENA_USE_NEW_SCOOP2 is used to tag the places where
support code is introduced.
* oln/core/typedefs.hh (stc/scoop2.hh) [OLENA_USE_NEW_SCOOP2]:
Include it.
(stc/scoop.hh) [!OLENA_USE_NEW_SCOOP2]: Include it.
Invoke stc_scoop_equipment_for_namespace(oln).
Temporary hack: define deferred virtual types as single_vtypes
when using new SCOOP 2 implementation.
* oln/core/image_entry.hh
(vtypes< image_entry<E> >::rvalue_type)
[!OLENA_USE_NEW_SCOOP2]: Define it.
(single_vtype<image_entry<E>, typedef_::rvalue_type>
[!OLENA_USE_NEW_SCOOP2]: Define it.
* oln/core/abstract/iterator_on_points.hh
(vtypes< abstract::iterator_on_points<E> >)
[!OLENA_USE_NEW_SCOOP2]: Define it.
(single_vtype<abstract::iterator_on_points<E>, typedef_::coord_type>)
[OLENA_USE_NEW_SCOOP2]: Define it.
* oln/core/abstract/point.hh (oln, oln):
(vtypes< abstract::point<E> >::coord_type)
(vtypes< abstract::point<E> >::vec_type)
[!OLENA_USE_NEW_SCOOP2]: Define them.
(single_vtype< abstract::point<E>, typedef_::coord_type>)
(single_vtype< abstract::point<E>, typedef_::vec_type>)
[OLENA_USE_NEW_SCOOP2]: Define them.
* oln/core/internal/point_nd.hh (vtypes< internal::point_nd<E> >):
Disable it (duplicate with vtypes< abstract::point<E> >).
* oln/core/internal/dpoint_nd.hh
(vtypes< internal::dpoint_nd<E> >::vec_type)
[!OLENA_USE_NEW_SCOOP2]: Define it.
(single_vtype< internal::dpoint_nd<E>, typedef_::vec_type >)
[OLENA_USE_NEW_SCOOP2]: Define it.
Fix the usage of stc::not_found and stc::is_found_.
* oln/core/abstract/image/dimension/hierarchy.hh
(case_<image_hierarchy_wrt_dimension, E, 1>)
(case_<image_hierarchy_wrt_dimension, E, 3>)
(case_<image_hierarchy_wrt_dimension, E, 5>)
[OLENA_USE_NEW_SCOOP2]: Use stc::is_found_ to check for the
existence of an lvalue.
[!OLENA_USE_NEW_SCOOP2]: Use mlc::is_found_ to check for the
existence of an lvalue.
* oln/core/abstract/image/mutability/hierarchy.hh
(case_<image_hierarchy_wrt_mutability, E, 1>)
[OLENA_USE_NEW_SCOOP2]: Use stc::is_found_ to check for the
existence of an lvalue.
[!OLENA_USE_NEW_SCOOP2]: Use mlc::is_found_ to check for the
existence of an lvalue.
* oln/core/abstract/image/bbox/hierarchy.hh
(case_<image_hierarchy_wrt_bbox, E, 1>)
[OLENA_USE_NEW_SCOOP2]: Use stc::is_found_ to check for the
existence of a bounding box.
[!OLENA_USE_NEW_SCOOP2]: Use mlc::is_found_ to check for the
existence of a bounding box.
* oln/core/abstract/image/hybrid/classical.hh
(case_<image_hybrid_hierarchy_wrt_classical, E, 1>)
(case_<image_hybrid_hierarchy_wrt_classical, E, 2>)
(case_<image_hybrid_hierarchy_wrt_classical, E, 3>)
(case_<image_hybrid_hierarchy_wrt_classical, E, 4>)
[OLENA_USE_NEW_SCOOP2]: Use stc::not_found to check for the
existence of a bounding box.
(case_<image_hybrid_hierarchy_wrt_classical, E, 1>)
(case_<image_hybrid_hierarchy_wrt_classical, E, 2>)
(case_<image_hybrid_hierarchy_wrt_classical, E, 3>)
(case_<image_hybrid_hierarchy_wrt_classical, E, 4>)
[!OLENA_USE_NEW_SCOOP2]: Use mlc::not_found to check for the
existence of a bounding box.
* oln/core/abstract/image/value_wise_accessibility/hierarchy.hh
(case_<image_hierarchy_wrt_value_wise_accessibility, E, 1>):
(case_<image_hierarchy_wrt_value_wise_accessibility, E, 2>):
[OLENA_USE_NEW_SCOOP2]: Use stc::is_found_ to check for the
existence of a value iterator (and a value proxy).
[!OLENA_USE_NEW_SCOOP2]: Use mlc::is_found_ to check for the
existence of a value iterator (and a value proxy).
* oln/core/abstract/image/neighborhood/hierarchy.hh
(case_<image_hierarchy_wrt_neighborhood, E, 1>)
[OLENA_USE_NEW_SCOOP2]: Use stc::is_found_ to check for the
existence of a neighborhood.
[!OLENA_USE_NEW_SCOOP2]: Use mlc::is_found_ to check for the
existence of a neighborhood.
* oln/core/abstract/grid.hh (set_super_type<abstract::grid<E>>):
New. Fix abstract::grid not having a super type.
* oln/morpher/thru_mfun.hxx: Move all implementations of methods
into...
(oln::morpher): ...this namespace.
* oln/core/gen/fwd_viter_lut.hh, oln/core/gen/bkd_viter_lut.hh,
* oln/core/gen/topo_bbox.hh, oln/core/gen/topo_lbbox.hh,
* oln/core/gen/topo_add_isubset.hh, oln/core/gen/topo_add_nbh.hh,
* oln/core/internal/bbox_fwd_piter.hh: Fix comments.
* oln/core/2d/point2d.hh (oln): Aesthetic changes.
* tests/core/point2d.cc: Fix inter-dependent headers.
* tests/core/dpoint2d.cc: Add a static assertion.
* tests/algorithms/fill.cc:
s/oln_type_of_(image_t, piter)/oln_piter_(image_t)/
oln/core/2d/point2d.hh | 1
oln/core/abstract/grid.hh | 7 +
oln/core/abstract/image/bbox/hierarchy.hh | 5 +
oln/core/abstract/image/dimension/hierarchy.hh | 30 +++++-
oln/core/abstract/image/hybrid/classical.hh | 44 +++++++---
oln/core/abstract/image/mutability/hierarchy.hh | 4
oln/core/abstract/image/neighborhood/hierarchy.hh | 5 +
oln/core/abstract/image/value_wise_accessibility/hierarchy.hh | 19 +++-
oln/core/abstract/iterator_on_points.hh | 11 ++
oln/core/abstract/point.hh | 22 +++++
oln/core/gen/bkd_viter_lut.hh | 2
oln/core/gen/fwd_viter_lut.hh | 2
oln/core/gen/topo_add_isubset.hh | 6 -
oln/core/gen/topo_add_nbh.hh | 6 -
oln/core/gen/topo_bbox.hh | 4
oln/core/gen/topo_lbbox.hh | 4
oln/core/image_entry.hh | 9 ++
oln/core/internal/bbox_fwd_piter.hh | 2
oln/core/internal/dpoint_nd.hh | 17 +++
oln/core/internal/point_nd.hh | 21 ++--
oln/core/typedefs.hh | 6 +
oln/morpher/thru_mfun.hxx | 5 +
tests/algorithms/fill.cc | 2
tests/core/dpoint2d.cc | 3
tests/core/point2d.cc | 3
25 files changed, 193 insertions(+), 47 deletions(-)
Index: tests/core/point2d.cc
--- tests/core/point2d.cc (revision 722)
+++ tests/core/point2d.cc (working copy)
@@ -27,7 +27,10 @@
#include <mlc/assert.hh>
#include <mlc/is_a.hh>
+// FIXME: There is an inter-dependency between point2d and dpoint2d.
+// Maybe we'll solve this with the interface/implementation separation?
#include <oln/core/2d/point2d.hh>
+#include <oln/core/2d/dpoint2d.hh>
int
Index: tests/core/dpoint2d.cc
--- tests/core/dpoint2d.cc (revision 722)
+++ tests/core/dpoint2d.cc (working copy)
@@ -39,4 +39,7 @@
mlc::assert_<
mlc_is_a_( dpoint_t, oln::internal::dpoint_nd )
>::check();
+
+ typedef oln_vtype_(dpoint_t, vec) vec_t;
+ mlc::assert_< mlc_is_a_( vec_t, mlc_comma_1(xtd::vec< 2u, int >) ) >::check();
}
Index: tests/algorithms/fill.cc
--- tests/algorithms/fill.cc (revision 722)
+++ tests/algorithms/fill.cc (working copy)
@@ -40,7 +40,7 @@
typedef oln::image2d<int> image_t;
image_t ima(3, 3);
oln::level::fill(ima, 51);
- oln_type_of_(image_t, piter) p(ima.topo());
+ oln_piter_(image_t) p(ima.topo());
for_all(p)
assert(ima(p) == 51);
}
Index: oln/core/typedefs.hh
--- oln/core/typedefs.hh (revision 722)
+++ oln/core/typedefs.hh (working copy)
@@ -41,7 +41,11 @@
# include <stc/any.hh>
# include <stc/exact.hh>
+# ifdef OLENA_USE_NEW_SCOOP2
+# include <stc/scoop2.hh>
+# else
# include <stc/scoop.hh>
+# endif // OLENA_USE_NEW_SCOOP2
# include <oln/core/type.hh>
// FIXME: Move to oln/core.
@@ -52,9 +56,11 @@
| Namespace equipment. |
`----------------------*/
+# ifndef OLENA_USE_NEW_SCOOP2
// The virtual types facility is inserted here because it also
// triggers Metalic's typedef introspection equipment.
stc_scoop_equipment_for_namespace(oln);
+# endif // !OLENA_USE_NEW_SCOOP2
namespace oln
Index: oln/core/image_entry.hh
--- oln/core/image_entry.hh (revision 722)
+++ oln/core/image_entry.hh (working copy)
@@ -71,7 +71,9 @@
// FIXME: default definitions:
typedef oln_point(E) psite_type;
+# ifndef OLENA_USE_NEW_SCOOP2
typedef oln_value(E) rvalue_type;
+# endif // !OLENA_USE_NEW_SCOOP2
/// \brief Morpher type.
///
@@ -79,6 +81,13 @@
typedef mlc::none morpher_type;
};
+# ifdef OLENA_USE_NEW_SCOOP2
+ template <typename E>
+ struct single_vtype< image_entry<E>, typedef_::rvalue_type >
+ {
+ typedef oln_value(E) ret;
+ };
+# endif // OLENA_USE_NEW_SCOOP2
/// Entry class for point sets: image_entry<E> is an alias for
Index: oln/core/abstract/iterator_on_points.hh
--- oln/core/abstract/iterator_on_points.hh (revision 722)
+++ oln/core/abstract/iterator_on_points.hh (working copy)
@@ -54,9 +54,20 @@
struct vtypes< abstract::iterator_on_points<E> >
{
typedef stc::abstract point_type;
+# ifndef OLENA_USE_NEW_SCOOP2
typedef oln_deduce_deferred_vtype(E, point, coord) coord_type;
+# endif // !OLENA_USE_NEW_SCOOP2
};
+# ifdef OLENA_USE_NEW_SCOOP2
+ template <typename E>
+ struct single_vtype< abstract::iterator_on_points<E>,
+ typedef_::coord_type >
+ {
+ typedef oln_deduce_deferred_vtype(E, point, coord) ret;
+ };
+# endif // OLENA_USE_NEW_SCOOP2
+
namespace abstract
{
Index: oln/core/abstract/image/hybrid/classical.hh
--- oln/core/abstract/image/hybrid/classical.hh (revision 722)
+++ oln/core/abstract/image/hybrid/classical.hh (working copy)
@@ -174,11 +174,16 @@
/// 1D case.
template <typename E>
struct case_< image_hybrid_hierarchy_wrt_classical, E, 1 > :
- where_< mlc::and_list_< mlc::eq_< oln_vtype(E, grid), oln::grid1d >,
+ where_< mlc::and_list_<
+ mlc::eq_< oln_vtype(E, grid), oln::grid1d >,
mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
+ // FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
+# ifdef OLENA_USE_NEW_SCOOP2
+ mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found >
+# else
mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found >
- >
- >
+# endif // OLENA_USE_NEW_SCOOP2
+ > >
{
typedef abstract::classical_1d_image<E> ret;
};
@@ -187,11 +192,16 @@
/// 2D case.
template <typename E>
struct case_< image_hybrid_hierarchy_wrt_classical, E, 2 > :
- where_< mlc::and_list_< mlc::eq_< oln_vtype(E, grid), oln::grid2d >,
+ where_< mlc::and_list_<
+ mlc::eq_< oln_vtype(E, grid), oln::grid2d >,
mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
+ // FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
+# ifdef OLENA_USE_NEW_SCOOP2
+ mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found >
+# else
mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found >
- >
- >
+# endif // OLENA_USE_NEW_SCOOP2
+ > >
{
typedef abstract::classical_2d_image<E> ret;
};
@@ -200,11 +210,16 @@
/// 3D case.
template <typename E>
struct case_< image_hybrid_hierarchy_wrt_classical, E, 3 > :
- where_< mlc::and_list_< mlc::eq_< oln_vtype(E, grid), oln::grid3d >,
+ where_< mlc::and_list_<
+ mlc::eq_< oln_vtype(E, grid), oln::grid3d >,
mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
+ // FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
+# ifdef OLENA_USE_NEW_SCOOP2
+ mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found >
+# else
mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found >
- >
- >
+# endif // OLENA_USE_NEW_SCOOP2
+ > >
{
typedef abstract::classical_3d_image<E> ret;
};
@@ -213,10 +228,15 @@
/// General case.
template <typename E>
struct case_< image_hybrid_hierarchy_wrt_classical, E, 4 > :
- where_< mlc::and_< mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
+ where_< mlc::and_<
+ mlc::eq_< oln_deduce_vtype(E, topo, is_random_accessible), mlc::true_ >,
+ // FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
+# ifdef OLENA_USE_NEW_SCOOP2
+ mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found >
+# else
mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found >
- >
- >
+# endif // OLENA_USE_NEW_SCOOP2
+ > >
{
typedef abstract::classical_image<E> ret;
};
Index: oln/core/abstract/image/mutability/hierarchy.hh
--- oln/core/abstract/image/mutability/hierarchy.hh (revision 722)
+++ oln/core/abstract/image/mutability/hierarchy.hh (working copy)
@@ -108,7 +108,11 @@
/// With mutability.
template <typename E>
struct case_< image_hierarchy_wrt_mutability, E, 1 > :
+# ifdef OLENA_USE_NEW_SCOOP2
+ where_< stc::is_found_< oln_find_vtype(E, lvalue) > >
+# else
where_< mlc::is_found_< oln_find_vtype(E, lvalue) > >
+# endif // OLENA_USE_NEW_SCOOP2
{
typedef abstract::mutable_image<E> ret;
};
Index: oln/core/abstract/image/dimension/hierarchy.hh
--- oln/core/abstract/image/dimension/hierarchy.hh (revision 722)
+++ oln/core/abstract/image/dimension/hierarchy.hh (working copy)
@@ -96,8 +96,14 @@
template <typename E>
struct case_< image_hierarchy_wrt_dimension, E, 1 > :
- where_< mlc::and_< mlc::eq_< oln_grid(E), oln::grid1d >,
- mlc::is_found_< oln_find_vtype(E, lvalue) > > >
+ where_< mlc::and_<
+ mlc::eq_< oln_grid(E), oln::grid1d >,
+# ifdef OLENA_USE_NEW_SCOOP2
+ stc::is_found_< oln_find_vtype(E, lvalue) >
+# else
+ mlc::is_found_< oln_find_vtype(E, lvalue) >
+# endif // OLENA_USE_NEW_SCOOP2
+ > >
{
typedef abstract::mutable_image1d<E> ret;
};
@@ -113,8 +119,14 @@
template <typename E>
struct case_< image_hierarchy_wrt_dimension, E, 3 > :
- where_< mlc::and_< mlc::eq_< oln_grid(E), oln::grid2d >,
- mlc::is_found_< oln_find_vtype(E, lvalue) > > >
+ where_< mlc::and_<
+ mlc::eq_< oln_grid(E), oln::grid2d >,
+# ifdef OLENA_USE_NEW_SCOOP2
+ stc::is_found_< oln_find_vtype(E, lvalue) >
+# else
+ mlc::is_found_< oln_find_vtype(E, lvalue) >
+# endif // OLENA_USE_NEW_SCOOP2
+ > >
{
typedef abstract::mutable_image2d<E> ret;
};
@@ -130,8 +142,14 @@
template <typename E>
struct case_< image_hierarchy_wrt_dimension, E, 5 > :
- where_< mlc::and_< mlc::eq_< oln_grid(E), oln::grid3d >,
- mlc::is_found_< oln_find_vtype(E, lvalue) > > >
+ where_< mlc::and_<
+ mlc::eq_< oln_grid(E), oln::grid3d >,
+# ifdef OLENA_USE_NEW_SCOOP2
+ stc::is_found_< oln_find_vtype(E, lvalue) >
+# else
+ mlc::is_found_< oln_find_vtype(E, lvalue) >
+# endif // OLENA_USE_NEW_SCOOP2
+ > >
{
typedef abstract::mutable_image3d<E> ret;
};
Index: oln/core/abstract/image/neighborhood/hierarchy.hh
--- oln/core/abstract/image/neighborhood/hierarchy.hh (revision 722)
+++ oln/core/abstract/image/neighborhood/hierarchy.hh (working copy)
@@ -106,7 +106,12 @@
/// With neighborhood.
template <typename E>
struct case_< image_hierarchy_wrt_neighborhood, E, 1 > :
+ // FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
+# ifdef OLENA_USE_NEW_SCOOP2
+ where_< mlc::neq_< oln_find_vtype(E, neighborhood), stc::not_found > >
+# else
where_< mlc::neq_< oln_find_vtype(E, neighborhood), mlc::not_found > >
+# endif // OLENA_USE_NEW_SCOOP2
{
typedef abstract::image_having_neighborhood<E> ret;
};
Index: oln/core/abstract/image/bbox/hierarchy.hh
--- oln/core/abstract/image/bbox/hierarchy.hh (revision 722)
+++ oln/core/abstract/image/bbox/hierarchy.hh (working copy)
@@ -135,7 +135,12 @@
/// With bbox.
template <typename E>
struct case_< image_hierarchy_wrt_bbox, E, 1 > :
+ // FIXME: Shouldn't we use stc::is_found (resp. mlc::is_found) here?
+# ifdef OLENA_USE_NEW_SCOOP2
+ where_< mlc::neq_< oln_deduce_vtype(E, topo, bbox), stc::not_found > >
+# else
where_< mlc::neq_< oln_deduce_vtype(E, topo, bbox), mlc::not_found > >
+# endif // OLENA_USE_NEW_SCOOP2
{
typedef abstract::image_having_bbox<E> ret;
};
Index: oln/core/abstract/image/value_wise_accessibility/hierarchy.hh
--- oln/core/abstract/image/value_wise_accessibility/hierarchy.hh (revision 722)
+++ oln/core/abstract/image/value_wise_accessibility/hierarchy.hh (working copy)
@@ -133,8 +133,17 @@
/// With mutable value-wise random accessibility.
template <typename E>
struct case_< image_hierarchy_wrt_value_wise_accessibility, E, 1 > :
- where_< mlc_and( mlc_is_ok(oln_find_vtype(E, fwd_viter)),
- mlc_is_ok(oln_find_vtype(E, mutable_value_proxy)) ) >
+# ifdef OLENA_USE_NEW_SCOOP2
+ where_<
+ mlc_and( stc::is_found_< oln_find_vtype(E, fwd_viter) >,
+ stc::is_found_< oln_find_vtype(E, mutable_value_proxy) > )
+ >
+# else
+ where_<
+ mlc_and( mlc::is_found_< oln_find_vtype(E, fwd_viter) >,
+ mlc::is_found_< oln_find_vtype(E, mutable_value_proxy) > )
+ >
+# endif // OLENA_USE_NEW_SCOOP2
{
typedef abstract::mutable_image_being_value_wise_random_accessible<E> ret;
};
@@ -142,7 +151,11 @@
/// With (constant) value-wise random accessibility.
template <typename E>
struct case_< image_hierarchy_wrt_value_wise_accessibility, E, 2 > :
- where_< mlc_is_ok(oln_find_vtype(E, fwd_viter)) >
+# ifdef OLENA_USE_NEW_SCOOP2
+ where_< stc::is_found_< oln_find_vtype(E, fwd_viter) > >
+# else
+ where_< mlc::is_found_< oln_find_vtype(E, fwd_viter) > >
+# endif // OLENA_USE_NEW_SCOOP2
{
typedef abstract::image_being_value_wise_random_accessible<E> ret;
};
Index: oln/core/abstract/grid.hh
--- oln/core/abstract/grid.hh (revision 722)
+++ oln/core/abstract/grid.hh (working copy)
@@ -40,6 +40,13 @@
template <typename E> class grid;
}
+ /// Super type declaration.
+ template <typename E>
+ struct set_super_type< abstract::grid<E> >
+ {
+ typedef mlc::none ret;
+ };
+
/// Virtual types associated to oln::abstract::grid.
template <typename E>
struct vtypes< abstract::grid<E> >
Index: oln/core/abstract/point.hh
--- oln/core/abstract/point.hh (revision 722)
+++ oln/core/abstract/point.hh (working copy)
@@ -69,13 +69,35 @@
// FIXME: Prefer to use final<deduce..> when possible.
typedef stc::abstract grid_type;
typedef stc::abstract dpoint_type;
+# ifndef OLENA_USE_NEW_SCOOP2
typedef oln_deduce_deferred_vtype(E, dpoint, coord) coord_type;
+# endif // !OLENA_USE_NEW_SCOOP2
typedef stc::abstract dim_type;
+# ifndef OLENA_USE_NEW_SCOOP2
typedef oln_dim(E) dim_t;
typedef xtd::vec<mlc_value(dim_t), coord_type> vec_type;
+# endif // !OLENA_USE_NEW_SCOOP2
};
+# ifdef OLENA_USE_NEW_SCOOP2
+ template <typename E>
+ struct single_vtype< abstract::point<E>, typedef_::coord_type>
+ {
+ typedef oln_deduce_vtype(E, dpoint, coord) ret;
+ };
+
+ template <typename E>
+ struct single_vtype< abstract::point<E>, typedef_::vec_type>
+ {
+ private:
+ typedef oln_dim(E) dim_t;
+ typedef oln_coord(E) coord_t;
+ public:
+ typedef xtd::vec<mlc_value(dim_t), coord_t> ret;
+ };
+# endif // OLENA_USE_NEW_SCOOP2
+
namespace abstract
{
Index: oln/core/2d/point2d.hh
--- oln/core/2d/point2d.hh (revision 722)
+++ oln/core/2d/point2d.hh (working copy)
@@ -36,7 +36,6 @@
namespace oln
{
-
/// Fwd decls.
template <unsigned D> struct grid_;
template <typename C> struct dpoint2d_;
Index: oln/core/gen/topo_add_isubset.hh
--- oln/core/gen/topo_add_isubset.hh (revision 722)
+++ oln/core/gen/topo_add_isubset.hh (working copy)
@@ -36,7 +36,7 @@
{
- // Forward declarations.
+ // Forward declaration.
template <typename topo, typename isubset> class topo_add_isubset;
@@ -49,7 +49,7 @@
};
- /// Virtual types associated to oln::bbox_<point>.
+ /// Virtual types associated to oln::topo_add_isubset<topo, isubset>.
template <typename topo, typename isubset>
struct vtypes< topo_add_isubset<topo, isubset> >
{
@@ -57,7 +57,7 @@
};
- /// Bounding box topology based on a point class.
+ /// Topology based on another topology and a subset (encoded in an image).
template <typename topo_t, typename isubset_t>
class topo_add_isubset
: public internal::topology_morpher<topo_t, topo_add_isubset<topo_t, isubset_t> >
Index: oln/core/gen/topo_bbox.hh
--- oln/core/gen/topo_bbox.hh (revision 722)
+++ oln/core/gen/topo_bbox.hh (working copy)
@@ -35,7 +35,7 @@
namespace oln
{
- // Forward declarations.
+ // Forward declaration.
template <typename point> class topo_bbox_;
@@ -48,7 +48,7 @@
};
- /// Virtual types associated to oln::bbox_<point>.
+ /// Virtual types associated to oln::topo_bbox_<point>.
template <typename point>
struct vtypes< topo_bbox_<point> >
{
Index: oln/core/gen/bkd_viter_lut.hh
--- oln/core/gen/bkd_viter_lut.hh (revision 722)
+++ oln/core/gen/bkd_viter_lut.hh (working copy)
@@ -91,7 +91,7 @@
bool impl_is_valid() const;
/// \}
- // Get the value pointed by this iterator (const version).
+ /// Get the value pointed by this iterator.
value_type impl_to_value() const;
void print(std::ostream& ostr) const;
Index: oln/core/gen/topo_lbbox.hh
--- oln/core/gen/topo_lbbox.hh (revision 722)
+++ oln/core/gen/topo_lbbox.hh (working copy)
@@ -34,7 +34,7 @@
namespace oln
{
- // Forward declarations.
+ // Forward declaration.
template <typename point> class topo_lbbox_;
@@ -47,7 +47,7 @@
};
- /// Virtual types associated to oln::bbox_<point>.
+ /// Virtual types associated to oln::topo_lbbox_<point>.
template <typename point>
struct vtypes< topo_lbbox_<point> >
{
Index: oln/core/gen/fwd_viter_lut.hh
--- oln/core/gen/fwd_viter_lut.hh (revision 722)
+++ oln/core/gen/fwd_viter_lut.hh (working copy)
@@ -91,7 +91,7 @@
bool impl_is_valid() const;
/// \}
- // Get the value pointed by this iterator (const version).
+ /// Get the value pointed by this iterator.
value_type impl_to_value() const;
void print(std::ostream& ostr) const;
Index: oln/core/gen/topo_add_nbh.hh
--- oln/core/gen/topo_add_nbh.hh (revision 722)
+++ oln/core/gen/topo_add_nbh.hh (working copy)
@@ -36,7 +36,7 @@
{
- // Forward declarations.
+ // Forward declaration.
template <typename topo, typename nbh> class topo_add_nbh;
@@ -49,7 +49,7 @@
};
- /// Virtual types associated to oln::bbox_<point>.
+ /// Virtual types associated to oln::topo_add_nbh<topo, nbh>.
template <typename topo, typename nbh>
struct vtypes< topo_add_nbh<topo, nbh> >
{
@@ -58,7 +58,7 @@
};
- /// Bounding box topology based on a point class.
+ /// Topology based on another topology and a neighborhood.
template <typename topo_t, typename nbh_t>
class topo_add_nbh : public internal::topology_morpher<topo_t, topo_add_nbh<topo_t, nbh_t> >
{
Index: oln/core/internal/point_nd.hh
--- oln/core/internal/point_nd.hh (revision 722)
+++ oln/core/internal/point_nd.hh (working copy)
@@ -44,7 +44,6 @@
namespace oln
{
-
/// Function \f$point : (n, coord) \rightarrow point type\f$.
template <unsigned n, typename C>
@@ -67,16 +66,16 @@
typedef abstract::point<E> ret;
};
-
- template <typename E>
- struct vtypes< internal::point_nd<E> >
- {
- private:
- typedef oln_deferred_vtype(E, dim) dim_t;
- typedef oln_deferred_vtype(E, coord) coord_t;
- public:
- typedef xtd::vec<mlc_value(dim_t), coord_t> vec_type;
- };
+// FIXME: Already defined in vtypes< abstract::point<E> > (Why?).
+// template <typename E>
+// struct vtypes< internal::point_nd<E> >
+// {
+// private:
+// typedef oln_deferred_vtype(E, dim) dim_t;
+// typedef oln_deferred_vtype(E, coord) coord_t;
+// public:
+// typedef xtd::vec<mlc_value(dim_t), coord_t> vec_type;
+// };
namespace internal
Index: oln/core/internal/bbox_fwd_piter.hh
--- oln/core/internal/bbox_fwd_piter.hh (revision 722)
+++ oln/core/internal/bbox_fwd_piter.hh (working copy)
@@ -45,7 +45,7 @@
}
- // Super type declaration.
+ /// Super type declaration.
template <typename E>
struct set_super_type< internal::bbox_fwd_piter<E> >
{
Index: oln/core/internal/dpoint_nd.hh
--- oln/core/internal/dpoint_nd.hh (revision 722)
+++ oln/core/internal/dpoint_nd.hh (working copy)
@@ -54,13 +54,26 @@
template <typename E>
struct vtypes< internal::dpoint_nd<E> >
{
+# ifndef OLENA_USE_NEW_SCOOP2
private:
typedef oln_deferred_vtype(E, dim) dim_t;
typedef oln_deferred_vtype(E, coord) coord_t;
public:
typedef xtd::vec<mlc_value(dim_t), coord_t> vec_type;
+# endif // !OLENA_USE_NEW_SCOOP2
};
+# ifdef OLENA_USE_NEW_SCOOP2
+ template <typename E>
+ struct single_vtype< internal::dpoint_nd<E>, typedef_::vec_type >
+ {
+ private:
+ typedef oln_deferred_vtype(E, dim) dim_t;
+ typedef oln_deferred_vtype(E, coord) coord_t;
+ public:
+ typedef xtd::vec<mlc_value(dim_t), coord_t> ret;
+ };
+# endif // OLENA_USE_NEW_SCOOP2
namespace internal
{
@@ -68,6 +81,10 @@
template <typename E>
class dpoint_nd : public abstract::dpoint<E>
{
+// #ifdef USE_ALT_SCOOP2
+// typedef typename vtypes< internal::dpoint_nd<E> >::self_type dummy;
+// #endif // USE_ALT_SCOOP2
+
typedef E exact_t;
typedef dpoint_nd<E> self_t;
typedef oln_dim(E) dim_t;
Index: oln/morpher/thru_mfun.hxx
--- oln/morpher/thru_mfun.hxx (revision 722)
+++ oln/morpher/thru_mfun.hxx (working copy)
@@ -31,6 +31,9 @@
namespace oln
{
+ namespace morpher
+ {
+
template <typename Image, typename Fun>
thru_mfun<Image, Fun>::thru_mfun(const Image& image, const Fun& fun) :
super_t(image),
@@ -52,6 +55,8 @@
return fun_(this->image_(p));
}
+ } // end of namespace oln::morpher
+
} // end of namespace oln
#endif // ! OLN_MORPHER_THRU_MFUN_HXX
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Polish stc/scoop2.hh.
The work is far from beeing finished; we still have to address
the problem of deferred virtual types.
* doc/algorithms.ml: Add a new (non working) example.
Typos.
* stc/scoop.hh (stc_find_deduce_vtype): Add a missing argument.
* stc/scoop2.hh (stc::none): New.
(stc::is_found_, stc::is_not_found_): New.
(SCOOPED_NAMESPACE): Set to oln.
(stc_match_pair_0p_with, stc_match_pair_1p_with
(stc_match_pair_2p_with, stc_match_pair_1p_with_error)
(stc_match_pair_2p_with_error): New macros.
(merge2_): Use them to simplify this struct.
(stc_match_triple_0p_with, stc_match_triple_1p_with)
(stc_match_triple_2p_with, stc_match_triple_3p_with)
(stc_match_triple_2p_with_error, stc_match_triple_3p_with_error):
New macros.
(merge3_): Use them to simplify this struct.
(find): Rename struct as...
(find_vtype): ...this.
(vtype): New struct.
(stc_deferred_vtype, stc_vtype_, stc_vtype)
(stc_find_deduce_vtype_, stc_find_deduce_vtype)
(stc_deduce_deferred_vtype, stc_deduce_vtype_, stc_deduce_vtype):
New macros.
doc/algorithms.ml | 41 +++
stc/scoop.hh | 2
stc/scoop2.hh | 582 +++++++++++++++++++++++++++++++-----------------------
3 files changed, 378 insertions(+), 247 deletions(-)
Index: doc/algorithms.ml
--- doc/algorithms.ml (revision 721)
+++ doc/algorithms.ml (working copy)
@@ -80,8 +80,8 @@
| Stc_Not_found, u -> u
(* local_res == stc::abstract. *)
- | Stc_Abstract, Stc_Abstract -> Stc_Abstract
| Stc_Abstract, Stc_Not_found -> Stc_Abstract
+ | Stc_Abstract, Stc_Abstract -> Stc_Abstract
| Stc_Abstract, Stc_Final _ -> error "Final VT redefined abstract"
| Stc_Abstract, _ -> error "VT redefined abstract."
@@ -182,7 +182,7 @@
end
| _ -> error "find_rec: source is not a SCOOP class."
-(* Like find_rec, but only search in the inheritance branch. *)
+(* Like find_rec, but search only in the inheritance branch. *)
and find_rec_in_supers (source : cxx_type) (target : string) : cxx_type =
match source with
| Stc_None -> Stc_Not_found
@@ -206,7 +206,6 @@
;;
-
(*-----------.
| Examples. |
`-----------*)
@@ -611,3 +610,39 @@
assert (find image2d_int "value_type" = Std_Int);
assert (find value_cast__image2d_int__float "value_type" = Std_Float);;
+
+
+(*--------------.
+| Limitations. |
+`--------------*)
+
+(* Another Olena-like example with recursive definitions.
+
+ class internal_dpoint_nd < stc::none
+ {
+ vtype mydim_type = find dpoint2d "dim_type";
+ }
+
+ class dpoint2d < internal_dpoint_nd
+ {
+ // Dummy value (because our C++ types are limited in this prototype).
+ vtype dim_type = int
+ }
+*)
+(* However, we can't write this
+
+ let rec internal_dpoint_nd =
+ Scoop_Class { super = Stc_None;
+ vtypes = create_vtypes ["mydim_type",
+ (find dpoint2d "dim_type")] }
+ and dpoint2d =
+ Scoop_Class { super = internal_dpoint_nd;
+ vtypes = create_vtypes ["dim_type", Std_Int] }
+ in
+ find dpoint2d "dim_type";;
+
+ because of the limitations of the recursive definitions of OCaml.
+ These limitations reflect issues w.r.t. recursive definitions in
+ C++ too. A new mechanism is needed, both in this OCaml prototype
+ and in its C++ counterpart (stc/scoop2.hh).
+*)
Index: stc/scoop.hh
--- stc/scoop.hh (revision 721)
+++ stc/scoop.hh (working copy)
@@ -801,7 +801,7 @@
Namespace::typedef_::Target1##_type>::ret, \
Namespace::typedef_::Target2##_type>::ret
-# define stc_find_deduce_vtype(Namespace, From, Target) \
+# define stc_find_deduce_vtype(Namespace, From, Target1, Target2) \
typename \
Namespace::find_vtype< typename \
Namespace::find_vtype<From, \
Index: stc/scoop2.hh
--- stc/scoop2.hh (revision 721)
+++ stc/scoop2.hh (working copy)
@@ -39,14 +39,38 @@
namespace stc
{
-
+ /* 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 paradigme (see stc/scoop.hh), we
+ need to have stc::none be equal to mlc::none. */
+#if 0
struct none {};
+#endif
+ using mlc::none;
+
struct not_found;
struct abstract;
struct not_delegated;
struct not_delegated_abstract;
template <typename T> struct final;
+
+ /// \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
+ {
+ };
+
+ template <typename T>
+ struct is_found_ : public mlc_is_not_a(T, stc::not_found)::bexpr
+ {
+ };
+ /// \}
+
namespace ERROR
{
struct IN_find__VIRTUAL_TYPE_IS_ABSTRACT;
@@ -73,8 +97,10 @@
// Based on doc/algorithm.ml.
-// FIXME: Hack.
-#define SCOOPED_NAMESPACE my
+// FIXME: Temp. hack. The contents of SCOOPED_NAMESPACE will be
+// available later as a macro, as in stc/scoop.hh. Currently, it's
+// easier to work without this macro equipment.
+#define SCOOPED_NAMESPACE oln
// ------------------------------------------------------------ find_local.
@@ -152,106 +178,124 @@
// -------------------------------------------------------------- merge2.
+// Shortcuts macros.
+#define stc_match_pair_0p_with(Local, Super, Res) \
+ template <> \
+ struct match_with< Local, Super > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_match_pair_1p_with(T1, Local, Super, Res) \
+ template < typename T1 > \
+ struct match_with< Local, Super > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_match_pair_2p_with(T1, T2, Local, Super, Res) \
+ template < typename T1, typename T2 > \
+ struct match_with< Local, Super > \
+ { \
+ typedef Res ret; \
+ }
+
+// Erroneous cases.
+#define stc_match_pair_1p_with_error(T1, Local, Super, Msg) \
+ template < typename T1 > \
+ struct match_with< Local, Super > : \
+ mlc::abort_< T1, Msg > \
+ { \
+ }
+
+#define stc_match_pair_2p_with_error(T1, T2, Local, Super, Msg) \
+ template < typename T1, typename T2 > \
+ struct match_with< Local, Super > : \
+ mlc::abort_< T2, Msg > \
+ { \
+ }
+
+
namespace merge2_
{
// Forward declaration.
template <typename T, typename U> struct match_with;
- // super_res == stc::not_found.
- template <>
- struct match_with<stc::abstract, stc::not_found>
- {
- typedef stc::abstract ret;
- };
- template <>
- struct match_with<stc::not_found, stc::not_found>
- {
- typedef stc::not_found ret;
- };
- template <typename T>
- struct match_with<stc::final<T>, stc::not_found>
- {
- typedef stc::final<T> ret;
- };
+ /*------------------------------.
+ | local_res == stc::not_found. |
+ `------------------------------*/
- template <typename T>
- struct match_with<T, stc::not_found>
- {
- typedef T ret;
- };
+ stc_match_pair_0p_with(stc::not_found, stc::not_found,
+ stc::not_found);
+ stc_match_pair_0p_with(stc::not_found, stc::abstract,
+ stc::not_found);
- // super_res == stc::abstract.
- template <>
- struct match_with<stc::not_found, stc::abstract>
- {
- typedef stc::not_found ret;
- };
+ stc_match_pair_1p_with(U,
+ stc::not_found, stc::final<U>,
+ stc::final<U>);
- template <>
- struct match_with<stc::abstract, stc::abstract>
- {
- typedef stc::abstract ret;
- };
+ stc_match_pair_1p_with(U,
+ stc::not_found, U,
+ U);
- template <typename T>
- struct match_with<stc::final<T>, stc::abstract>
- {
- typedef stc::final<T> ret;
- };
- template <typename T>
- struct match_with<T, stc::abstract>
- {
- typedef T ret;
- };
+ /*-----------------------------.
+ | local_res == stc::abstract. |
+ `-----------------------------*/
+ stc_match_pair_0p_with(stc::abstract, stc::not_found,
+ stc::abstract);
- // super_res == stc::final<U>.
- template <typename U>
- struct match_with<stc::abstract, stc::final<U> > :
- mlc::abort_<U, stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT>
- {
- };
+ stc_match_pair_0p_with(stc::abstract, stc::abstract,
+ stc::abstract);
- template <typename U>
- struct match_with<stc::not_found, stc::final<U> >
- {
- typedef stc::final<U> ret;
- };
+ stc_match_pair_1p_with_error(U,
+ stc::abstract, stc::final<U>,
+ stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT);
- template <typename T, typename U>
- struct match_with<stc::final<T>, stc::final<U> > :
- mlc::abort_<U, stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL>
- {
- };
+ stc_match_pair_1p_with_error(U,
+ stc::abstract, U,
+ stc::ERROR::IN_merge2__VIRTUAL_TYPE_REDEFINED_ABSTRACT);
- template <typename T, typename U>
- struct match_with<T, stc::final<U> > :
- mlc::abort_<U, stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED>
- {
- };
+ /*-----------------------------.
+ | local_res == stc::final<T>. |
+ `-----------------------------*/
- // super_res == U.
- template <typename U>
- struct match_with<stc::abstract, U> :
- mlc::abort_<U, stc::ERROR::IN_merge2__VIRTUAL_TYPE_REDEFINED_ABSTRACT>
- {
- };
+ stc_match_pair_1p_with(T,
+ stc::final<T>, stc::not_found,
+ stc::final<T>);
- template <typename U>
- struct match_with<stc::not_found, U>
- {
- typedef U ret;
- };
+ stc_match_pair_1p_with(T,
+ stc::final<T>, stc::abstract,
+ stc::final<T>);
- template <typename T, typename U>
- struct match_with<stc::final<T>, U>
- {
- typedef stc::final<T> ret;
- };
+ stc_match_pair_2p_with_error(T, U,
+ stc::final<T>, stc::final<U>,
+ stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL);
+
+ stc_match_pair_2p_with(T, U,
+ stc::final<T>, U,
+ stc::final<T>);
+
+
+ /*-----------------.
+ | local_res == T. |
+ `-----------------*/
+
+ stc_match_pair_1p_with(T,
+ T, stc::not_found,
+ T);
+
+ stc_match_pair_1p_with(T,
+ T, stc::abstract,
+ T);
+
+ stc_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
@@ -261,6 +305,12 @@
} // end of namespace merge2_
+#undef stc_match_pair_2p_with_error
+#undef stc_match_pair_1p_with_error
+#undef stc_match_pair_2p_with
+#undef stc_match_pair_1p_with
+#undef stc_match_pair_0p_with
+
template <typename local_res, typename super_res>
struct merge2
{
@@ -271,38 +321,50 @@
// -------------------------------------------------------------- merge3.
- // FIXME: Undef these macros after the definition of merge3.
-
-#define stc_match_0p_with(Local, Super, Deleg, Res) \
+// Shortcuts macros.
+#define stc_match_triple_0p_with(Local, Super, Deleg, Res) \
template <> \
struct match_with< Local, Super, Deleg > \
{ \
typedef Res ret; \
}
-#define stc_match_1p_with(T1, Local, Super, Deleg, Res) \
+#define stc_match_triple_1p_with(T1, Local, Super, Deleg, Res) \
template <typename T1> \
struct match_with< Local, Super, Deleg > \
{ \
typedef Res ret; \
}
-#define stc_match_2p_with(T1, T2, Local, Super, Deleg, Res) \
+#define stc_match_triple_2p_with(T1, T2, Local, Super, Deleg, Res) \
template <typename T1, typename T2> \
struct match_with< Local, Super, Deleg > \
{ \
typedef Res ret; \
}
-#define stc_match_3p_with(T1, T2, T3, Local, Super, Deleg, Res) \
+#define stc_match_triple_3p_with(T1, T2, T3, Local, Super, Deleg, Res) \
template <typename T1, typename T2, typename T3> \
struct match_with< Local, Super, Deleg > \
{ \
typedef Res ret; \
}
- // FIXME: Example of use.
- // stc_match_with(stc::not_found, stc::not_found, stc::not_found, stc::not_found);
+// Erroneous cases.
+#define stc_match_triple_2p_with_error(T1, T2, Local, Super, Deleg, Msg) \
+ template < typename T1, typename T2 > \
+ struct match_with< Local, Super, Deleg > : \
+ mlc::abort_< T2, Msg > \
+ { \
+ }
+
+#define stc_match_triple_3p_with_error(T1, T2, T3, Local, Super, Deleg, Msg) \
+ template < typename T1, typename T2, typename T3 > \
+ struct match_with< Local, Super, Deleg > : \
+ mlc::abort_< T3, Msg > \
+ { \
+ }
+
namespace merge3_
{
@@ -310,198 +372,155 @@
template <typename T, typename U, typename V> struct match_with;
- // local_res == stc::not_found.
- template <>
- struct match_with<stc::not_found, stc::not_found, stc::not_found>
- {
- typedef stc::not_found ret;
- };
+ /*------------------------------.
+ | local_res == stc::not_found. |
+ `------------------------------*/
- template <>
- struct match_with<stc::not_found, stc::not_found, stc::abstract>
- {
- typedef stc::not_found ret;
- };
+ // super_res == stc::not_found.
+ stc_match_triple_0p_with(stc::not_found, stc::not_found, stc::not_found,
+ stc::not_found);
- template <typename V>
- struct match_with<stc::not_found, stc::not_found, stc::final<V> >
- {
- typedef stc::final<V> ret;
- };
+ stc_match_triple_0p_with(stc::not_found, stc::not_found, stc::abstract,
+ stc::not_found);
- template <typename V>
- struct match_with<stc::not_found, stc::not_found, V>
- {
- typedef V ret;
- };
+ stc_match_triple_1p_with(V,
+ stc::not_found, stc::not_found, stc::final<V>,
+ stc::final<V>);
+
+ stc_match_triple_1p_with(V,
+ stc::not_found, stc::not_found, V,
+ V);
+ // super_res == stc::abstract.
+ stc_match_triple_0p_with(stc::not_found, stc::abstract, stc::not_found,
+ stc::not_found);
- template <>
- struct match_with<stc::not_found, stc::abstract, stc::not_found>
- {
- typedef stc::not_found ret;
- };
+ stc_match_triple_0p_with(stc::not_found, stc::abstract, stc::abstract,
+ stc::abstract);
- template <>
- struct match_with<stc::not_found, stc::abstract, stc::abstract>
- {
- typedef stc::abstract ret;
- };
+ stc_match_triple_1p_with(V,
+ stc::not_found, stc::abstract, stc::final<V>,
+ stc::final<V>);
- template <typename V>
- struct match_with<stc::not_found, stc::abstract, stc::final<V> >
- {
- typedef stc::final<V> ret;
- };
+ stc_match_triple_1p_with(V,
+ stc::not_found, stc::abstract, V,
+ V);
- template <typename V>
- struct match_with<stc::not_found, stc::abstract, V>
- {
- typedef V ret;
- };
+ // super_res is a concrete type.
+ stc_match_triple_2p_with(U, V,
+ stc::not_found, stc::final<U>, V,
+ stc::final<U>);
+ stc_match_triple_2p_with(U, V,
+ stc::not_found, U, V,
+ U);
- template <typename U, typename V>
- struct match_with<stc::not_found, stc::final<U>, V>
- {
- typedef stc::final<U> ret;
- };
- template <typename U, typename V>
- struct match_with<stc::not_found, U, V>
- {
- typedef U ret;
- };
+ /*-----------------------------.
+ | local_res == stc::abstract. |
+ `-----------------------------*/
+ // super_res == stc::not_found.
+ stc_match_triple_0p_with(stc::abstract, stc::not_found, stc::not_found,
+ stc::abstract);
- // local_res == stc::abstract.
- template <>
- struct match_with<stc::abstract, stc::not_found, stc::not_found>
- {
- typedef stc::abstract ret;
- };
+ stc_match_triple_0p_with(stc::abstract, stc::not_found, stc::abstract,
+ stc::abstract);
- template <>
- struct match_with<stc::abstract, stc::not_found, stc::abstract>
- {
- typedef stc::abstract ret;
- };
+ stc_match_triple_1p_with(V,
+ stc::abstract, stc::not_found, stc::final<V>,
+ stc::final<V>);
+
+ stc_match_triple_1p_with(V,
+ stc::abstract, stc::not_found, V,
+ V);
- template <typename V>
- struct match_with<stc::abstract, stc::not_found, stc::final<V> >
- {
- typedef stc::final<V> ret;
- };
- template <typename V>
- struct match_with<stc::abstract, stc::not_found, V >
- {
- typedef V ret;
- };
+ // super_res == stc::abstract.
+ stc_match_triple_0p_with(stc::abstract, stc::abstract, stc::not_found,
+ stc::abstract);
+ stc_match_triple_0p_with(stc::abstract, stc::abstract, stc::abstract,
+ stc::abstract);
- template <>
- struct match_with<stc::abstract, stc::abstract, stc::not_found>
- {
- typedef stc::abstract ret;
- };
+ stc_match_triple_1p_with(V,
+ stc::abstract, stc::abstract, stc::final<V>,
+ stc::final<V>);
- template <>
- struct match_with<stc::abstract, stc::abstract, stc::abstract>
- {
- typedef stc::abstract ret;
- };
+ stc_match_triple_1p_with(V,
+ stc::abstract, stc::abstract, V,
+ V);
- template <typename V>
- struct match_with<stc::abstract, stc::abstract, stc::final<V> >
- {
- typedef stc::final<V> ret;
- };
- template <typename V>
- struct match_with<stc::abstract, stc::abstract, V>
- {
- typedef V ret;
- };
+ // super_res == stc::not_delegated_abstract.
+ stc_match_triple_1p_with(V,
+ stc::abstract, stc::not_delegated_abstract, V,
+ stc::not_delegated_abstract);
+ stc_match_triple_1p_with(V,
+ stc::abstract, stc::not_delegated, V,
+ stc::not_delegated_abstract);
- template <typename V>
- struct match_with<stc::abstract, stc::not_delegated_abstract, V>
- {
- typedef stc::not_delegated_abstract ret;
- };
- template <typename V>
- struct match_with<stc::abstract, stc::not_delegated, V>
- {
- typedef stc::not_delegated_abstract ret;
- };
+ // super_res is a concrete type.
+ stc_match_triple_2p_with_error(U, V,
+ stc::abstract, stc::final<U>, V,
+ stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT);
+ stc_match_triple_2p_with_error(U, V,
+ stc::abstract, U, V,
+ stc::ERROR::IN_merge3__VIRTUAL_TYPE_REDEFINED_ABSTRACT);
- template <typename U, typename V>
- struct match_with<stc::abstract, stc::final<U>, V> :
- mlc::abort_<V, stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT>
- {
- };
- template <typename U, typename V>
- struct match_with<stc::abstract, U, V> :
- mlc::abort_<V, stc::ERROR::IN_merge3__VIRTUAL_TYPE_REDEFINED_ABSTRACT>
- {
- };
+ /*----------------------------------.
+ | local_res == stc::not_delegated. |
+ `----------------------------------*/
+ stc_match_triple_1p_with(V,
+ stc::not_delegated, stc::not_found, V,
+ stc::not_delegated);
- // local_res == stc::not_delegated.
- template <typename V>
- struct match_with<stc::not_delegated, stc::not_found, V>
- {
- typedef stc::not_delegated ret;
- };
+ stc_match_triple_1p_with(V,
+ stc::not_delegated, stc::abstract, V,
+ stc::not_delegated_abstract);
- template <typename V>
- struct match_with<stc::not_delegated, stc::abstract, V>
- {
- typedef stc::not_delegated_abstract ret;
- };
+ stc_match_triple_1p_with(V,
+ stc::not_delegated, stc::not_delegated_abstract, V,
+ stc::not_delegated_abstract);
- template <typename V>
- struct match_with<stc::not_delegated, stc::not_delegated_abstract, V>
- {
- typedef stc::not_delegated_abstract ret;
- };
+ /*----------------------------------------------.
+ | local_res == 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). */
- template <typename U, typename V>
- struct match_with<stc::not_delegated_abstract, U, V> :
- mlc::abort_<V, stc::ERROR::IN_merge3__LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT>
- {
- };
+ stc_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>.
- template <typename T, typename U, typename V>
- struct match_with<stc::final<T>, stc::final<U>, V> :
- mlc::abort_<V, stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL>
- {
- };
+ /*-----------------------------.
+ | local_res == stc::final<T>. |
+ `-----------------------------*/
- template <typename T, typename U, typename V>
- struct match_with<stc::final<T>, U, V>
- {
- typedef stc::final<T> ret;
- };
+ stc_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_match_triple_3p_with(T, U, V,
+ stc::final<T>, U, V,
+ stc::final<T>);
- // local_res == T.
- template <typename T, typename U, typename V>
- struct match_with<T, stc::final<U>, V> :
- mlc::abort_<V, stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED>
- {
- };
+
+ /*-----------------.
+ | local_res == T. |
+ `-----------------*/
+
+ stc_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
@@ -511,6 +530,15 @@
} // end of namespace merge3_
+
+#undef stc_match_triple_3p_with_error
+#undef stc_match_triple_2p_with_error
+#undef stc_match_triple_3p_with
+#undef stc_match_triple_2p_with
+#undef stc_match_triple_1p_with
+#undef stc_match_triple_0p_with
+
+
template <typename local_res, typename super_res, typename delegatee_res>
struct merge3
{
@@ -669,21 +697,89 @@
} // end of namespace find_
+
+ /// Find a virtual type.
template <typename source, typename target>
- struct find
+ 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 */
+// FIXME: Document all these macros.
+
# define stc_find_vtype_(Namespace, Source, Target) \
- Namespace::find<Source, Namespace::typedef_::Target##_type>::ret
+ 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
+
+
#endif // ! STC_SCOOP2_HH
1
0
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
URL: https://svn.lrde.epita.fr/svn/oln/trunk/olena
ChangeLog:
2007-01-19 Thomas Moulard <thomas.moulard(a)lrde.epita.fr>
Split morphers' interface and implementation.
* oln/morpher/add_isubset.hh: Split into...
* oln/morpher/add_isubset.hxx: ...this new file.
* oln/morpher/add_neighborhood.hh: Split into...
* oln/morpher/add_neighborhood.hxx: : ...this new file.
* oln/morpher/count_rw.hh: Split into...
* oln/morpher/count_rw.hxx: : ...this new file.
* oln/morpher/identity.hh: Split into...
* oln/morpher/identity.hxx: : ...this new file.
* oln/morpher/stack.hh: Split into...
* oln/morpher/stack.hxx: : ...this new file.
* oln/morpher/stack_rw.hh: Split into...
* oln/morpher/stack_rw.hxx: : ...this new file.
* oln/morpher/thru_fun.hh: Split into...
* oln/morpher/thru_mfun.hh: Split into...
* oln/morpher/thru_mfun.hxx: : ...this new file.
* oln/morpher/two_way.hh: Split into...
* oln/morpher/two_way.hxx: : ...this new file.
* oln/morpher/two_way_rw.hh: Split into...
* oln/morpher/two_way_rw.hxx: : ...this new file.
* oln/morpher/value_cast.hh: Split into...
* oln/morpher/value_cast.hxx: : ...this new file.
* oln/morpher/with_lut.hh: Split into...
* oln/morpher/with_lut.hxx: : ...this new file.
add_isubset.hh | 60 ++----------------------
add_isubset.hxx | 98 +++++++++++++++++++++++++++++++++++++++
add_neighborhood.hh | 40 +---------------
add_neighborhood.hxx | 82 ++++++++++++++++++++++++++++++++
count_rw.hh | 62 +-----------------------
count_rw.hxx | 105 ++++++++++++++++++++++++++++++++++++++++++
identity.hh | 10 ++--
identity.hxx | 55 ++++++++++++++++++++++
stack.hh | 75 +-----------------------------
stack.hxx | 121 ++++++++++++++++++++++++++++++++++++++++++++++++
stack_rw.hh | 92 ++----------------------------------
stack_rw.hxx | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++
thru_fun.hh | 8 +--
thru_mfun.hh | 39 +++------------
thru_mfun.hxx | 64 +++++++++++++++++++++++++
two_way.hh | 52 ++++----------------
two_way.hxx | 80 ++++++++++++++++++++++++++++++++
two_way_rw.hh | 42 +---------------
two_way_rw.hxx | 79 +++++++++++++++++++++++++++++++
value_cast.hh | 35 ++------------
value_cast.hxx | 68 +++++++++++++++++++++++++++
with_lut.hh | 64 +------------------------
with_lut.hxx | 91 ++++++++++++++++++++++++++++++++++++
23 files changed, 1034 insertions(+), 515 deletions(-)
Index: oln/morpher/stack_rw.hxx
===================================================================
- --- oln/morpher/stack_rw.hxx (revision 0)
+++ oln/morpher/stack_rw.hxx (revision 0)
@@ -0,0 +1,127 @@
+// 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_MORPHER_STACK_RW_HXX
+# define OLN_MORPHER_STACK_RW_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+
+ template <unsigned n, typename I>
+ stack_rw<n, I>::stack_rw(const xtd::vec<n, I>& images) :
+ super_t(images[0]),
+ images_(images)
+ {
+ }
+
+ template <unsigned n, typename I>
+ xtd::vec<n, oln_value(I)>
+ stack_rw<n, I>::impl_op_read(const typename stack_rw<n, I>::psite_t& p) const
+ {
+ xtd::vec<n, oln_value(I)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = images_[i](p);
+ return tmp;
+ }
+
+ template <unsigned n, typename I>
+ typename stack_rw<n, I>::lvalue_t
+ stack_rw<n, I>::impl_op_readwrite(const typename stack_rw<n, I>::psite_t& p)
+ {
+ lvalue_t tmp(*this, p);
+ return tmp;
+ }
+
+ template <unsigned n, typename I>
+ const I&
+ stack_rw<n, I>::image(unsigned i) const
+ {
+ precondition(i < n);
+ return images_[i];
+ }
+
+ template <unsigned n, typename I>
+ I&
+ stack_rw<n, I>::image(unsigned i)
+ {
+ precondition(i < n);
+ return images_[i];
+ }
+
+ } // end of namespace oln::morpher
+
+
+ template <typename I>
+ morpher::stack_rw<2, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1)
+ {
+ morpher::stack_rw<2, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact()));
+ return tmp;
+ }
+
+ template <typename I>
+ morpher::stack_rw<3, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1,
+ abstract::mutable_image<I>& image_2)
+ {
+ morpher::stack_rw<3, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact(),
+ image_2.exact()));
+ return tmp;
+ }
+
+ template <typename I>
+ morpher::stack_rw<4, I>
+ stack_rw(abstract::mutable_image<I>& image_0,
+ abstract::mutable_image<I>& image_1,
+ abstract::mutable_image<I>& image_2,
+ abstract::mutable_image<I>& image_3)
+ {
+ morpher::stack_rw<4, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact(),
+ image_2.exact(),
+ image_3.exact()));
+ return tmp;
+ }
+
+} // end of namespace oln
+
+#endif // ! OLN_MORPHER_STACK_RW_HXX
+
+
+
+
+
+
+
+
Index: oln/morpher/add_isubset.hh
===================================================================
- --- oln/morpher/add_isubset.hh (revision 719)
+++ oln/morpher/add_isubset.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,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
- -#ifndef OLN_MORPHER_ADD_ISUBSET
- -# define OLN_MORPHER_ADD_ISUBSET
+#ifndef OLN_MORPHER_ADD_ISUBSET_HH
+# define OLN_MORPHER_ADD_ISUBSET_HH
# include <oln/core/abstract/image.hh>
# include <oln/core/abstract/image/type/binary.hh>
@@ -93,34 +93,9 @@
protected:
topo_t topo_;
};
- -
- -
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename Image, typename Isubset>
- - add_isubset<Image, Isubset>::add_isubset(const Image& image, const Isubset& isubset) :
- - super_t(image),
- - topo_(image.topo(), isubset)
- - {
- - // mlc::assert_equal_<oln_vtype(Image, grid), oln_vtype(Isubset, grid)>::check();
- - // FIXME: check that Image is without a isubset
- - }
- -
- - template <typename Image, typename Isubset>
- - const typename add_isubset<Image, Isubset>::topo_t&
- - add_isubset<Image, Isubset>::impl_topo() const
- - {
- - return topo_;
- - }
- -
- -# endif
- -
- -
} // end of namespace oln::morpher
- -
template <typename I, typename S>
morpher::add_isubset<I, S>
operator | (const abstract::image<I>& image,
@@ -135,33 +110,10 @@
operator | (const abstract::image<I>& image,
const xtd::abstract::fun_nary_expr_<1,S>& fsubset);
- -
+} // end of namespace oln
# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename I, typename S>
- - morpher::add_isubset<I, S>
- - operator | (const abstract::image<I>& image,
- - const abstract::binary_image<S>& isubset)
- - {
- - mlc::assert_equal_<oln_vtype(I, grid), oln_vtype(S, grid)>::check();
- - // FIXME: check that Image does not have yet a subset
- - morpher::add_isubset<I, S> tmp(image.exact(), isubset.exact());
- - return tmp;
- - }
- -
- - template <typename I, typename S>
- - morpher::add_isubset<I, S>
- - operator | (const abstract::image<I>& image,
- - const xtd::abstract::fun_nary_expr_<1,S>& fsubset)
- - {
- - morpher::add_isubset<I, S> tmp(image.exact(), fsubset.exact_());
- - return tmp;
- - }
- -
+# include "add_isubset.hxx"
# endif
- -} // end of namespace oln
- -
- -
- -#endif // ! OLN_MORPHER_ADD_ISUBSET
+#endif // ! OLN_MORPHER_ADD_ISUBSET_HH
Index: oln/morpher/value_cast.hh
===================================================================
- --- oln/morpher/value_cast.hh (revision 719)
+++ oln/morpher/value_cast.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,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
- -#ifndef OLN_MORPHER_VALUE_CAST
- -# define OLN_MORPHER_VALUE_CAST
+#ifndef OLN_MORPHER_VALUE_CAST_HH
+# define OLN_MORPHER_VALUE_CAST_HH
# include <xtd/abstract/open_nary_fun.hh>
# include <xtd/res.hh>
@@ -86,17 +86,6 @@
value_cast(const Image& image);
};
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename Image, typename Value>
- - value_cast<Image, Value>::value_cast(const Image& image) :
- - super_t(image)
- - {
- - }
- -
- -# endif
- -
} // end of namespace oln::morpher
@@ -105,21 +94,11 @@
value_cast(const abstract::image<I>& ima);
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename Value, typename I>
- - morpher::value_cast<I, Value>
- - value_cast(const abstract::image<I>& ima)
- - {
- - morpher::value_cast<I, Value> tmp(ima.exact());
- - return tmp;
- - }
- -
- -# endif
- -
- -
} // end of namespace oln
+# ifndef OLN_INCLUDE_ONLY
+# include "value_cast.hxx"
+# endif
- -#endif // ! OLN_MORPHER_VALUE_CAST
+#endif // ! OLN_MORPHER_VALUE_CAST_HH
Index: oln/morpher/add_neighborhood.hxx
===================================================================
- --- oln/morpher/add_neighborhood.hxx (revision 0)
+++ oln/morpher/add_neighborhood.hxx (revision 0)
@@ -0,0 +1,82 @@
+// 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_MORPHER_ADD_NEIGHBORHOOD_HXX
+# define OLN_MORPHER_ADD_NEIGHBORHOOD_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+
+ template <typename Image, typename Neighb>
+ add_neighborhood<Image, Neighb>::add_neighborhood(const Image& image, const Neighb& nbh) :
+ super_t(image),
+ topo_(image.topo(), nbh)
+ {
+ mlc::assert_equal_<oln_vtype(Image, grid), oln_vtype(Neighb, grid)>::check();
+ // FIXME: check that Image is without a nbh
+ }
+
+ template <typename Image, typename Neighb>
+ const typename add_neighborhood<Image, Neighb>::topo_t&
+ add_neighborhood<Image, Neighb>::impl_topo() const
+ {
+ return topo_;
+ }
+
+ } // end of namespace oln::morpher
+
+
+ template <typename I, typename N>
+ morpher::add_neighborhood<I, N>
+ operator + (const abstract::image<I>& image,
+ const abstract::neighborhood<N>& nbh)
+ {
+ mlc::assert_equal_<oln_vtype(I, grid), oln_vtype(N, grid)>::check();
+ // FIXME: check that Image is without a nbh
+ morpher::add_neighborhood<I, N> tmp(image.exact(), nbh.exact());
+ return tmp;
+ }
+
+} // end of namespace oln
+
+#endif // ! ADD_NEIGHBORHOOD_HXX
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: oln/morpher/two_way.hh
===================================================================
- --- oln/morpher/two_way.hh (revision 719)
+++ oln/morpher/two_way.hh (working copy)
@@ -109,56 +109,24 @@
} // end of namespace oln::morpher::ERROR
+ } // end of namespace oln::morpher
+
+} // end of namespace oln
+
# ifndef OLN_INCLUDE_ONLY
+# include "two_way.hxx"
+# endif
- - // public
+# include <oln/value/two_way.hxx>
+
+
+#endif // ! OLN_MORPHER_TWO_WAY_HH
- - template <typename Image, typename Fun>
- - two_way<Image, Fun>::two_way(Image& image) :
- - super_t(image),
- - fun_()
- - {
- - }
- -
- - template <typename Image, typename Fun>
- - two_way<Image, Fun>::two_way(Image& image, Fun fun) :
- - super_t(image),
- - fun_(fun)
- - {
- - }
- -
- - template <typename Image, typename Fun>
- - two_way<Image, Fun>::two_way(oln::abstract::mutable_image<Image>& image,
- - const oln::abstract::fun_v2w2v<Fun>& fun) :
- - super_t(image.exact()),
- - fun_(fun.exact())
- - {
- - }
- -
- - template <typename Image, typename Fun>
- - typename two_way<Image, Fun>::rvalue_t
- - two_way<Image, Fun>::impl_op_read(const typename two_way<Image, Fun>::psite_t& p) const
- - {
- - return fun_.direct(image_(p));
- - }
- -
- - template <typename Image, typename Fun>
- - typename two_way<Image, Fun>::lvalue_t
- - two_way<Image, Fun>::impl_op_readwrite(const typename two_way<Image, Fun>::psite_t& p)
- - {
- - value::two_way<Image, Fun> tmp(image_, fun_, p);
- - return tmp;
- - }
- -# endif
- - } // end of namespace oln::morpher
- -} // end of namespace oln
- -# include <oln/value/two_way.hxx>
- -#endif // ! OLN_MORPHER_TWO_WAY_HH
Index: oln/morpher/identity.hh
===================================================================
- --- oln/morpher/identity.hh (revision 719)
+++ oln/morpher/identity.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,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
- -#ifndef OLN_MORPHER_IDENTITY
- -# define OLN_MORPHER_IDENTITY
+#ifndef OLN_MORPHER_IDENTITY_HH
+# define OLN_MORPHER_IDENTITY_HH
# include <oln/morpher/internal/image_extension.hh>
@@ -82,4 +82,6 @@
} // end of namespace oln
- -#endif // ! OLN_MORPHER_IDENTITY
+#endif // ! OLN_MORPHER_IDENTITY_HH
+
+
Index: oln/morpher/thru_fun.hh
===================================================================
- --- oln/morpher/thru_fun.hh (revision 719)
+++ oln/morpher/thru_fun.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,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
- -#ifndef OLN_MORPHER_THRU_FUN
- -# define OLN_MORPHER_THRU_FUN
+#ifndef OLN_MORPHER_THRU_FUN_HH
+# define OLN_MORPHER_THRU_FUN_HH
# include <xtd/res.hh>
// For xtd::case_<xtd::tag::fun_operator_1, mlc::pair_<F, Expr>, 1>
@@ -149,4 +149,4 @@
- -#endif // ! OLN_MORPHER_THRU_FUN
+#endif // ! OLN_MORPHER_THRU_FUN_HH
Index: oln/morpher/value_cast.hxx
===================================================================
- --- oln/morpher/value_cast.hxx (revision 0)
+++ oln/morpher/value_cast.hxx (revision 0)
@@ -0,0 +1,68 @@
+// 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_MORPHER_VALUE_CAST_HXX
+# define OLN_MORPHER_VALUE_CAST_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+
+ template <typename Image, typename Value>
+ value_cast<Image, Value>::value_cast(const Image& image) :
+ super_t(image)
+ {
+ }
+
+ } // end of namespace oln::morpher
+
+ template <typename Value, typename I>
+ morpher::value_cast<I, Value>
+ value_cast(const abstract::image<I>& ima)
+ {
+ morpher::value_cast<I, Value> tmp(ima.exact());
+ return tmp;
+ }
+
+} // end of namespace oln
+
+#endif // ! OLN_MORPHER_VALUE_CAST_HXX
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: oln/morpher/add_isubset.hxx
===================================================================
- --- oln/morpher/add_isubset.hxx (revision 0)
+++ oln/morpher/add_isubset.hxx (revision 0)
@@ -0,0 +1,98 @@
+// 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_MORPHER_ADD_ISUBSET_HXX
+# define OLN_MORPHER_ADD_ISUBSET_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+
+ template <typename Image, typename Isubset>
+ add_isubset<Image, Isubset>::add_isubset(const Image& image, const Isubset& isubset) :
+ super_t(image),
+ topo_(image.topo(), isubset)
+ {
+ // mlc::assert_equal_<oln_vtype(Image, grid), oln_vtype(Isubset, grid)>::check();
+ // FIXME: check that Image is without a isubset
+ }
+
+ template <typename Image, typename Isubset>
+ const typename add_isubset<Image, Isubset>::topo_t&
+ add_isubset<Image, Isubset>::impl_topo() const
+ {
+ return topo_;
+ }
+
+ } // end of namespace oln::morpher
+
+
+ template <typename I, typename S>
+ morpher::add_isubset<I, S>
+ operator | (const abstract::image<I>& image,
+ const abstract::binary_image<S>& isubset)
+ {
+ mlc::assert_equal_<oln_vtype(I, grid), oln_vtype(S, grid)>::check();
+ // FIXME: check that Image does not have yet a subset
+ morpher::add_isubset<I, S> tmp(image.exact(), isubset.exact());
+ return tmp;
+ }
+
+ template <typename I, typename S>
+ morpher::add_isubset<I, S>
+ operator | (const abstract::image<I>& image,
+ const xtd::abstract::fun_nary_expr_<1,S>& fsubset)
+ {
+ morpher::add_isubset<I, S> tmp(image.exact(), fsubset.exact_());
+ return tmp;
+ }
+
+} // end of namespace oln
+
+
+#endif // ! OLN_MORPHER_ADD_ISUBSET_HXX
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: oln/morpher/with_lut.hh
===================================================================
- --- oln/morpher/with_lut.hh (revision 719)
+++ oln/morpher/with_lut.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
@@ -122,50 +122,6 @@
lut_type lut_;
};
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename Image, typename Lut>
- - with_lut<Image, Lut>::with_lut(const Image& image, const Lut& lut) :
- - super_t(image),
- - lut_(lut)
- - {
- - mlc::assert_equal_< oln_value(Image), typename Lut::orig_value_type >::check();
- - }
- -
- - template <typename Image, typename Lut>
- - typename with_lut<Image, Lut>::rvalue_type
- - with_lut<Image, Lut>::impl_op_read(const typename with_lut<Image, Lut>::psite_type& p) const
- - {
- - // FIXME: What if lut_ has no value for `this->image_(p)'? At
- - // least, document the behavior of this method (will it abort,
- - // does the LUT have to provide a default value, etc.)
- - return lut_(this->image_(p));
- - }
- -
- - template <typename Image, typename Lut>
- - typename with_lut<Image, Lut>::value_proxy_type
- - with_lut<Image, Lut>::impl_value(const value_type& v) const
- - {
- - return value_proxy_type(lut_, v);
- - }
- -
- - template <typename Image, typename Lut>
- - typename with_lut<Image, Lut>::mutable_value_proxy_type
- - with_lut<Image, Lut>::impl_value(const value_type& v)
- - {
- - return mutable_value_proxy_type(lut_, v);
- - }
- -
- - template <typename Image, typename Lut>
- - const typename with_lut<Image, Lut>::lut_type&
- - with_lut<Image, Lut>::lut() const
- - {
- - return lut_;
- - }
- -
- -# endif
- -
} // end of namespace oln::morpher
@@ -176,23 +132,11 @@
operator + (const abstract::image<I>& image,
lookup_table<K, D>& lut);
+} // end of namespace oln
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename I, typename K, typename D>
- - morpher::with_lut< I, lookup_table<K, D> >
- - operator + (const abstract::image<I>& image,
- - lookup_table<K, D>& lut)
- - {
- - typedef lookup_table<K, D> lut_type;
- - mlc::assert_equal_< oln_value(I), typename lut_type::orig_value_type >::check();
- - morpher::with_lut<I, lut_type> tmp(image.exact(), lut);
- - return tmp;
- - }
+# ifndef OLN_INCLUDE_ONLY
+# include "with_lut.hxx"
# endif
- -} // end of namespace oln
- -
- -
#endif // ! OLN_MORPHER_WITH_LUT_HH
Index: oln/morpher/count_rw.hh
===================================================================
- --- oln/morpher/count_rw.hh (revision 719)
+++ oln/morpher/count_rw.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
@@ -99,41 +99,6 @@
} // end of namespace oln::morpher::ERROR
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - // public
- -
- - template <typename Image>
- - count_rw_<Image>::count_rw_(Image& image) :
- - super_t(image)
- - {
- - }
- -
- - template <typename Image>
- - count_rw_<Image>::count_rw_(oln::abstract::mutable_image<Image>& image) :
- - super_t(image.exact())
- - {
- - }
- -
- - template <typename Image>
- - oln_rvalue(count_rw_<Image>)
- - count_rw_<Image>::impl_op_read(const oln_psite(count_rw_<Image>)& p) const
- - {
- - value::ro_counter<Image> tmp(image_, p);
- - return tmp;
- - }
- -
- - template <typename Image>
- - oln_lvalue(count_rw_<Image>)
- - count_rw_<Image>::impl_op_readwrite(const oln_psite(count_rw_<Image>)& p)
- - {
- - value::rw_counter<Image> tmp(image_, p);
- - return tmp;
- - }
- -
- -# endif
- -
} // end of namespace oln::morpher
@@ -145,31 +110,10 @@
morpher::count_rw_<I>
count_rw(const oln::abstract::mutable_image<I>& input);
+} // end of namespace oln
# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename I>
- - morpher::count_rw_<I>
- - count_rw(oln::abstract::mutable_image<I>& input)
- - {
- - morpher::count_rw_<I> tmp(input.exact());
- - return tmp;
- - }
- -
- - template <typename I>
- - morpher::count_rw_<I>
- - count_rw(const oln::abstract::mutable_image<I>& input)
- - {
- - // FIXME: Hack.
- - I& input_ = const_cast<I&>(input.exact());
- - morpher::count_rw_<I> tmp(input_);
- - return tmp;
- - }
- -
+# include "count_rw.hxx"
# endif
- -
- -} // end of namespace oln
- -
- -
#endif // ! OLN_MORPHER_COUNT_RW_HH
Index: oln/morpher/two_way_rw.hh
===================================================================
- --- oln/morpher/two_way_rw.hh (revision 719)
+++ oln/morpher/two_way_rw.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
@@ -108,47 +108,13 @@
} // end of namespace oln::morpher::ERROR
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - // public
- -
- - template <typename Image, typename Fun>
- - two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image) :
- - super_t(image.exact()),
- - fun_()
- - {
- - }
- -
- - template <typename Image, typename Fun>
- - two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image,
- - const oln::abstract::fun_rw<Fun>& fun) :
- - super_t(image.exact()),
- - fun_(fun.exact())
- - {
- - }
- -
- - template <typename Image, typename Fun>
- - typename two_way_rw<Image, Fun>::rvalue_t
- - two_way_rw<Image, Fun>::impl_op_read(const typename two_way_rw<Image, Fun>::psite_t& p) const
- - {
- - return fun_.read(this->delegate(), p);
- - }
- -
- - template <typename Image, typename Fun>
- - typename two_way_rw<Image, Fun>::lvalue_t
- - two_way_rw<Image, Fun>::impl_op_readwrite(const typename two_way_rw<Image, Fun>::psite_t& p)
- - {
- - typename two_way_rw<Image, Fun>::lvalue_t tmp(this->delegate(), p);
- - return tmp;
- - }
- -
- -# endif
- -
} // end of namespace oln::morpher
} // end of namespace oln
+# ifndef OLN_INCLUDE_ONLY
+# include "two_way_rw.hxx"
+# endif
# include <oln/value/two_way.hxx>
Index: oln/morpher/identity.hxx
===================================================================
- --- oln/morpher/identity.hxx (revision 0)
+++ oln/morpher/identity.hxx (revision 0)
@@ -0,0 +1,55 @@
+// 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_MORPHER_IDENTITY_HXX
+# define OLN_MORPHER_IDENTITY_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+
+ template <typename Image>
+ identity<Image>::identity(const Image& image) :
+ super_t(image)
+ {
+ }
+
+ } // end of namespace oln::morpher
+
+} // end of namespace oln
+
+
+# endif // ! OLN_MORPHER_IDENTITY_HXX
+
+
+
+
+
+
+
Index: oln/morpher/two_way.hxx
===================================================================
- --- oln/morpher/two_way.hxx (revision 0)
+++ oln/morpher/two_way.hxx (revision 0)
@@ -0,0 +1,80 @@
+// 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_MORPHER_TWO_WAY_HXX
+# define OLN_MORPHER_TWO_WAY_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+
+ // public
+
+ template <typename Image, typename Fun>
+ two_way<Image, Fun>::two_way(Image& image) :
+ super_t(image),
+ fun_()
+ {
+ }
+
+ template <typename Image, typename Fun>
+ two_way<Image, Fun>::two_way(Image& image, Fun fun) :
+ super_t(image),
+ fun_(fun)
+ {
+ }
+
+ template <typename Image, typename Fun>
+ two_way<Image, Fun>::two_way(oln::abstract::mutable_image<Image>& image,
+ const oln::abstract::fun_v2w2v<Fun>& fun) :
+ super_t(image.exact()),
+ fun_(fun.exact())
+ {
+ }
+
+ template <typename Image, typename Fun>
+ typename two_way<Image, Fun>::rvalue_t
+ two_way<Image, Fun>::impl_op_read(const typename two_way<Image, Fun>::psite_t& p) const
+ {
+ return fun_.direct(image_(p));
+ }
+
+ template <typename Image, typename Fun>
+ typename two_way<Image, Fun>::lvalue_t
+ two_way<Image, Fun>::impl_op_readwrite(const typename two_way<Image, Fun>::psite_t& p)
+ {
+ value::two_way<Image, Fun> tmp(image_, fun_, p);
+ return tmp;
+ }
+
+ } // end of namespace oln::morpher
+
+} // end of namespace oln
+
+#endif // ! OLN_MORPHER_TWO_WAY_HXX
Index: oln/morpher/stack.hh
===================================================================
- --- oln/morpher/stack.hh (revision 719)
+++ oln/morpher/stack.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
@@ -90,36 +90,6 @@
xtd::vec<n, I> images_;
};
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <unsigned n, typename I>
- - stack<n, I>::stack(const xtd::vec<n, I>& images) :
- - super_t(images[0]),
- - images_(images)
- - {
- - }
- -
- - template <unsigned n, typename I>
- - xtd::vec<n, oln_value(I)>
- - stack<n, I>::impl_op_read(const typename stack<n, I>::psite_t& p) const
- - {
- - xtd::vec<n, oln_value(I)> tmp;
- - for (unsigned i = 0; i < n; ++i)
- - tmp[i] = images_[i](p);
- - return tmp;
- - }
- -
- - template <unsigned n, typename I>
- - const I&
- - stack<n, I>::image(unsigned i) const
- - {
- - precondition(i < n);
- - return images_[i];
- - }
- -
- -# endif
- -
} // end of namespace oln::morpher
@@ -141,49 +111,10 @@
const abstract::image<I>& image_2,
const abstract::image<I>& image_3);
+} // end of namespace oln
# ifndef OLN_INCLUDE_ONLY
- -
- -
- - template <typename I>
- - morpher::stack<2, I>
- - stack(const abstract::image<I>& image_0,
- - const abstract::image<I>& image_1)
- - {
- - morpher::stack<2, I> tmp(xtd::mk_vec(image_0.exact(),
- - image_1.exact()));
- - return tmp;
- - }
- -
- - template <typename I>
- - morpher::stack<3, I>
- - stack(const abstract::image<I>& image_0,
- - const abstract::image<I>& image_1,
- - const abstract::image<I>& image_2)
- - {
- - morpher::stack<3, I> tmp(xtd::mk_vec(image_0.exact(),
- - image_1.exact(),
- - image_2.exact()));
- - return tmp;
- - }
- -
- - template <typename I>
- - morpher::stack<4, I>
- - stack(const abstract::image<I>& image_0,
- - const abstract::image<I>& image_1,
- - const abstract::image<I>& image_2,
- - const abstract::image<I>& image_3)
- - {
- - morpher::stack<4, I> tmp(xtd::mk_vec(image_0.exact(),
- - image_1.exact(),
- - image_2.exact(),
- - image_3.exact()));
- - return tmp;
- - }
- -
+# include "stack.hxx"
# endif
- -} // end of namespace oln
- -
- -
#endif // ! OLN_MORPHER_STACK_HH
Index: oln/morpher/thru_mfun.hh
===================================================================
- --- oln/morpher/thru_mfun.hh (revision 719)
+++ oln/morpher/thru_mfun.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,8 +25,8 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
- -#ifndef OLN_MORPHER_THRU_MFUN
- -# define OLN_MORPHER_THRU_MFUN
+#ifndef OLN_MORPHER_THRU_MFUN_HH
+# define OLN_MORPHER_THRU_MFUN_HH
# include <xtd/res.hh>
# include <xtd/abstract/open_nary_fun.hh>
@@ -107,35 +107,8 @@
} // end of namespace oln::morpher::ERROR
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename Image, typename Fun>
- - thru_mfun<Image, Fun>::thru_mfun(const Image& image, const Fun& fun) :
- - super_t(image),
- - fun_(fun)
- - {
- - }
- -
- - template <typename Image, typename Fun>
- - typename thru_mfun<Image, Fun>::rvalue_t
- - thru_mfun<Image, Fun>::impl_op_read(const typename thru_mfun<Image, Fun>::psite_t& p) const
- - {
- - return fun_(this->image_(p));
- - }
- -
- - template <typename Image, typename Fun>
- - typename thru_mfun<Image, Fun>::lvalue_t
- - thru_mfun<Image, Fun>::impl_op_readwrite(const typename thru_mfun<Image, Fun>::psite_t& p)
- - {
- - return fun_(this->image_(p));
- - }
- -
- -# endif
- -
} // end of namespace oln::morpher
- -
} // end of namespace oln
@@ -177,5 +150,9 @@
} // end of namespace xtd
+# ifndef OLN_INCLUDE_ONLY
+# include "thru_mfun.hxx"
+# endif
+
+#endif // ! OLN_MORPHER_THRU_MFUN_HH
- -#endif // ! OLN_MORPHER_THRU_MFUN
Index: oln/morpher/with_lut.hxx
===================================================================
- --- oln/morpher/with_lut.hxx (revision 0)
+++ oln/morpher/with_lut.hxx (revision 0)
@@ -0,0 +1,91 @@
+// 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_MORPHER_WITH_LUT_HXX
+# define OLN_MORPHER_WITH_LUT_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+
+ template <typename Image, typename Lut>
+ with_lut<Image, Lut>::with_lut(const Image& image, const Lut& lut) :
+ super_t(image),
+ lut_(lut)
+ {
+ mlc::assert_equal_< oln_value(Image), typename Lut::orig_value_type >::check();
+ }
+
+ template <typename Image, typename Lut>
+ typename with_lut<Image, Lut>::rvalue_type
+ with_lut<Image, Lut>::impl_op_read(const typename with_lut<Image, Lut>::psite_type& p) const
+ {
+ // FIXME: What if lut_ has no value for `this->image_(p)'? At
+ // least, document the behavior of this method (will it abort,
+ // does the LUT have to provide a default value, etc.)
+ return lut_(this->image_(p));
+ }
+
+ template <typename Image, typename Lut>
+ typename with_lut<Image, Lut>::value_proxy_type
+ with_lut<Image, Lut>::impl_value(const value_type& v) const
+ {
+ return value_proxy_type(lut_, v);
+ }
+
+ template <typename Image, typename Lut>
+ typename with_lut<Image, Lut>::mutable_value_proxy_type
+ with_lut<Image, Lut>::impl_value(const value_type& v)
+ {
+ return mutable_value_proxy_type(lut_, v);
+ }
+
+ template <typename Image, typename Lut>
+ const typename with_lut<Image, Lut>::lut_type&
+ with_lut<Image, Lut>::lut() const
+ {
+ return lut_;
+ }
+
+ } // end of namespace oln::morpher
+
+ template <typename I, typename K, typename D>
+ morpher::with_lut< I, lookup_table<K, D> >
+ operator + (const abstract::image<I>& image,
+ lookup_table<K, D>& lut)
+ {
+ typedef lookup_table<K, D> lut_type;
+ mlc::assert_equal_< oln_value(I), typename lut_type::orig_value_type >::check();
+ morpher::with_lut<I, lut_type> tmp(image.exact(), lut);
+ return tmp;
+ }
+
+} // end of namespace oln
+
+#endif // ! OLN_MORPHER_WITH_LUT_HXX
Index: oln/morpher/count_rw.hxx
===================================================================
- --- oln/morpher/count_rw.hxx (revision 0)
+++ oln/morpher/count_rw.hxx (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_MORPHER_COUNT_RW_HXX
+# define OLN_MORPHER_COUNT_RW_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+ // public
+
+ template <typename Image>
+ count_rw_<Image>::count_rw_(Image& image) :
+ super_t(image)
+ {
+ }
+
+ template <typename Image>
+ count_rw_<Image>::count_rw_(oln::abstract::mutable_image<Image>& image) :
+ super_t(image.exact())
+ {
+ }
+
+ template <typename Image>
+ oln_rvalue(count_rw_<Image>)
+ count_rw_<Image>::impl_op_read(const oln_psite(count_rw_<Image>)& p) const
+ {
+ value::ro_counter<Image> tmp(image_, p);
+ return tmp;
+ }
+
+ template <typename Image>
+ oln_lvalue(count_rw_<Image>)
+ count_rw_<Image>::impl_op_readwrite(const oln_psite(count_rw_<Image>)& p)
+ {
+ value::rw_counter<Image> tmp(image_, p);
+ return tmp;
+ }
+
+ } // end of namespace oln::morpher
+
+
+ template <typename I>
+ morpher::count_rw_<I>
+ count_rw(oln::abstract::mutable_image<I>& input)
+ {
+ morpher::count_rw_<I> tmp(input.exact());
+ return tmp;
+ }
+
+ template <typename I>
+ morpher::count_rw_<I>
+ count_rw(const oln::abstract::mutable_image<I>& input)
+ {
+ // FIXME: Hack.
+ I& input_ = const_cast<I&>(input.exact());
+ morpher::count_rw_<I> tmp(input_);
+ return tmp;
+ }
+
+} // end of namespace oln
+
+#endif // ! OLN_MORPHER_COUNT_RW_HH
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: oln/morpher/two_way_rw.hxx
===================================================================
- --- oln/morpher/two_way_rw.hxx (revision 0)
+++ oln/morpher/two_way_rw.hxx (revision 0)
@@ -0,0 +1,79 @@
+// 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_MORPHER_TWO_WAY_RW_HXX
+# define OLN_MORPHER_TWO_WAY_RW_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+ // public
+
+ template <typename Image, typename Fun>
+ two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image) :
+ super_t(image.exact()),
+ fun_()
+ {
+ }
+
+ template <typename Image, typename Fun>
+ two_way_rw<Image, Fun>::two_way_rw(oln::abstract::mutable_image<Image>& image,
+ const oln::abstract::fun_rw<Fun>& fun) :
+ super_t(image.exact()),
+ fun_(fun.exact())
+ {
+ }
+
+ template <typename Image, typename Fun>
+ typename two_way_rw<Image, Fun>::rvalue_t
+ two_way_rw<Image, Fun>::impl_op_read(const typename two_way_rw<Image, Fun>::psite_t& p) const
+ {
+ return fun_.read(this->delegate(), p);
+ }
+
+ template <typename Image, typename Fun>
+ typename two_way_rw<Image, Fun>::lvalue_t
+ two_way_rw<Image, Fun>::impl_op_readwrite(const typename two_way_rw<Image, Fun>::psite_t& p)
+ {
+ typename two_way_rw<Image, Fun>::lvalue_t tmp(this->delegate(), p);
+ return tmp;
+ }
+
+ } // end of namespace oln::morpher
+
+} // end of namespace oln
+
+#endif // ! OLN_MORPHER_TWO_WAY_RW_HXX
+
+
+
+
+
+
+
Index: oln/morpher/stack_rw.hh
===================================================================
- --- oln/morpher/stack_rw.hh (revision 719)
+++ oln/morpher/stack_rw.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
@@ -120,52 +120,6 @@
xtd::vec<n, I> images_;
};
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <unsigned n, typename I>
- - stack_rw<n, I>::stack_rw(const xtd::vec<n, I>& images) :
- - super_t(images[0]),
- - images_(images)
- - {
- - }
- -
- - template <unsigned n, typename I>
- - xtd::vec<n, oln_value(I)>
- - stack_rw<n, I>::impl_op_read(const typename stack_rw<n, I>::psite_t& p) const
- - {
- - xtd::vec<n, oln_value(I)> tmp;
- - for (unsigned i = 0; i < n; ++i)
- - tmp[i] = images_[i](p);
- - return tmp;
- - }
- -
- - template <unsigned n, typename I>
- - typename stack_rw<n, I>::lvalue_t
- - stack_rw<n, I>::impl_op_readwrite(const typename stack_rw<n, I>::psite_t& p)
- - {
- - lvalue_t tmp(*this, p);
- - return tmp;
- - }
- -
- - template <unsigned n, typename I>
- - const I&
- - stack_rw<n, I>::image(unsigned i) const
- - {
- - precondition(i < n);
- - return images_[i];
- - }
- -
- - template <unsigned n, typename I>
- - I&
- - stack_rw<n, I>::image(unsigned i)
- - {
- - precondition(i < n);
- - return images_[i];
- - }
- -
- -# endif
- -
} // end of namespace oln::morpher
@@ -187,52 +141,18 @@
abstract::mutable_image<I>& image_2,
abstract::mutable_image<I>& image_3);
+} // end of namespace oln
# ifndef OLN_INCLUDE_ONLY
+# include "stack_rw.hxx"
+# endif
+# include <oln/value/two_way.hxx>
- - template <typename I>
- - morpher::stack_rw<2, I>
- - stack_rw(abstract::mutable_image<I>& image_0,
- - abstract::mutable_image<I>& image_1)
- - {
- - morpher::stack_rw<2, I> tmp(xtd::mk_vec(image_0.exact(),
- - image_1.exact()));
- - return tmp;
- - }
- -
- - template <typename I>
- - morpher::stack_rw<3, I>
- - stack_rw(abstract::mutable_image<I>& image_0,
- - abstract::mutable_image<I>& image_1,
- - abstract::mutable_image<I>& image_2)
- - {
- - morpher::stack_rw<3, I> tmp(xtd::mk_vec(image_0.exact(),
- - image_1.exact(),
- - image_2.exact()));
- - return tmp;
- - }
- -
- - template <typename I>
- - morpher::stack_rw<4, I>
- - stack_rw(abstract::mutable_image<I>& image_0,
- - abstract::mutable_image<I>& image_1,
- - abstract::mutable_image<I>& image_2,
- - abstract::mutable_image<I>& image_3)
- - {
- - morpher::stack_rw<4, I> tmp(xtd::mk_vec(image_0.exact(),
- - image_1.exact(),
- - image_2.exact(),
- - image_3.exact()));
- - return tmp;
- - }
- -# endif
+#endif // ! OLN_MORPHER_STACK_RW_HH
- -} // end of namespace oln
- -# include <oln/value/two_way.hxx>
- -#endif // ! OLN_MORPHER_STACK_RW_HH
Index: oln/morpher/stack.hxx
===================================================================
- --- oln/morpher/stack.hxx (revision 0)
+++ oln/morpher/stack.hxx (revision 0)
@@ -0,0 +1,121 @@
+// 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_MORPHER_STACK_HXX
+# define OLN_MORPHER_STACK_HXX
+
+namespace oln
+{
+
+ namespace morpher
+ {
+
+ template <unsigned n, typename I>
+ stack<n, I>::stack(const xtd::vec<n, I>& images) :
+ super_t(images[0]),
+ images_(images)
+ {
+ }
+
+ template <unsigned n, typename I>
+ xtd::vec<n, oln_value(I)>
+ stack<n, I>::impl_op_read(const typename stack<n, I>::psite_t& p) const
+ {
+ xtd::vec<n, oln_value(I)> tmp;
+ for (unsigned i = 0; i < n; ++i)
+ tmp[i] = images_[i](p);
+ return tmp;
+ }
+
+ template <unsigned n, typename I>
+ const I&
+ stack<n, I>::image(unsigned i) const
+ {
+ precondition(i < n);
+ return images_[i];
+ }
+
+ } // end of namespace oln::morpher
+
+
+ template <typename I>
+ morpher::stack<2, I>
+ stack(const abstract::image<I>& image_0,
+ const abstract::image<I>& image_1)
+ {
+ morpher::stack<2, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact()));
+ return tmp;
+ }
+
+ template <typename I>
+ morpher::stack<3, I>
+ stack(const abstract::image<I>& image_0,
+ const abstract::image<I>& image_1,
+ const abstract::image<I>& image_2)
+ {
+ morpher::stack<3, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact(),
+ image_2.exact()));
+ return tmp;
+ }
+
+ template <typename I>
+ morpher::stack<4, I>
+ stack(const abstract::image<I>& image_0,
+ const abstract::image<I>& image_1,
+ const abstract::image<I>& image_2,
+ const abstract::image<I>& image_3)
+ {
+ morpher::stack<4, I> tmp(xtd::mk_vec(image_0.exact(),
+ image_1.exact(),
+ image_2.exact(),
+ image_3.exact()));
+ return tmp;
+ }
+
+
+} // end of namespace oln
+
+#endif // ! OLN_MORPHER_STACK_HXX
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: oln/morpher/add_neighborhood.hh
===================================================================
- --- oln/morpher/add_neighborhood.hh (revision 719)
+++ oln/morpher/add_neighborhood.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
@@ -95,27 +95,6 @@
topo_t topo_;
};
- -
- -# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename Image, typename Neighb>
- - add_neighborhood<Image, Neighb>::add_neighborhood(const Image& image, const Neighb& nbh) :
- - super_t(image),
- - topo_(image.topo(), nbh)
- - {
- - mlc::assert_equal_<oln_vtype(Image, grid), oln_vtype(Neighb, grid)>::check();
- - // FIXME: check that Image is without a nbh
- - }
- -
- - template <typename Image, typename Neighb>
- - const typename add_neighborhood<Image, Neighb>::topo_t&
- - add_neighborhood<Image, Neighb>::impl_topo() const
- - {
- - return topo_;
- - }
- -
- -# endif
- -
} // end of namespace oln::morpher
@@ -124,23 +103,10 @@
morpher::add_neighborhood<I, N>
operator + (const abstract::image<I>& image, const abstract::neighborhood<N>& nbh);
+} // end of namespace oln
# ifndef OLN_INCLUDE_ONLY
- -
- - template <typename I, typename N>
- - morpher::add_neighborhood<I, N>
- - operator + (const abstract::image<I>& image,
- - const abstract::neighborhood<N>& nbh)
- - {
- - mlc::assert_equal_<oln_vtype(I, grid), oln_vtype(N, grid)>::check();
- - // FIXME: check that Image is without a nbh
- - morpher::add_neighborhood<I, N> tmp(image.exact(), nbh.exact());
- - return tmp;
- - }
- -
+# include "add_neighborhood.hxx"
# endif
- -} // end of namespace oln
- -
- -
#endif // ! OLN_MORPHER_ADD_NEIGHBORHOOD_HH
Index: oln/morpher/thru_mfun.hxx
===================================================================
- --- oln/morpher/thru_mfun.hxx (revision 0)
+++ oln/morpher/thru_mfun.hxx (revision 0)
@@ -0,0 +1,64 @@
+// 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_MORPHER_THRU_MFUN_HXX
+# define OLN_MORPHER_THRU_MFUN_HXX
+
+namespace oln
+{
+
+ template <typename Image, typename Fun>
+ thru_mfun<Image, Fun>::thru_mfun(const Image& image, const Fun& fun) :
+ super_t(image),
+ fun_(fun)
+ {
+ }
+
+ template <typename Image, typename Fun>
+ typename thru_mfun<Image, Fun>::rvalue_t
+ thru_mfun<Image, Fun>::impl_op_read(const typename thru_mfun<Image, Fun>::psite_t& p) const
+ {
+ return fun_(this->image_(p));
+ }
+
+ template <typename Image, typename Fun>
+ typename thru_mfun<Image, Fun>::lvalue_t
+ thru_mfun<Image, Fun>::impl_op_readwrite(const typename thru_mfun<Image, Fun>::psite_t& p)
+ {
+ return fun_(this->image_(p));
+ }
+
+} // end of namespace oln
+
+#endif // ! OLN_MORPHER_THRU_MFUN_HXX
+
+
+
+
+
+
+
- --
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFFsPgX8QvmnUS5oeMRAmnZAJ98z1U0wa1aaIrCpzYqTlE1R4qW1wCgjCrC
7+Mj9v9MonIXqSS1lLptrYA=
=TXwv
-----END PGP SIGNATURE-----
1
0
03 Jan '07
2007-01-03 Roland Levillain <roland(a)lrde.epita.fr>
New versions of Salembier et al. algorithm.
* oln/lrde/ufmt/generic_salembier.hh
(oln::lrde::ufmt::generic_salembier): Add a second template
parameter, defaulting to std::greater< oln_value_type(I) >. Use
this parameter for comparisons, to have the algorithm be more
flexible.
* oln/lrde/ufmt/bin/generic_salembier_float2.cc: New.
Use the second template parameter of
oln::lrde::ufmt::generic_salembier to create a more flexible
version of generic_salembier_float where float comparisons are
performed using a maxium relative error and a maximum absolute
error.
* oln/lrde/ufmt/generic_simplified_salembier.hh: New.
A simplified version of oln::lrde::ufmt::generic_salembier,
specially useful on float images.
* oln/lrde/ufmt/bin/generic_simplified_salembier_float.cc: New.
* oln/lrde/ufmt/naive_generic_salembier.hh: New.
A previous attempt before generic_simplified_salembier.
* oln/lrde/ufmt/basic_salembier.hh: More documentation.
* oln/lrde/ufmt/bin/basic_najman.cc: Typo.
* oln/lrde/ufmt/README: Document Salembier et al. algorithm variants.
* oln/lrde/ufmt/bin/Makefile.am (check_PROGRAMS): Add
generic_salembier_float2, generic_simplified_salembier_float
and naive_generic_salembier_float.
(generic_salembier_float2_SOURCES)
(generic_salembier_float2_LDFLAGS)
(generic_simplified_salembier_float_SOURCES)
(generic_simplified_salembier_float_LDFLAGS)
(naive_generic_salembier_float_SOURCES)
(naive_generic_salembier_float_LDFLAGS): New.
* oln/lrde/ufmt/Makefile.am (noinst_HEADERS): Add
generic_simplified_salembier.hh and naive_generic_salembier.hh.
--- 10.269/olena/oln/lrde/ufmt/basic_salembier.hh Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/w/51_basic_sale 1.2 644)
+++ 10.270/olena/oln/lrde/ufmt/basic_salembier.hh Wed, 03 Jan 2007 15:17:57 +0100 levill_r (oln/w/51_basic_sale 1.3 644)
@@ -119,7 +119,47 @@
};
- /// Salembier's algorithm -- Version for images of unsigned integers.
+ /** \brief Salembier's algorithm -- Version for images of
+ unsigned integers.
+
+ The (corrected) algorithm, as written in the original
+ article, is as follows:
+
+ \verbatim
+
+ flood (h)
+
+ while not hqueue-empty (h)
+ p <- hqueue-first (h)
+ STATUS(p) <- number-nodes (h)
+ for every neighbor q of p
+ if STATUS(q) == "Not analyzed"
+ hqueue-add(ORI(q), q)
+ STATUS(q) <- "In the queue"
+ node-at-level(ORI(q)) <- true
+ if (ORI(q) > ORI(p))
+ m = ORI(q)
+ repeat
+ m <- flood(m)
+ until m <= h
+ number-nodes(h) <- number-nodes(h) + 1
+
+ m <- h - 1
+ while m >= 0 and node-at-level(m) == false
+ m <- m - 1
+ i <- number-nodes(h) - 1
+ if m >= 0
+ j <- number-nodes(m)
+ father of C(i, h) <- node C(j, m)
+ else
+ C(i, h) has no father // C(i, h) is root node.
+ node-at-level(h) <- false
+ return m
+
+ \endverbatim
+
+ \ref salembier.98.itip. */
+
template <class I>
struct basic_salembier
{
--- 10.269/olena/oln/lrde/ufmt/README Tue, 29 Aug 2006 14:48:46 +0200 levill_r (oln/x/22_README 1.6 644)
+++ 10.270/olena/oln/lrde/ufmt/README Wed, 03 Jan 2007 15:17:57 +0100 levill_r (oln/x/22_README 1.7 644)
@@ -123,11 +123,50 @@
spx impled
-* basic_salembier
+* algorithms deriving from Salembier et al. algorithm
+
+** basic_salembier
+
+flooding
+p as point2d
+father as std::map<pair_t, pair_t>
+hqueue as an array of std::queue<point>
+works only on image of unsigned integers (unsigned int or ntg::int_u8
+ for instance)
+
+** generic_salembier
+
+flooding
+p as point2d
+father as std::map<pair, pair>
+hqueue as std::map<value, std::queue<point> >
+modifiable comparison function on values (defaulting to
+ std::greater< oln_value_type(I) >)
+works only on any kind of image whose values are comparable
+
+** generic_simplified_salembier
+
+flooding
+the algorithm consider that each site (pixel) has a unique ``value''
+ within the image (the algorithm no longer works on levels, only on
+ points, which are totally ordered)
+p as point2d
+father as std::map<point, point, point_less<I, point> >
+no hqueue, but a set of points instead
+works on any kind of image whose values are comparable
+
+** naive_generic_salembier
+
+A previous version of generic_simplified_salembier, probablt no longer
+useful.
flooding
+the algorithm doesn't really handle flat zones (i.e., contiguous
+pixels having the same value).
p as point2d
-father as map<pair,pair>
+father as std::map<pair, pair>
+hqueue as std::map<V, P>
+works on any kind of image whose values are comparable
--- 10.269/olena/oln/lrde/ufmt/Makefile.am Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/x/26_Makefile.a 1.5 644)
+++ 10.270/olena/oln/lrde/ufmt/Makefile.am Wed, 03 Jan 2007 15:17:57 +0100 levill_r (oln/x/26_Makefile.a 1.6 644)
@@ -17,6 +17,8 @@
\
basic_salembier.hh \
generic_salembier.hh \
+ generic_simplified_salembier.hh \
+ naive_generic_salembier.hh \
\
fiorio-1.hh \
fiorio-2.hh \
--- 10.269/olena/oln/lrde/ufmt/bin/Makefile.am Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/x/29_Makefile.a 1.4 644)
+++ 10.270/olena/oln/lrde/ufmt/bin/Makefile.am Wed, 03 Jan 2007 15:17:57 +0100 levill_r (oln/x/29_Makefile.a 1.5 644)
@@ -1,10 +1,12 @@
AM_CXXFLAGS = -Wall -Werror -ansi -pedantic -ggdb -O3 -DNDEBUG
AM_LDFLAGS = $(ZLIB_LDFLAGS)
-check_PROGRAMS = \
- basic_maxtree basic_najman basic_salembier \
- generic_salembier_int_u8 generic_salembier_float \
- fiorio-1 fiorio-2 fiorio-3 \
+check_PROGRAMS = \
+ basic_maxtree basic_najman basic_salembier \
+ generic_salembier_int_u8 generic_salembier_float generic_salembier_float2 \
+ generic_simplified_salembier_float \
+ naive_generic_salembier_float \
+ fiorio-1 fiorio-2 fiorio-3 \
hdc_maxtree hpc_maxtree r1ic_maxtree rpc_maxtree
basic_maxtree_SOURCES = basic_maxtree.cc
@@ -14,6 +16,12 @@
generic_salembier_int_u8_SOURCES = generic_salembier_int_u8.cc
generic_salembier_float_SOURCES = generic_salembier_float.cc
generic_salembier_float_LDFLAGS = -lcfitsio $(ZLIB_LDFLAGS)
+generic_salembier_float2_SOURCES = generic_salembier_float2.cc
+generic_salembier_float2_LDFLAGS = -lcfitsio $(ZLIB_LDFLAGS)
+generic_simplified_salembier_float_SOURCES = generic_simplified_salembier_float.cc
+generic_simplified_salembier_float_LDFLAGS = -lcfitsio $(ZLIB_LDFLAGS)
+naive_generic_salembier_float_SOURCES = naive_generic_salembier_float.cc
+naive_generic_salembier_float_LDFLAGS = -lcfitsio $(ZLIB_LDFLAGS)
fiorio_1_SOURCES = fiorio.cc
fiorio_2_SOURCES = fiorio.cc
--- 10.269/olena/oln/lrde/ufmt/bin/basic_najman.cc Mon, 28 Aug 2006 18:17:59 +0200 berger_c (oln/x/43_basic_najm 1.1 644)
+++ 10.270/olena/oln/lrde/ufmt/bin/basic_najman.cc Wed, 03 Jan 2007 15:17:57 +0100 levill_r (oln/x/43_basic_najm 1.2 644)
@@ -11,7 +11,8 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " input.pgm c" << std::endl;
- std::cerr << "basic max-tree computation with union-find" << std::endl;
+ std::cerr << "basic max-tree computation with Najman et al. algorithm"
+ << std::endl;
// FIXME: get precise description...
exit(1);
}
--- 10.269/olena/oln/lrde/ufmt/naive_generic_salembier.hh Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/y/7_naive_gene 1.1 644)
+++ 10.270/olena/oln/lrde/ufmt/naive_generic_salembier.hh Wed, 03 Jan 2007 15:17:57 +0100 levill_r (oln/y/7_naive_gene 1.2 644)
@@ -25,6 +25,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
+
+// FIXME: This version of Salembier et al. algorithm has been
+// superseded by oln::lrde::ufmt::generic_simplified_salembier, and
+// should not be useful anymore.
+
+
#ifndef OLENA_LRDE_UFMT_NAIVE_GENERIC_SALEMBIER_HH
# define OLENA_LRDE_UFMT_NAIVE_GENERIC_SALEMBIER_HH
@@ -202,7 +208,7 @@
m = levels.find(f[q]);
if (m == levels.end())
abort();
- while (*m > h) // err. 2
+ while (m != levels.end() and *m > h) // err. 2
m = flood(*m);
}
}
--- 10.269/olena/oln/lrde/ufmt/generic_salembier.hh Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/y/8_generic_sa 1.1 644)
+++ 10.270/olena/oln/lrde/ufmt/generic_salembier.hh Wed, 03 Jan 2007 15:17:57 +0100 levill_r (oln/y/8_generic_sa 1.2 644)
@@ -115,7 +115,8 @@
};
- template <class I>
+ template < class I,
+ class Greater = std::greater< oln_value_type(I) > >
struct generic_salembier
{
typedef oln_point_type(I) point;
@@ -140,12 +141,15 @@
generic_hqueue_t<value, point> hqueue;
value h_min;
- typedef std::set< value, std::greater<value> > levels_t;
+ typedef std::set< value, Greater > levels_t;
typedef typename levels_t::const_iterator level_iterator;
// Set of all values present in the input image, sorting in
// descending order.
levels_t levels;
+ // Level comparison function.
+ Greater level_greater;
+
typedef std::pair<unsigned, value> pair_t;
std::map<pair_t, pair_t> father;
@@ -181,7 +185,7 @@
// Init levels.
levels.insert(f[p]);
// Find the global Only in 10.270: olena/oln/lrde/ufmt/bin/generic_salembier_float2.cc
Only in 10.270: olena/oln/lrde/ufmt/bin/generic_simplified_salembier_float.cc
Only in 10.270: olena/oln/lrde/ufmt/bin/naive_generic_salembier_float.cc
Only in 10.270: olena/oln/lrde/ufmt/generic_simplified_salembier.hh
minimum.
- if (f[p] < h_min)
+ if (level_greater(h_min, f[p])) // Was: f[p] < h_min
{
h_min = f[p];
p_min = p;
@@ -215,7 +219,7 @@
m = levels.find(f[q]);
if (m == levels.end())
abort();
- while (*m > h) // err. 2
+ while (m != levels.end() and *m > h) // err. 2
m = flood(*m);
}
}
--- 10.269/oln.prj
+++ 10.270/oln.prj
@@ -1,30 +1,47 @@
;; -*- Prcs -*-
(Created-By-Prcs-Version 1 3 3)
(Project-Description "Olena")
-(Project-Version oln 10 269)
-(Parent-Version oln 10 268)
-(Version-Log "2006-12-20 Roland Levillain <roland(a)lrde.epita.fr>
-
- Add a more generic version of Salembier's algorithm.
-
- * oln/lrde/ufmt/basic_salembier.hh
- (oln::lrde::ufmt::hqueue_t::print): New method.
- * oln/lrde/ufmt/generic_salembier.hh: New.
- * oln/lrde/ufmt/bin/basic_salembier.cc: Add a timer.
- * oln/lrde/ufmt/bin/generic_salembier_int_u8.cc,
- * oln/lrde/ufmt/bin/generic_salembier_float.cc: New.
- * oln/lrde/Makefile.am (SUBDIRS): Add efigi.
+(Project-Version oln 10 270)
+(Parent-Version oln 10 269)
+(Version-Log "2007-01-03 Roland Levillain <roland(a)lrde.epita.fr>
+
+ New versions of Salembier et al. algorithm.
+
+ * oln/lrde/ufmt/generic_salembier.hh
+ (oln::lrde::ufmt::generic_salembier): Add a second template
+ parameter, defaulting to std::greater< oln_value_type(I) >. Use
+ this parameter for comparisons, to have the algorithm be more
+ flexible.
+ * oln/lrde/ufmt/bin/generic_salembier_float2.cc: New.
+ Use the second template parameter of
+ oln::lrde::ufmt::generic_salembier to create a more flexible
+ version of generic_salembier_float where float comparisons are
+ performed using a maxium relative error and a maximum absolute
+ error.
+ * oln/lrde/ufmt/generic_simplified_salembier.hh: New.
+ A simplified version of oln::lrde::ufmt::generic_salembier,
+ specially useful on float images.
+ * oln/lrde/ufmt/bin/generic_simplified_salembier_float.cc: New.
+ * oln/lrde/ufmt/naive_generic_salembier.hh: New.
+ A previous attempt before generic_simplified_salembier.
+ * oln/lrde/ufmt/basic_salembier.hh: More documentation.
+ * oln/lrde/ufmt/bin/basic_najman.cc: Typo.
+ * oln/lrde/ufmt/README: Document Salembier et al. algorithm variants.
* oln/lrde/ufmt/bin/Makefile.am (check_PROGRAMS): Add
- generic_salembier_int_u8 and generic_salembier_float.
- (generic_salembier_int_u8_SOURCES)
- (generic_salembier_float_SOURCES)
- (generic_salembier_float_LDFLAGS): New.
+ generic_salembier_float2, generic_simplified_salembier_float
+ and naive_generic_salembier_float.
+ (generic_salembier_float2_SOURCES)
+ (generic_salembier_float2_LDFLAGS)
+ (generic_simplified_salembier_float_SOURCES)
+ (generic_simplified_salembier_float_LDFLAGS)
+ (naive_generic_salembier_float_SOURCES)
+ (naive_generic_salembier_float_LDFLAGS): New.
+ * oln/lrde/ufmt/Makefile.am (noinst_HEADERS): Add
+ generic_simplified_salembier.hh and naive_generic_salembier.hh.
- * oln/lrde/efigi/pgm2pfm_wo_noise.cc: New
- * oln/lrde/efigi/Makefile.am: New.
")
(New-Version-Log "")
-(Checkin-Time "Wed, 20 Dec 2006 14:46:12 +0100")
+(Checkin-Time "Wed, 03 Jan 2007 15:17:57 +0100")
(Checkin-Login levill_r)
;; diff-ignore tests/data/.*pbm$
;; diff-ignore .*\.pbm$
@@ -141,7 +158,7 @@
(doc/ChangeLog (oln/o/31_ChangeLog 1.38.1.7.1.5.1.14.1.17 600))
(integre/ChangeLog (oln/q/35_ChangeLog 1.12.1.2.1.51 600))
(metalic/ChangeLog (oln/q/30_ChangeLog 1.3.1.44 600))
- (olena/ChangeLog (oln/o/30_ChangeLog 1.27.1.36.1.3.1.11.1.5.1.64.1.47.1.93.1.27.2.18.1.8 600))
+ (olena/ChangeLog (oln/o/30_ChangeLog 1.27.1.36.1.3.1.11.1.5.1.64.1.47.1.93.1.27.2.18.1.9 600))
(tools/ChangeLog (oln/o/32_ChangeLog 1.10.1.17 600))
(tools/swilena/ChangeLog (oln/n/37_ChangeLog 1.7.1.52 600))
@@ -1543,7 +1560,7 @@
- (olena/oln/lrde/ufmt/basic_salembier.hh (oln/w/51_basic_sale 1.2 644))
+ (olena/oln/lrde/ufmt/basic_salembier.hh (oln/w/51_basic_sale 1.3 644))
(olena/oln/lrde/ufmt/bin/basic_maxtree.cc (oln/x/0_basic_maxt 1.2 644))
(olena/oln/lrde/ufmt/bin/basic_salembier.cc (oln/x/1_basic_sale 1.3 644))
(olena/oln/lrde/ufmt/bin/gppo (oln/x/2_gppo 1.1.1.1 755))
@@ -1577,7 +1594,7 @@
- (olena/oln/lrde/ufmt/README (oln/x/22_README 1.6 644))
+ (olena/oln/lrde/ufmt/README (oln/x/22_README 1.7 644))
;; Files deleted by depopulate at Fri, 04 Aug 2006 18:41:16 +0200,
;; from version 10.245(w), by theo:
@@ -1593,10 +1610,10 @@
(TODO (oln/x/23_TODO 1.1 644))
(olena/TODO (oln/x/24_TODO 1.1 644))
(olena/oln/lrde/Makefile.am (oln/x/25_Makefile.a 1.2 644))
- (olena/oln/lrde/ufmt/Makefile.am (oln/x/26_Makefile.a 1.5 644))
+ (olena/oln/lrde/ufmt/Makefile.am (oln/x/26_Makefile.a 1.6 644))
(olena/oln/lrde/ufmt/fiorio-1.hh (oln/x/27_fiorio-1.h 1.3 644))
(olena/oln/lrde/ufmt/fiorio-2.hh (oln/x/28_fiorio-2.h 1.3 644))
- (olena/oln/lrde/ufmt/bin/Makefile.am (oln/x/29_Makefile.a 1.4 644))
+ (olena/oln/lrde/ufmt/bin/Makefile.am (oln/x/29_Makefile.a 1.5 644))
(olena/oln/lrde/ufmt/bin/fiorio.cc (oln/x/30_fiorio.cc 1.3 644))
;; Files added by populate at Mon, 28 Aug 2006 10:51:36 +0200,
;; to version 10.249(w), by theo:
@@ -1637,7 +1654,7 @@
;; Files added by populate at Mon, 28 Aug 2006 18:08:14 +0200,
;; to version 10.253(w), by berger_c:
- (olena/oln/lrde/ufmt/bin/basic_najman.cc (oln/x/43_basic_najm 1.1 644))
+ (olena/oln/lrde/ufmt/bin/basic_najman.cc (oln/x/43_basic_najm 1.2 644))
;; Files added by populate at Fri, 15 Dec 2006 10:12:49 +0100,
;; to version 10.255(w), by theo:
@@ -1660,12 +1677,18 @@
(olena/oln/lrde/efigi/pgm2pfm_wo_noise.cc (oln/y/5_pgm2pfm_wo 1.1 644))
(olena/oln/lrde/efigi/Makefile.am (oln/y/6_Makefile.a 1.1 644))
- (olena/oln/lrde/ufmt/naive_generic_salembier.hh (oln/y/7_naive_gene 1.1 644))
- (olena/oln/lrde/ufmt/generic_salembier.hh (oln/y/8_generic_sa 1.1 644))
+ (olena/oln/lrde/ufmt/naive_generic_salembier.hh (oln/y/7_naive_gene 1.2 644))
+ (olena/oln/lrde/ufmt/generic_salembier.hh (oln/y/8_generic_sa 1.2 644))
(olena/oln/lrde/ufmt/bin/generic_salembier_int_u8.cc (oln/y/9_generic_sa 1.1 644))
(olena/oln/lrde/ufmt/bin/generic_salembier_float.cc (oln/y/10_generic_sa 1.1 644))
+
+;; Files added by populate at Wed, 03 Jan 2007 14:28:38 +0100,
+;; to version 10.269(w), by levill_r:
+
+ (olena/oln/lrde/ufmt/bin/generic_salembier_float2.cc (oln/y/11_generic_sa 1.1 644))
+ (olena/oln/lrde/ufmt/bin/generic_simplified_salembier_float.cc (oln/y/12_generic_si 1.1 644))
+ (olena/oln/lrde/ufmt/bin/naive_generic_salembier_float.cc (oln/y/13_naive_gene 1.1 644))
+ (olena/oln/lrde/ufmt/generic_simplified_salembier.hh (oln/y/14_generic_si 1.1 644))
)
-(Merge-Parents
- (10.268 complete)
-)
+(Merge-Parents)
(New-Merge-Parents)
1
0
olena-0.10 10.269: Add a more generic version of Salembier's algorithm
by Roland Levillain 20 Dec '06
by Roland Levillain 20 Dec '06
20 Dec '06
2006-12-20 Roland Levillain <roland(a)lrde.epita.fr>
Add a more generic version of Salembier's algorithm.
* oln/lrde/ufmt/basic_salembier.hh
(oln::lrde::ufmt::hqueue_t::print): New method.
* oln/lrde/ufmt/generic_salembier.hh: New.
* oln/lrde/ufmt/bin/basic_salembier.cc: Add a timer.
* oln/lrde/ufmt/bin/generic_salembier_int_u8.cc,
* oln/lrde/ufmt/bin/generic_salembier_float.cc: New.
* oln/lrde/Makefile.am (SUBDIRS): Add efigi.
* oln/lrde/ufmt/bin/Makefile.am (check_PROGRAMS): Add
generic_salembier_int_u8 and generic_salembier_float.
(generic_salembier_int_u8_SOURCES)
(generic_salembier_float_SOURCES)
(generic_salembier_float_LDFLAGS): New.
* oln/lrde/efigi/pgm2pfm_wo_noise.cc: New
* oln/lrde/efigi/Makefile.am: New.
--- 10.268/olena/oln/lrde/ufmt/basic_salembier.hh Thu, 03 Aug 2006 16:06:43 +0200 theo (oln/w/51_basic_sale 1.1 644)
+++ 10.269/olena/oln/lrde/ufmt/basic_salembier.hh Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/w/51_basic_sale 1.2 644)
@@ -36,7 +36,6 @@
# include <oln/lrde/ufmt/utils.hh>
-
namespace oln
{
@@ -46,6 +45,13 @@
namespace ufmt
{
+ /*-----------------------------------------------------------.
+ | Original version of Salembier's algorithm (working only on |
+ | image of unsigned integers). |
+ `-----------------------------------------------------------*/
+
+ /// Version of hqueue for unsigned values, using an array of
+ /// queues, indexed by the gray level.
template <class P>
struct hqueue_t
{
@@ -91,10 +97,29 @@
return s;
}
+ void print (std::ostream& os)
+ {
+ os << "hqueue = {";
+ for (unsigned h = 0; h < nvalues; ++h)
+ if (not empty(h))
+ {
+ os << " " << h << " -> { ";
+ std::queue<P> queue_copy = q[h];
+ while (not queue_copy.empty())
+ {
+ os << queue_copy.front () << " ";
+ queue_copy.pop();
+ }
+ os << "}";
+ }
+ os << " }" << std::endl;
+ }
+
std::queue<P>* q;
};
+ /// Salembier's algorithm -- Version for images of unsigned integers.
template <class I>
struct basic_salembier
{
@@ -175,6 +200,7 @@
while (not hqueue.empty(h))
{
point p = hqueue.first(h);
+
status[p] = number_nodes[h];
oln_neighb_type(Nbh) q(nbh, p);
@@ -204,7 +230,7 @@
if (m >= 0)
{
int j = number_nodes[m];
- father[pair_t(i, h)] = pair_t(j, m );
+ father[pair_t(i, h)] = pair_t(j, m);
}
else
{
@@ -223,7 +249,6 @@
}; // end of struct basic_salembier
-
} // end of namespace oln::lrde::ufmt
} // end of namespace oln::lrde
--- 10.268/olena/oln/lrde/ufmt/bin/basic_salembier.cc Mon, 21 Aug 2006 17:17:14 +0200 theo (oln/x/1_basic_sale 1.2 644)
+++ 10.269/olena/oln/lrde/ufmt/bin/basic_salembier.cc Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/x/1_basic_sale 1.3 644)
@@ -3,6 +3,7 @@
#include <ntg/int.hh>
#include <oln/basics2d.hh>
+#include <oln/utils/timer.hh>
#include <oln/lrde/ufmt/basic_salembier.hh>
@@ -10,7 +11,8 @@
void usage(char* argv[])
{
std::cerr << "usage: " << argv[0] << " input.pgm c" << std::endl;
- std::cerr << "basic max-tree computation with salembier's flooding" << std::endl;
+ std::cerr << "basic max-tree computation with salembier's flooding"
+ << std::endl;
// FIXME: get precise description...
exit(1);
}
@@ -25,6 +27,7 @@
typedef image2d<ntg::int_u8> image_t;
image_t input = load(argv[1]);
+ assert (input.has_impl());
int c = atoi(argv[2]);
if (not (c == 2 or c == 4 or c == 8))
@@ -39,6 +42,10 @@
nbh = c == 4 ? neighb_c4() : neighb_c8();
algorithm_t run(input, nbh);
+ utils::timer t;
+ t.start();
run.go();
- std::cout << "n level roots = " << run.n_level_roots() << std::endl;
+ t.stop();
+ std::cout << "n level roots = " << run.n_level_roots() << std::endl
+ << "elapsed time = " << t.last_time() << std::endl;
}
--- 10.268/olena/oln/lrde/Makefile.am Fri, 25 Aug 2006 17:56:35 +0200 levill_r (oln/x/25_Makefile.a 1.1 644)
+++ 10.269/olena/oln/lrde/Makefile.am Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/x/25_Makefile.a 1.2 644)
@@ -5,5 +5,5 @@
## The contents of `olena/lrde' should be moved to subdirectory of
## `olena/oln', and the contents of `olena/lrde/ufmt/bin to `olena/tests'
## or to `tools'.
-SUBDIRS = ufmt
+SUBDIRS = efigi ufmt
## ---------------------------------------- FIXME: Improve integration. --
--- 10.268/olena/oln/lrde/ufmt/Makefile.am Fri, 20 Oct 2006 19:13:44 +0200 levill_r (oln/x/26_Makefile.a 1.4 644)
+++ 10.269/olena/oln/lrde/ufmt/Makefile.am Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/x/26_Makefile.a 1.5 644)
@@ -14,7 +14,10 @@
attributes.hh \
basic_maxtree.hh \
basic_najman.hh \
+ \
basic_salembier.hh \
+ generic_salembier.hh \
+ \
fiorio-1.hh \
fiorio-2.hh \
fiorio-3.hh \
--- 10.268/olena/oln/lrde/ufmt/bin/Makefile.am Tue, 29 Aug 2006 14:48:46 +0200 levill_r (oln/x/29_Makefile.a 1.3 644)
+++ 10.269/olena/oln/lrde/ufmt/bin/Makefile.am Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/x/29_Makefile.a 1.4 644)
@@ -3,17 +3,24 @@
check_PROGRAMS = \
basic_maxtree basic_najman basic_salembier \
+ generic_salembier_int_u8 generic_salembier_float \
fiorio-1 fiorio-2 fiorio-3 \
hdc_maxtree hpc_maxtree r1ic_maxtree rpc_maxtree
basic_maxtree_SOURCES = basic_maxtree.cc
basic_najman_SOURCES = basic_najman.cc
basic_salembier_SOURCES = basic_salembier.cc
+
+generic_salembier_int_u8_SOURCES = generic_salembier_int_u8.cc
+generic_salembier_float_SOURCES = generic_salembier_float.cc
+generic_salembier_float_LDFLAGS = -lcfitsio $(ZLIB_LDFLAGS)
+
fiorio_1_SOURCES = fiorio.cc
fiorio_2_SOURCES = fiorio.cc
fiorio_2_CPPFLAGS = -DFIORIO_VERSION=2
fiorio_3_SOURCES = fiorio.cc
fiorio_3_CPPFLAGS = -DFIORIO_VERSION=3
+
hdc_maxtree_SOURCES = hdc_maxtree.cc
hpc_maxtree_SOURCES = hpc_maxtree.cc
r1ic_maxtree_SOURCES = r1ic_maxtree.cc
Only in 10.269: olena/oln/lrde/efigi/pgm2pfm_wo_noise.cc
Only in 10.269: olena/oln/lrde/efigi/Makefile.am
Only in 10.269: olena/oln/lrde/ufmt/naive_generic_salembier.hh
Only in 10.269: olena/oln/lrde/ufmt/generic_salembier.hh
Only in 10.269: olena/oln/lrde/ufmt/bin/generic_salembier_int_u8.cc
Only in 10.269: olena/oln/lrde/ufmt/bin/generic_salembier_float.cc
--- 10.268/configure.ac Fri, 25 Aug 2006 17:56:35 +0200 levill_r (oln/3_configure. 1.47.1.1.1.1.1.4.1.15.1.16.1.10 600)
+++ 10.269/configure.ac Wed, 20 Dec 2006 14:46:12 +0100 levill_r (oln/3_configure. 1.47.1.1.1.1.1.4.1.15.1.16.1.11 600)
@@ -469,6 +469,7 @@
## `olena/oln', and the contents of `olena/lrde/ufmt/bin to `olena/tests'
## or to `tools'.
AC_CONFIG_FILES([olena/oln/lrde/Makefile
+ olena/oln/lrde/efigi/Makefile
olena/oln/lrde/ufmt/Makefile
olena/oln/lrde/ufmt/bin/Makefile])
## ---------------------------------------- FIXME: Improve integration. --
--- 10.268/oln.prj
+++ 10.269/oln.prj
@@ -1,25 +1,31 @@
;; -*- Prcs -*-
(Created-By-Prcs-Version 1 3 3)
(Project-Description "Olena")
-(Project-Version oln 10 268)
-(Parent-Version oln 10 255)
-(Version-Log "2006-12-15 Thierry GERAUD <theo(a)tegucigalpa.lrde.epita.fr>
-
- Add some EFIGI utilities.
-
- * olena/oln/lrde/efigi/pfm2pgm.cc,
- * olena/oln/lrde/efigi/misc.hh,
- * olena/oln/lrde/efigi/io.hh,
- * olena/oln/lrde/efigi/req.hh,
- * olena/oln/lrde/efigi/wst.cc,
- * olena/oln/lrde/efigi/gaussian.cc,
- * olena/oln/lrde/efigi/pgm2pfm.cc,
- * olena/oln/lrde/efigi/wst.hh:
- New.
+(Project-Version oln 10 269)
+(Parent-Version oln 10 268)
+(Version-Log "2006-12-20 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Add a more generic version of Salembier's algorithm.
+
+ * oln/lrde/ufmt/basic_salembier.hh
+ (oln::lrde::ufmt::hqueue_t::print): New method.
+ * oln/lrde/ufmt/generic_salembier.hh: New.
+ * oln/lrde/ufmt/bin/basic_salembier.cc: Add a timer.
+ * oln/lrde/ufmt/bin/generic_salembier_int_u8.cc,
+ * oln/lrde/ufmt/bin/generic_salembier_float.cc: New.
+ * oln/lrde/Makefile.am (SUBDIRS): Add efigi.
+ * oln/lrde/ufmt/bin/Makefile.am (check_PROGRAMS): Add
+ generic_salembier_int_u8 and generic_salembier_float.
+ (generic_salembier_int_u8_SOURCES)
+ (generic_salembier_float_SOURCES)
+ (generic_salembier_float_LDFLAGS): New.
+
+ * oln/lrde/efigi/pgm2pfm_wo_noise.cc: New
+ * oln/lrde/efigi/Makefile.am: New.
")
(New-Version-Log "")
-(Checkin-Time "Fri, 15 Dec 2006 10:22:33 +0100")
-(Checkin-Login theo)
+(Checkin-Time "Wed, 20 Dec 2006 14:46:12 +0100")
+(Checkin-Login levill_r)
;; diff-ignore tests/data/.*pbm$
;; diff-ignore .*\.pbm$
;; diff-ignore .*\.pgm$
@@ -131,11 +137,11 @@
(Project-Keywords)
(Files
- (ChangeLog (oln/o/33_ChangeLog 1.37.1.16.1.17.1.19.1.29 600))
+ (ChangeLog (oln/o/33_ChangeLog 1.37.1.16.1.17.1.19.1.30 600))
(doc/ChangeLog (oln/o/31_ChangeLog 1.38.1.7.1.5.1.14.1.17 600))
(integre/ChangeLog (oln/q/35_ChangeLog 1.12.1.2.1.51 600))
(metalic/ChangeLog (oln/q/30_ChangeLog 1.3.1.44 600))
- (olena/ChangeLog (oln/o/30_ChangeLog 1.27.1.36.1.3.1.11.1.5.1.64.1.47.1.93.1.27.2.18.1.7 600))
+ (olena/ChangeLog (oln/o/30_ChangeLog 1.27.1.36.1.3.1.11.1.5.1.64.1.47.1.93.1.27.2.18.1.8 600))
(tools/ChangeLog (oln/o/32_ChangeLog 1.10.1.17 600))
(tools/swilena/ChangeLog (oln/n/37_ChangeLog 1.7.1.52 600))
@@ -147,7 +153,7 @@
(cleanup.sh (oln/o/29_cleanup.sh 1.6 700))
- (configure.ac (oln/3_configure. 1.47.1.1.1.1.1.4.1.15.1.16.1.10 600))
+ (configure.ac (oln/3_configure. 1.47.1.1.1.1.1.4.1.15.1.16.1.11 600))
(doc/demo/image.cc (oln/d/46_image.cc 1.8 600))
(doc/demo/Makefile.am (oln/d/44_Makefile.a 1.16.1.2 600))
@@ -1537,9 +1543,9 @@
- (olena/oln/lrde/ufmt/basic_salembier.hh (oln/w/51_basic_sale 1.1 644))
+ (olena/oln/lrde/ufmt/basic_salembier.hh (oln/w/51_basic_sale 1.2 644))
(olena/oln/lrde/ufmt/bin/basic_maxtree.cc (oln/x/0_basic_maxt 1.2 644))
- (olena/oln/lrde/ufmt/bin/basic_salembier.cc (oln/x/1_basic_sale 1.2 644))
+ (olena/oln/lrde/ufmt/bin/basic_salembier.cc (oln/x/1_basic_sale 1.3 644))
(olena/oln/lrde/ufmt/bin/gppo (oln/x/2_gppo 1.1.1.1 755))
(olena/oln/lrde/ufmt/bin/gpp (oln/x/3_gpp 1.1.1.1 755))
@@ -1586,11 +1592,11 @@
(TODO (oln/x/23_TODO 1.1 644))
(olena/TODO (oln/x/24_TODO 1.1 644))
- (olena/oln/lrde/Makefile.am (oln/x/25_Makefile.a 1.1 644))
- (olena/oln/lrde/ufmt/Makefile.am (oln/x/26_Makefile.a 1.4 644))
+ (olena/oln/lrde/Makefile.am (oln/x/25_Makefile.a 1.2 644))
+ (olena/oln/lrde/ufmt/Makefile.am (oln/x/26_Makefile.a 1.5 644))
(olena/oln/lrde/ufmt/fiorio-1.hh (oln/x/27_fiorio-1.h 1.3 644))
(olena/oln/lrde/ufmt/fiorio-2.hh (oln/x/28_fiorio-2.h 1.3 644))
- (olena/oln/lrde/ufmt/bin/Makefile.am (oln/x/29_Makefile.a 1.3 644))
+ (olena/oln/lrde/ufmt/bin/Makefile.am (oln/x/29_Makefile.a 1.4 644))
(olena/oln/lrde/ufmt/bin/fiorio.cc (oln/x/30_fiorio.cc 1.3 644))
;; Files added by populate at Mon, 28 Aug 2006 10:51:36 +0200,
;; to version 10.249(w), by theo:
@@ -1648,21 +1654,18 @@
(olena/oln/lrde/ufmt/fiorio-3.hh (oln/x/44_fiorio-3.h 1.1 644))
(olena/oln/lrde/ufmt/img/lena64nb.pgm (oln/x/47_lena64nb.p 1.1 644) :no-keywords)
- (olena/oln/lrde/ufmt/img/lena64.pbm (oln/x/48_lena64.pbm 1.1 644) :no-keywords))
+ (olena/oln/lrde/ufmt/img/lena64.pbm (oln/x/48_lena64.pbm 1.1 644) :no-keywords)
+;; Files added by populate at Wed, 20 Dec 2006 11:47:55 +0100,
+;; to version 10.268(w), by levill_r:
+
+ (olena/oln/lrde/efigi/pgm2pfm_wo_noise.cc (oln/y/5_pgm2pfm_wo 1.1 644))
+ (olena/oln/lrde/efigi/Makefile.am (oln/y/6_Makefile.a 1.1 644))
+ (olena/oln/lrde/ufmt/naive_generic_salembier.hh (oln/y/7_naive_gene 1.1 644))
+ (olena/oln/lrde/ufmt/generic_salembier.hh (oln/y/8_generic_sa 1.1 644))
+ (olena/oln/lrde/ufmt/bin/generic_salembier_int_u8.cc (oln/y/9_generic_sa 1.1 644))
+ (olena/oln/lrde/ufmt/bin/generic_salembier_float.cc (oln/y/10_generic_sa 1.1 644))
+)
(Merge-Parents
- (10.267 complete
- (olena/ChangeLog olena/ChangeLog olena/ChangeLog m) (tools/swilena/ChangeLog tools/swilena/ChangeLog tools/swilena/ChangeLog r)
- (olena/oln/Makefile.am olena/oln/Makefile.am olena/oln/Makefile.am r) (tools/swilena/ruby/Makefile.am tools/swilena/ruby/Makefile.am tools/swilena/ruby/Makefile.am r)
- (tools/swilena/python/Makefile.am tools/swilena/python/Makefile.am tools/swilena/python/Makefile.am r) (olena/oln/makefile.src olena/oln/makefile.src olena/oln/makefile.src r)
- (tools/swilena/ruby/ltrequire.rb tools/swilena/ruby/ltrequire.rb tools/swilena/ruby/ltrequire.rb r) (olena/oln/lrde/ufmt/bin/gppo olena/oln/lrde/ufmt/bin/gppo olena/oln/lrde/ufmt/bin/gppo r)
- (olena/oln/lrde/ufmt/bin/gpp olena/oln/lrde/ufmt/bin/gpp olena/oln/lrde/ufmt/bin/gpp r) (olena/oln/lrde/ufmt/bin/inc olena/oln/lrde/ufmt/bin/inc () d)
- (olena/oln/lrde/ufmt/utils.hh olena/oln/lrde/ufmt/utils.hh olena/oln/lrde/ufmt/utils.hh r) (olena/oln/lrde/ufmt/README olena/oln/lrde/ufmt/README olena/oln/lrde/ufmt/README r)
- (olena/oln/lrde/ufmt/Makefile.am olena/oln/lrde/ufmt/Makefile.am olena/oln/lrde/ufmt/Makefile.am r) (olena/oln/lrde/ufmt/fiorio-1.hh olena/oln/lrde/ufmt/fiorio-1.hh olena/oln/lrde/ufmt/fiorio-1.hh r)
- (olena/oln/lrde/ufmt/fiorio-2.hh olena/oln/lrde/ufmt/fiorio-2.hh olena/oln/lrde/ufmt/fiorio-2.hh r) (olena/oln/lrde/ufmt/bin/Makefile.am olena/oln/lrde/ufmt/bin/Makefile.am olena/oln/lrde/ufmt/bin/Makefile.am r)
- (olena/oln/lrde/ufmt/bin/fiorio.cc olena/oln/lrde/ufmt/bin/fiorio.cc olena/oln/lrde/ufmt/bin/fiorio.cc r) (olena/oln/lrde/ufmt/attributes.hh olena/oln/lrde/ufmt/attributes.hh olena/oln/lrde/ufmt/attributes.hh r)
- (olena/oln/lrde/ufmt/attributes_bis.hh olena/oln/lrde/ufmt/attributes_bis.hh olena/oln/lrde/ufmt/attributes_bis.hh r) (olena/oln/lrde/ufmt/basic_najman.hh olena/oln/lrde/ufmt/basic_najman.hh olena/oln/lrde/ufmt/basic_najman.hh r)
- (() () olena/oln/lrde/ufmt/fiorio-3.hh a) (() () olena/oln/lrde/ufmt/img/lena64nb.pgm a)
- (() () olena/oln/lrde/ufmt/img/lena64.pbm a)
- )
+ (10.268 complete)
)
(New-Merge-Parents)
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
New prototype for SCOOP 2 algorithms.
* stc/scoop2.hh: New (prototype).
* tests/scoop2.cc: New test.
* stc/Makefile.am (nobase_stc_HEADERS): Add scoop2.hh
* tests/Makefile.am (check_PROGRAMS): Add scoop2.
(scoop2_SOURCES): New.
stc/Makefile.am | 4
stc/scoop2.hh | 689 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
tests/Makefile.am | 7
tests/scoop2.cc | 657 +++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 1355 insertions(+), 2 deletions(-)
Index: tests/Makefile.am
--- tests/Makefile.am (revision 717)
+++ tests/Makefile.am (working copy)
@@ -21,7 +21,10 @@
vtypes \
vtypes-and-exact \
\
- tour
+ tour \
+ \
+ scoop2
+
any_SOURCES = any.cc
entry_SOURCES = entry.cc
@@ -33,6 +36,8 @@
tour_SOURCES = tour.cc
+scoop2_SOURCES = scoop2.cc
+
# Old tests.
EXTRA_DIST = multiple-supers.cc vtypes-multiple-supers.cc
Index: tests/scoop2.cc
--- tests/scoop2.cc (revision 0)
+++ tests/scoop2.cc (revision 0)
@@ -0,0 +1,657 @@
+// Copyright (C) 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+
+/// This test focuses on the virtual types system, so the exact type of
+/// classes is not propagated here (stc::any is not used).
+
+/// These examples comes from doc/algorithm.ml.
+
+
+#include <mlc/cmp.hh>
+#include <mlc/assert.hh>
+
+#include <stc/scoop2.hh>
+
+/* FIXME: To be enabled later, when the contents of stc/scoop2.hh is
+ enclosed in a macro. */
+#if 0
+// Namespace equipment.
+stc_scoop_equipment_for_namespace(my);
+#endif
+
+// FIXME: Check single_vtype, too.
+
+namespace my
+{
+ // ------------------------------------------------------------ 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(value_type);
+
+
+
+ /* ---------------------------------------------------------------- Ex 1.
+
+ ** Virtual type definition
+
+ Ex.
+
+ class A < stc::none =
+ {
+ vtype my_type = int;
+ }
+ */
+
+ namespace ex1
+ {
+ // Forward declaration.
+ struct A;
+ }
+
+ // Set super type.
+ template <> struct set_super_type<ex1::A> { typedef stc::none ret; };
+
+ /// Virtual types associated to A.
+ template <>
+ struct vtypes<ex1::A>
+ {
+ typedef int my_type;
+ };
+
+ namespace ex1
+ {
+ struct A : public stc::none {};
+
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex1::A, my), int)
+ >::check();
+ }
+ }
+
+ /* ---------------------------------------------------------------- Ex 2.
+
+ ** Virtual type re-definition.
+
+ Ex.
+
+ class A < stc::none =
+ {
+ vtype my_type = int;
+ }
+ // Valid.
+ class B < A =
+ {
+ vtype my_type = float;
+ }
+ // Valid.
+ class C < A =
+ {
+ vtype my_type = int;
+ }
+ */
+
+ namespace ex2
+ {
+ // Forward declarations.
+ struct A;
+ struct B;
+ struct C;
+ }
+
+ // 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; };
+
+ /// Virtual types associated to A.
+ template <>
+ struct vtypes<ex2::A>
+ {
+ typedef int my_type;
+ };
+
+ /// Virtual types associated to B.
+ template <>
+ struct vtypes<ex2::B>
+ {
+ typedef float my_type;
+ };
+
+ /// Virtual types associated to C.
+ template <>
+ struct vtypes<ex2::C>
+ {
+ typedef int my_type;
+ };
+
+ namespace ex2
+ {
+ struct A : public stc::none {};
+ struct B : public A {};
+ struct C : public B {};
+
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex2::A, my), int)
+ >::check();
+
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex2::B, my), float)
+ >::check();
+
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex2::C, my), int)
+ >::check();
+ }
+ }
+
+
+ /* ---------------------------------------------------------------- Ex 3.
+
+ ** Virtual type abstract declaration (i.e., deferred definition).
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ // my_type is abstract.
+ vtype my_type = 0;
+ }
+ class B < A =
+ {
+ vtype my_type = int;
+ }
+ */
+
+ namespace ex3
+ {
+ // Forward declarations.
+ struct A;
+ struct B;
+ }
+
+ // 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; };
+
+ /// Virtual types associated to A.
+ template <>
+ struct vtypes<ex3::A>
+ {
+ typedef stc::abstract my_type;
+ };
+
+ /// Virtual types associated to B.
+ template <>
+ struct vtypes<ex3::B>
+ {
+ typedef int my_type;
+ };
+
+ namespace ex3
+ {
+ struct A : public stc::none {};
+ struct B : public A {};
+
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex3::B, my), int)
+ >::check();
+ }
+ }
+
+
+ /* ---------------------------------------------------------------- Ex 4.
+
+ ** Final virtual type
+
+ - A virtual type can be tagged as final.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ final vtype my_type = int;
+ }
+ */
+
+ namespace ex4
+ {
+ // Forward declaration.
+ struct A;
+ }
+
+ // Set super type.
+ template <> struct set_super_type<ex4::A> { typedef stc::none ret; };
+
+ /// Virtual types associated to A.
+ template <>
+ struct vtypes<ex4::A>
+ {
+ typedef stc::final<int> my_type;
+ };
+
+ namespace ex4
+ {
+ struct A : public stc::none {};
+
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex4::A, my), int)
+ >::check();
+ }
+ }
+
+
+ /* ---------------------------------------------------------------- Ex 5.
+
+ ** General virtual type lookup (i.e., with delegation)
+
+ *** Abstract
+
+ class A < stc::none
+ {
+ // my_vtype not defined.
+ }
+
+ class D < stc::none
+ {
+ vtype my_type = 0;
+ }
+
+ // A
+ // ^
+ // |
+ // C<>--D
+ class C < stc::none
+ {
+ vtype delegatee_type = D;
+ }
+
+ type t = C#my_type;
+ */
+
+ namespace ex5
+ {
+ // Forward declarations.
+ struct A;
+ struct D;
+ struct C;
+ }
+
+ // 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; };
+
+ /// Virtual types associated to A.
+ template <>
+ struct vtypes<ex5::A>
+ {
+ };
+
+ /// Virtual types associated to D.
+ template <>
+ struct vtypes<ex5::D>
+ {
+ typedef stc::abstract my_type;
+ };
+
+ /// Virtual types associated to C.
+ template <>
+ struct vtypes<ex5::C>
+ {
+ typedef ex5::D delegatee_type;
+ };
+
+ namespace ex5
+ {
+ struct A : public stc::none {};
+ struct D : public stc::none {};
+ struct C : public A {};
+
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex5::C, my), stc::not_found)
+ >::check();
+ }
+ }
+
+
+ /* ---------------------------------------------------------------- Ex 6.
+
+ * More examples.
+
+ ** A complex example, with stc::not_delegated.
+
+ A
+ ^
+ | X
+ B ^
+ ^ |
+ | Y
+ C<>-�
+ ^
+ |
+ D
+ ^
+ |
+ E
+
+
+ class A < stc::none | class C < B
+ { | {
+ } | vtype delegatee_type = Y;
+ class B < A | vtype foo = int;
+ { | vtype baz = not_delegated;
+ vtype foo = 0; | vtype hop = not_delegated;
+ } | }
+ | class D < C
+ class X < stc::none | {
+ { | vtype quux = unsigned;
+ vtype bar = 0; | }
+ vtype hop = int; | class E < D
+ } | {
+ class Y < X | vtype baz = float;
+ { | }
+ vtype baz = short; |
+ vtype bar = char; |
+ } |
+ */
+
+ namespace ex6
+ {
+ // Forward declarations.
+ struct A;
+ struct B;
+
+ struct X;
+ struct Y;
+
+ struct C;
+ struct D;
+ struct E;
+ }
+
+ // 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 set_super_type<ex6::X> { typedef stc::none ret; };
+ template <> struct set_super_type<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; };
+
+ /// Virtual types associated to A.
+ template <>
+ struct vtypes<ex6::A>
+ {
+ };
+
+ /// Virtual types associated to B.
+ template <>
+ struct vtypes<ex6::B>
+ {
+ typedef stc::abstract foo_type;
+ };
+
+ /// Virtual types associated to X.
+ template <>
+ struct vtypes<ex6::X>
+ {
+ typedef stc::abstract bar_type;
+ typedef int hop_type;
+ };
+
+ /// Virtual types associated to Y.
+ template <>
+ struct vtypes<ex6::Y>
+ {
+ typedef short baz_type;
+ typedef char bar_type;
+ };
+
+ /// 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;
+ };
+
+ /// Virtual types associated to D.
+ template <>
+ struct vtypes<ex6::D>
+ {
+ typedef unsigned quux_type;
+ };
+
+ /// Virtual types associated to E.
+ template <>
+ struct vtypes<ex6::E>
+ {
+ typedef float baz_type;
+ };
+
+ namespace ex6
+ {
+ struct A : public stc::none {};
+ struct B : public A {};
+
+ struct X : public stc::none {};
+ struct Y : public X {};
+
+ struct C : public B {};
+ struct D : public C {};
+ struct E : public D {};
+
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex6::E, foo), int)
+ >::check();
+
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex6::E, bar), char)
+ >::check();
+
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex6::E, baz), float)
+ >::check();
+
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex6::E, quux), unsigned)
+ >::check();
+
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, my::ex6::E, hop), stc::not_found)
+ >::check();
+ }
+ }
+
+
+ /* ---------------------------------------------------------------- Ex 7.
+
+ *** Olena-like examples.
+
+ class /image_entry/ < stc::none
+ {
+ vtype value_type = 0;
+ }
+
+ class image2d<int> < image_entry
+ {
+ vtypes value_type = int;
+ }
+
+ class /value_morpher/ < image_entry
+ {
+ vtype delegatee_type = 0;
+ vtype value_type = stc::not_delegated;
+ }
+
+ class value_cast<image2d<int>, float> < value_morpher
+ {
+ vtype delegatee_type = image2d<int>;
+ vtype value_type = float;
+ }
+ */
+
+ namespace ex7
+ {
+ // Forward declarations.
+ namespace abstract
+ {
+ struct image_entry;
+ struct value_morpher;
+ }
+
+ template <typename T> struct image2d;
+ template <typename I, typename T> struct value_cast;
+ }
+
+ // Set super types.
+ template <>
+ struct set_super_type<ex7::abstract::image_entry>
+ {
+ typedef stc::none ret;
+ };
+ template <>
+ struct set_super_type<ex7::abstract::value_morpher>
+ {
+ typedef ex7::abstract::image_entry ret;
+ };
+ template <typename T>
+ struct set_super_type< ex7::image2d<T> >
+ {
+ typedef ex7::abstract::image_entry ret;
+ };
+ template <typename I, typename T>
+ struct set_super_type< ex7::value_cast<I, T> >
+ {
+ typedef ex7::abstract::value_morpher ret;
+ };
+
+
+ /// Virtual types associated to abstract::image_entry.
+ template <>
+ struct vtypes<ex7::abstract::image_entry>
+ {
+ typedef stc::abstract value_type;
+ };
+
+ /// 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;
+ };
+
+ /// Virtual types associated to image2d<T>.
+ template <typename T>
+ struct vtypes< ex7::image2d<T> >
+ {
+ typedef T value_type;
+ };
+
+ /// 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;
+ };
+
+
+ namespace ex7
+ {
+ namespace abstract
+ {
+ struct image_entry : public stc::none {};
+ struct value_morpher : public image_entry {};
+ }
+
+ template <typename T>
+ struct image2d : public abstract::image_entry {};
+
+ template <typename I, typename T>
+ struct value_cast : public abstract::value_morpher {};
+
+
+ void
+ check()
+ {
+ mlc::assert_<
+ mlc_eq(stc_find_vtype_(my, 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)
+ >::check();
+ }
+ }
+
+} // end of namespace my
+
+
+int
+main()
+{
+ my::ex1::check();
+ my::ex2::check();
+ my::ex3::check();
+ my::ex4::check();
+ my::ex5::check();
+ my::ex6::check();
+ my::ex7::check();
+}
Index: stc/scoop2.hh
--- stc/scoop2.hh (revision 0)
+++ stc/scoop2.hh (revision 0)
@@ -0,0 +1,689 @@
+// Copyright (C) 2005, 2006 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library without restriction. Specifically, if other files
+// instantiate templates or use macros or inline functions from this
+// file, or you compile this file and link it with other files to
+// produce an executable, this file does not by itself cause the
+// resulting executable to be covered by the GNU General Public
+// License. This exception does not however invalidate any other
+// reasons why the executable file might be covered by the GNU General
+// Public License.
+
+/* \file stc/vtypes.hh
+
+ \brief Equipment for SCOOP 2 (in particular, virtual types). */
+
+#ifndef STC_SCOOP2_HH
+# define STC_SCOOP2_HH
+
+# include <mlc/flags.hh>
+# include <mlc/typedef.hh>
+# include <mlc/abort.hh>
+
+
+namespace stc
+{
+
+ struct none {};
+ struct not_found;
+ struct abstract;
+ struct not_delegated;
+ struct not_delegated_abstract;
+ template <typename T> struct final;
+
+ namespace ERROR
+ {
+ struct IN_find__VIRTUAL_TYPE_IS_ABSTRACT;
+
+ struct IN_find_local__VIRTUAL_TYPE_MULTIPLY_DEFINED;
+
+ 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.
+
+// FIXME: Hack.
+#define SCOOPED_NAMESPACE my
+
+
+// ------------------------------------------------------------ find_local.
+
+// Highly inspired from Th�o's get_stm!
+
+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;
+ };
+
+ 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;
+
+
+ // super_res == stc::not_found.
+ template <>
+ struct match_with<stc::abstract, stc::not_found>
+ {
+ typedef stc::abstract ret;
+ };
+ template <>
+ struct match_with<stc::not_found, stc::not_found>
+ {
+ typedef stc::not_found ret;
+ };
+ template <typename T>
+ struct match_with<stc::final<T>, stc::not_found>
+ {
+ typedef stc::final<T> ret;
+ };
+
+ template <typename T>
+ struct match_with<T, stc::not_found>
+ {
+ typedef T ret;
+ };
+
+
+ // super_res == stc::abstract.
+ template <>
+ struct match_with<stc::not_found, stc::abstract>
+ {
+ typedef stc::not_found ret;
+ };
+
+ template <>
+ struct match_with<stc::abstract, stc::abstract>
+ {
+ typedef stc::abstract ret;
+ };
+
+ template <typename T>
+ struct match_with<stc::final<T>, stc::abstract>
+ {
+ typedef stc::final<T> ret;
+ };
+
+ template <typename T>
+ struct match_with<T, stc::abstract>
+ {
+ typedef T ret;
+ };
+
+
+ // super_res == stc::final<U>.
+ template <typename U>
+ struct match_with<stc::abstract, stc::final<U> > :
+ mlc::abort_<U, stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT>
+ {
+ };
+
+ template <typename U>
+ struct match_with<stc::not_found, stc::final<U> >
+ {
+ typedef stc::final<U> ret;
+ };
+
+ template <typename T, typename U>
+ struct match_with<stc::final<T>, stc::final<U> > :
+ mlc::abort_<U, stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL>
+ {
+ };
+
+ template <typename T, typename U>
+ struct match_with<T, stc::final<U> > :
+ mlc::abort_<U, stc::ERROR::IN_merge2__FINAL_VIRTUAL_TYPE_REDEFINED>
+ {
+ };
+
+
+ // super_res == U.
+ template <typename U>
+ struct match_with<stc::abstract, U> :
+ mlc::abort_<U, stc::ERROR::IN_merge2__VIRTUAL_TYPE_REDEFINED_ABSTRACT>
+ {
+ };
+
+ template <typename U>
+ struct match_with<stc::not_found, U>
+ {
+ typedef U ret;
+ };
+
+ template <typename T, typename U>
+ struct match_with<stc::final<T>, U>
+ {
+ typedef stc::final<T> ret;
+ };
+
+ 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.
+
+ // FIXME: Undef these macros after the definition of merge3.
+
+#define stc_match_0p_with(Local, Super, Deleg, Res) \
+ template <> \
+ struct match_with< Local, Super, Deleg > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_match_1p_with(T1, Local, Super, Deleg, Res) \
+ template <typename T1> \
+ struct match_with< Local, Super, Deleg > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_match_2p_with(T1, T2, Local, Super, Deleg, Res) \
+ template <typename T1, typename T2> \
+ struct match_with< Local, Super, Deleg > \
+ { \
+ typedef Res ret; \
+ }
+
+#define stc_match_3p_with(T1, T2, T3, Local, Super, Deleg, Res) \
+ template <typename T1, typename T2, typename T3> \
+ struct match_with< Local, Super, Deleg > \
+ { \
+ typedef Res ret; \
+ }
+
+ // FIXME: Example of use.
+ // stc_match_with(stc::not_found, stc::not_found, stc::not_found, stc::not_found);
+
+ namespace merge3_
+ {
+ // Forward declaration.
+ template <typename T, typename U, typename V> struct match_with;
+
+
+ // local_res == stc::not_found.
+ template <>
+ struct match_with<stc::not_found, stc::not_found, stc::not_found>
+ {
+ typedef stc::not_found ret;
+ };
+
+ template <>
+ struct match_with<stc::not_found, stc::not_found, stc::abstract>
+ {
+ typedef stc::not_found ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::not_found, stc::not_found, stc::final<V> >
+ {
+ typedef stc::final<V> ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::not_found, stc::not_found, V>
+ {
+ typedef V ret;
+ };
+
+
+ template <>
+ struct match_with<stc::not_found, stc::abstract, stc::not_found>
+ {
+ typedef stc::not_found ret;
+ };
+
+ template <>
+ struct match_with<stc::not_found, stc::abstract, stc::abstract>
+ {
+ typedef stc::abstract ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::not_found, stc::abstract, stc::final<V> >
+ {
+ typedef stc::final<V> ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::not_found, stc::abstract, V>
+ {
+ typedef V ret;
+ };
+
+
+ template <typename U, typename V>
+ struct match_with<stc::not_found, stc::final<U>, V>
+ {
+ typedef stc::final<U> ret;
+ };
+
+ template <typename U, typename V>
+ struct match_with<stc::not_found, U, V>
+ {
+ typedef U ret;
+ };
+
+
+ // local_res == stc::abstract.
+ template <>
+ struct match_with<stc::abstract, stc::not_found, stc::not_found>
+ {
+ typedef stc::abstract ret;
+ };
+
+ template <>
+ struct match_with<stc::abstract, stc::not_found, stc::abstract>
+ {
+ typedef stc::abstract ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::abstract, stc::not_found, stc::final<V> >
+ {
+ typedef stc::final<V> ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::abstract, stc::not_found, V >
+ {
+ typedef V ret;
+ };
+
+
+ template <>
+ struct match_with<stc::abstract, stc::abstract, stc::not_found>
+ {
+ typedef stc::abstract ret;
+ };
+
+ template <>
+ struct match_with<stc::abstract, stc::abstract, stc::abstract>
+ {
+ typedef stc::abstract ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::abstract, stc::abstract, stc::final<V> >
+ {
+ typedef stc::final<V> ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::abstract, stc::abstract, V>
+ {
+ typedef V ret;
+ };
+
+
+ template <typename V>
+ struct match_with<stc::abstract, stc::not_delegated_abstract, V>
+ {
+ typedef stc::not_delegated_abstract ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::abstract, stc::not_delegated, V>
+ {
+ typedef stc::not_delegated_abstract ret;
+ };
+
+
+ template <typename U, typename V>
+ struct match_with<stc::abstract, stc::final<U>, V> :
+ mlc::abort_<V, stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_ABSTRACT>
+ {
+ };
+
+ template <typename U, typename V>
+ struct match_with<stc::abstract, U, V> :
+ mlc::abort_<V, stc::ERROR::IN_merge3__VIRTUAL_TYPE_REDEFINED_ABSTRACT>
+ {
+ };
+
+
+ // local_res == stc::not_delegated.
+ template <typename V>
+ struct match_with<stc::not_delegated, stc::not_found, V>
+ {
+ typedef stc::not_delegated ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::not_delegated, stc::abstract, V>
+ {
+ typedef stc::not_delegated_abstract ret;
+ };
+
+ template <typename V>
+ struct match_with<stc::not_delegated, stc::not_delegated_abstract, V>
+ {
+ typedef stc::not_delegated_abstract ret;
+ };
+
+
+ // 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). */
+ template <typename U, typename V>
+ struct match_with<stc::not_delegated_abstract, U, V> :
+ mlc::abort_<V, stc::ERROR::IN_merge3__LOCAL_DECLARATION_OF_NOT_DELEGATED_AND_ABSTRACT>
+ {
+ };
+
+
+ // local_res == stc::final<T>.
+ template <typename T, typename U, typename V>
+ struct match_with<stc::final<T>, stc::final<U>, V> :
+ mlc::abort_<V, stc::ERROR::IN_merge3__FINAL_VIRTUAL_TYPE_REDEFINED_FINAL>
+ {
+ };
+
+ template <typename T, typename U, typename V>
+ struct match_with<stc::final<T>, U, V>
+ {
+ typedef stc::final<T> ret;
+ };
+
+
+ // local_res == T.
+ template <typename T, typename U, typename V>
+ struct match_with<T, stc::final<U>, V> :
+ mlc::abort_<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;
+
+ template <>
+ struct match_with<stc::abstract>
+/* 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). */
+#if 0
+ : mlc::abort_<stc::abstract,
+ stc::ERROR::IN_find__VIRTUAL_TYPE_IS_ABSTRACT>
+#endif
+ {
+ };
+
+ template <>
+ struct match_with<stc::not_delegated_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). */
+#if 0
+ : mlc::abort_<stc::not_delegated_abstract,
+ stc::ERROR::IN_find__VIRTUAL_TYPE_IS_ABSTRACT>
+#endif
+ {
+ };
+
+ 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_
+
+ template <typename source, typename target>
+ struct find
+ {
+ typedef typename find_rec<source, target>::ret res;
+ // Result.
+ typedef typename find_::match_with<res>::ret ret;
+ };
+
+} /* end of SCOOPED_NAMESPACE */
+
+
+# define stc_find_vtype_(Namespace, Source, Target) \
+ Namespace::find<Source, Namespace::typedef_::Target##_type>::ret
+
+# define stc_find_vtype(Namespace, Source, Target) \
+ typename stc_find_vtype_(Namespace, Source, Target)
+
+#endif // ! STC_SCOOP2_HH
Index: stc/Makefile.am
--- stc/Makefile.am (revision 717)
+++ stc/Makefile.am (working copy)
@@ -9,7 +9,9 @@
scoop.hh \
valist_aggregator.hh \
\
- internal/extract_vtype_from_list.hh
+ internal/extract_vtype_from_list.hh \
+ \
+ scoop2.hh
# Old code.
EXTRA_DIST = was.scoop.hh
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Improve SCOOP 2 documentation and prototype.
* doc/algorithms.ml (merge2): Reorder patterns as in merge3.
Aesthetic changes.
(merge3): Aesthetic changes.
* doc/algorithms.txt: Adjust.
* doc/rules.txt: Typos.
Improve the last two examples.
algorithms.ml | 46 +++++++++++++++-------------------
algorithms.txt | 32 ++++++++++++------------
rules.txt | 75 ++++++++++++++++++++++++++++++++-------------------------
3 files changed, 80 insertions(+), 73 deletions(-)
Index: doc/algorithms.ml
--- doc/algorithms.ml (revision 716)
+++ doc/algorithms.ml (working copy)
@@ -73,26 +73,25 @@
let merge2 (local_res : cxx_type) (super_res : cxx_type) : cxx_type =
match local_res, super_res with
- | Stc_Abstract, Stc_Not_found -> Stc_Abstract
+ (* local_res == stc::not_found. *)
| Stc_Not_found, Stc_Not_found -> Stc_Not_found
- | Stc_Final t, Stc_Not_found -> Stc_Final t
- | t, Stc_Not_found -> t
-
| Stc_Not_found, Stc_Abstract -> Stc_Not_found
- | Stc_Abstract, Stc_Abstract -> Stc_Abstract
- | Stc_Final t, Stc_Abstract -> Stc_Final t
- | t, Stc_Abstract -> t
-
- | Stc_Abstract, Stc_Final u -> error "Final VT redefined abstract"
| Stc_Not_found, Stc_Final u -> Stc_Final u
- | Stc_Final t, Stc_Final u -> error "Final VT redefined final."
- | t, Stc_Final u -> error "Final VT redefined."
-
- | Stc_Abstract, u -> error "VT redefined abstract."
| Stc_Not_found, u -> u
- | Stc_Final t, u -> Stc_Final t
- | t, u -> t
+ (* local_res == stc::abstract. *)
+ | Stc_Abstract, Stc_Abstract -> Stc_Abstract
+ | Stc_Abstract, Stc_Not_found -> Stc_Abstract
+ | Stc_Abstract, Stc_Final _ -> error "Final VT redefined abstract"
+ | Stc_Abstract, _ -> error "VT redefined abstract."
+
+ (* local_res == stc::final<T>. *)
+ | Stc_Final _, Stc_Final _ -> error "Final VT redefined final."
+ | Stc_Final t, _ -> Stc_Final t
+
+ (* local_res == T. *)
+ | _, Stc_Final _ -> error "Final VT redefined."
+ | t, _ -> t
;;
(* Another version (rewriting) of merge3. *)
@@ -114,7 +113,7 @@
| Stc_Not_found, Stc_Final u, _ -> Stc_Final u
| Stc_Not_found, u, _ -> u
- (* local_res == stc::not_abstract. *)
+ (* local_res == stc::abstract. *)
| Stc_Abstract, Stc_Not_found, Stc_Not_found -> Stc_Abstract
| Stc_Abstract, Stc_Not_found, Stc_Abstract -> Stc_Abstract
| Stc_Abstract, Stc_Not_found, Stc_Final v -> Stc_Final v
@@ -128,9 +127,9 @@
| Stc_Abstract, Stc_Not_delegated_Abstract, _ -> Stc_Not_delegated_Abstract
| Stc_Abstract, Stc_Not_delegated, _ -> Stc_Not_delegated_Abstract
- | Stc_Abstract, Stc_Final u, _ -> error ("Final VT " ^
+ | Stc_Abstract, Stc_Final _, _ -> error ("Final VT " ^
"redefined abstract")
- | Stc_Abstract, u, _ -> error ("VT redefined " ^
+ | Stc_Abstract, _, _ -> error ("VT redefined " ^
"abstract.")
(* local_res == stc::not_delegated. *)
@@ -147,15 +146,14 @@
" and abstract")
(* local_res == stc::final<T>. *)
- | Stc_Final t, Stc_Final u, _ -> error ("Final VT " ^
+ | Stc_Final _, Stc_Final _, _ -> error ("Final VT " ^
"redefined final.")
| Stc_Final t, _, _ -> Stc_Final t
(* local_res == T. *)
- | t, Stc_Final u, _ -> error ("Final VT " ^
+ | _, Stc_Final _, _ -> error ("Final VT " ^
"redefined.")
| t, _, _ -> t
-
;;
@@ -380,7 +378,7 @@
with Scoop_exception "Final VT redefined final." -> ();
;;
-(* ** General virtual type lookup
+(* ** General virtual type lookup (i.e., with delegation)
*** Abstract
@@ -403,8 +401,6 @@
vtype delegatee_type = D;
}
- // FIXME: What should be the value of ``t''?
- // I would say ``stc::not_found'', but I'm not sure (see intro.txt, too).
type t = C#my_type;
*)
let a =
@@ -573,7 +569,7 @@
;;
-(* Olena-like examples.
+(* *** Olena-like examples.
class /image_entry/ < stc::none
{
Index: doc/algorithms.txt
--- doc/algorithms.txt (revision 716)
+++ doc/algorithms.txt (working copy)
@@ -29,8 +29,8 @@
| stc::abstract -> error "find: VT is abstract."
| stc::not_delegated_abstract -> error "find: VT is abstract."
| stc::not_delegated -> stc::not_found
- | stc::final t -> t
- | t -> t
+ | stc::final<T> -> T
+ | T -> T
** find_rec
@@ -70,25 +70,25 @@
merge2 (local_res, super_res) =
match local_res, super_res with
- | stc::abstract, stc::not_found -> stc::abstract
+ // local_res == stc::not_found.
| mlc::not_found, stc::not_found -> stc::not_found
- | T, stc::not_found -> T
- | stc::final<T>, stc::not_found -> stc::final<T>
-
| mlc::not_found, stc::abstract -> stc::not_found
- | stc::abstract, stc::abstract -> stc::abstract
- | T, stc::abstract -> T
- | stc::final<T>, stc::abstract -> stc::final<T>
-
- | stc::abstract, U -> error ("VT redefined abstract.")
+ | mlc::not_found, stc::final<U> -> stc::final<U>
| mlc::not_found, U -> U
- | T, U -> T
- | stc::final<T>, U -> stc::final<T>
+ // local_res == stc::abstract.
+ | stc::abstract, stc::not_found -> stc::abstract
+ | stc::abstract, stc::abstract -> stc::abstract
| stc::abstract, stc::final<U> -> error ("Final VT redefined abstract")
- | mlc::not_found, stc::final<U> -> stc::final<U>
- | T, stc::final<U> -> error ("Final VT redefined.")
+ | stc::abstract, U -> error ("VT redefined abstract.")
+
+ // local_res == stc::final<T>.
| stc::final<T>, stc::final<U> -> error ("Final VT redefined final.")
+ | stc::final<T>, _ -> stc::final<T>
+
+ // local_res == stc::final<T>.
+ | T, stc::final<U> -> error ("Final VT redefined.")
+ | T, _ -> T
merge3 (local_res, super_res, delegatee_res) =
@@ -109,7 +109,7 @@
| mlc::not_found, U, _ -> U
- // local_res == stc::not_abstract.
+ // local_res == stc::abstract.
| stc::abstract, stc::not_found, stc::not_found -> stc::abstract
| stc::abstract, stc::not_found, stc::abstract -> stc::abstract
| stc::abstract, stc::not_found, stc::final<V> -> stc::final<V>
Index: doc/rules.txt
--- doc/rules.txt (revision 716)
+++ doc/rules.txt (working copy)
@@ -16,7 +16,7 @@
stc::none (FIXME: What about stc::top ?)
- deferred_type? (FIXME: Which syntax?)
+ (deferred_type?) (FIXME: Which syntax?)
* Declaration/definition
@@ -93,7 +93,7 @@
- Unless declared final (see relevant item), a virtual type of a class
can be redefined in its subclass(es). The new value can be the same
or different for the inital one. The syntax is the same as the one
- for defining a virtual type.
+ defining a virtual type.
Ex.:
@@ -315,7 +315,7 @@
This process relies on an `atomic' lookup on each inspected class:
each of them can be queried for a locally defined virtual type.
-(FIXME: reference to the local_find algorithm.)
+(FIXME: reference to the find_local algorithm.)
The result of this local lookup is
- mlc::not_found: meaning there is no delegatee_type;
@@ -415,6 +415,8 @@
FIXME: Continue.
+
+
* Examples
@@ -471,41 +473,50 @@
*** E#bar
- A local_find(A, bar) = mlc::not_found
- ^
+ top-down
+ propagation
+
|
- | X local_find(X, bar) = 0
- | ^
- | |
- B | local_find(B, bar) = mlc::not_found
- ^ |
+ | find_local(A, bar) = not_found A
+ | => find(A, bar) = not_found ^
+ | | X find_local(X, bar) = 0
+ | | ^ => find(X, bar) = 0
+ | find_local(B, bar) = not_found B |
+ | => find(B, bar) = not_found ^ |
+ | | Y find_local(Y, bar) = char
+ | | | => find(Y, bar) = char
+ | find_local(C, bar) = not_found C<>-�
+ | => find(C, bar) = char ^
| |
- | Y local_find(Y, bar) = char
+ | find_local(D, bar) = not_found D
+ | => find(D, bar) = char ^
| |
- | |
- C<>-� local_find(D, bar) = mlc::not_found
- ^
- |
- D local_find(D, bar) = mlc::not_found
- ^
- |
- E local_find(E, bar) = mlc::not_found
+ | find_local(E, bar) = not_found E
+ | => find(E, bar) = char
+ v
*** E#hop
- A local_find(A, bar) = mlc::not_found
- ^
- | X
- B ^ local_find(B, bar) = mlc::not_found
- ^ |
- | Y
- C<>-� local_find(D, bar) = stc::not_delegated
- ^
- |
- D local_find(D, hop) = mlc::not_found
- ^
- |
- E local_find(E, hop) = mlc::not_found
+ top-down
+ propagation
+
+ | find_local(A, hop) = not_found A
+ | => find(A, hop) = not_found ^
+ | | X find_local(X, hop) = int
+ | | ^ => find(X, hop) = int
+ | find_local(B, hop) = not_found B |
+ | => find(B, hop) = not_found ^ |
+ | | Y find_local(Y, hop) = not_found
+ | | | => find(Y, hop) = int
+ | find_local(C, hop) = not_deleg C<>-�
+ | => find(C, hop) = not_found ^
+ | |
+ | find_local(D, hop) = not_found D
+ | => find(D, hop) = not_found ^
+ | |
+ | find_local(E, hop) = not_found E
+ | => find(E, hop) = not_found
+ v
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
More examples in doc/algorithms.ml.
* doc/algorithms.ml (find_rec): Handle abstract delegatee.
Add Olena-like examples.
Aesthetic changes.
* doc/algorithms.txt (Top-down approach): Document `find'.
(Bottom-up approach): Move section at the end of the file.
algorithms.ml | 178 ++++++++++++++++++++++------------
algorithms.txt | 292 +++++++++++++++++++++++++++++----------------------------
2 files changed, 267 insertions(+), 203 deletions(-)
Index: doc/algorithms.ml
--- doc/algorithms.ml (revision 715)
+++ doc/algorithms.ml (working copy)
@@ -173,13 +173,12 @@
inheritance branch. Of course, the declarative nature
of C++ templates will avoid this cost, but it remains
inelegant, IMHO. *)
-
let delegatee = find_rec_in_supers source "delegatee_type" in
let delegatee_res =
- if delegatee = Stc_Not_found then
- Stc_Not_found
- else
- find_rec delegatee target in
+ match delegatee with
+ | Stc_Not_found -> Stc_Not_found
+ | Stc_Abstract -> Stc_Not_found
+ | _ -> find_rec delegatee target in
merge3 local_res super_res delegatee_res
end
@@ -223,7 +222,8 @@
vtype my_type = int;
}
*)
-let a = Scoop_Class { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["my_type", Std_Int] } in
assert (find a "my_type" = Std_Int);;
@@ -247,11 +247,14 @@
vtype my_type = int;
}
*)
-let a = Scoop_Class { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["my_type", Std_Int] } in
-let b = Scoop_Class { super = a;
+let b =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["my_type", Std_Float] } in
-let c = Scoop_Class { super = b;
+let c =
+ Scoop_Class { super = b;
vtypes = create_vtypes ["my_type", Std_Int] } in
assert (find c "my_type" = Std_Int);;
@@ -270,9 +273,11 @@
vtype my_type = int;
}
*)
-let a = Scoop_Class { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["my_type", Stc_Abstract] } in
-let b = Scoop_Class { super = a;
+let b =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["my_type", Std_Int] } in
assert (find b "my_type" = Std_Int);;
@@ -290,14 +295,15 @@
vtype my_type = 0;
}
*)
-let a = Scoop_Class { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["my_type", Std_Int] } in
-let b = Scoop_Class { super = a;
+let b =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["my_type", Stc_Abstract] } in
try
ignore (find b "my_type")
- with Scoop_exception "VT redefined abstract." -> ()
-;;
+with Scoop_exception "VT redefined abstract." -> ();;
(* ** Final virtual type
@@ -311,9 +317,9 @@
final vtype my_type = int;
}
*)
-let a = Scoop_Class { super = Stc_None;
- vtypes = create_vtypes ["my_type", Stc_Final Std_Int] }
-in
+let a =
+ Scoop_Class { super = Stc_None;
+ vtypes = create_vtypes ["my_type", Stc_Final Std_Int] } in
assert (find a "my_type" = Std_Int);;
(* - A virtual type tagged as final in a class cannot be redefined in its
@@ -347,20 +353,20 @@
final vtype my_type = float;
}
*)
-let a = Scoop_Class
- { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["my_type", Stc_Final Std_Int] } in
-let b = Scoop_Class
- { super = a;
+let b =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["my_type", Std_Float] } in
-let c = Scoop_Class
- { super = a;
+let c =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["my_type", Std_Int] } in
-let d = Scoop_Class
- { super = a;
+let d =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["my_type", Stc_Final Std_Int] } in
-let e = Scoop_Class
- { super = a;
+let e =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["my_type", Stc_Final Std_Float] } in
assert (find a "my_type" = Std_Int);
@@ -401,14 +407,14 @@
// I would say ``stc::not_found'', but I'm not sure (see intro.txt, too).
type t = C#my_type;
*)
-let a = Scoop_Class
- { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes [] } in
-let d = Scoop_Class
- { super = Stc_None;
+let d =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["my_type", Stc_Abstract] } in
-let c = Scoop_Class
- { super = a;
+let c =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["delegatee_type", d] } in
assert (find c "my_type" = Stc_Not_found);;
@@ -451,33 +457,33 @@
vtype bar = char; |
} |
*)
-let a = Scoop_Class
- { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes [] } in
-let b = Scoop_Class
- { super = a;
+let b =
+ Scoop_Class { super = a;
vtypes = create_vtypes ["foo", Stc_Abstract] } in
-let x = Scoop_Class
- { super = Stc_None;
+let x =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes [("bar", Stc_Abstract);
("hop", Std_Int)] } in
-let y = Scoop_Class
- { super = x;
+let y =
+ Scoop_Class { super = x;
vtypes = create_vtypes [("bar", Std_Char);
("baz", Std_Short)] } in
-let c = Scoop_Class
- { super = b;
+let c =
+ Scoop_Class { super = b;
vtypes = create_vtypes [("delegatee_type", y);
("foo", Std_Int);
("baz", Stc_Not_delegated);
("hop", Stc_Not_delegated)] } in
-let d = Scoop_Class
- { super = c;
+let d =
+ Scoop_Class { super = c;
vtypes = create_vtypes [("quux", Std_Unsigned)] } in
-let e = Scoop_Class
- { super = d;
+let e =
+ Scoop_Class { super = d;
vtypes = create_vtypes [("baz", Std_Float)] } in
assert (find e "foo" = Std_Int);
@@ -503,20 +509,20 @@
{ |
} |
*)
-let a = Scoop_Class
- { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["foo", Stc_Abstract] } in
-let x = Scoop_Class
- { super = Stc_None;
+let x =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["foo", Std_Int] } in
-let b = Scoop_Class
- { super = a;
+let b =
+ Scoop_Class { super = a;
vtypes = create_vtypes [("delegatee_type", x);
("foo", Stc_Not_delegated)] } in
-let c = Scoop_Class
- { super = b;
+let c =
+ Scoop_Class { super = b;
vtypes = create_vtypes [] } in
(* foo is abstract and tagged ``not delegated'' for B. *)
@@ -544,20 +550,20 @@
vtype foo = 0 |
} |
*)
-let a = Scoop_Class
- { super = Stc_None;
+let a =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes [] } in
-let x = Scoop_Class
- { super = Stc_None;
+let x =
+ Scoop_Class { super = Stc_None;
vtypes = create_vtypes ["foo", Std_Int] } in
-let b = Scoop_Class
- { super = a;
+let b =
+ Scoop_Class { super = a;
vtypes = create_vtypes [("delegatee_type", x);
("foo", Stc_Not_delegated)] } in
-let c = Scoop_Class
- { super = b;
+let c =
+ Scoop_Class { super = b;
vtypes = create_vtypes ["foo", Stc_Abstract] } in
(* foo is abstract and tagged ``not delegated'' for B. *)
@@ -565,3 +571,47 @@
(* Likewise for C. *)
try ignore (find c "foo") with Scoop_exception "find: VT is abstract." -> ()
;;
+
+
+(* Olena-like examples.
+
+ class /image_entry/ < stc::none
+ {
+ vtype value_type = 0;
+ }
+
+ class image2d<int> < image_entry
+ {
+ vtypes value_type = int;
+ }
+
+ class /value_morpher/ < image_entry
+ {
+ vtype delegatee_type = 0;
+ vtype value_type = stc::not_delegated;
+ }
+
+ class value_cast<image2d<int>, float> < value_morpher
+ {
+ vtype delegatee_type = image2d<int>;
+ vtype value_type = float;
+ }
+*)
+
+let image_entry =
+ Scoop_Class { super = Stc_None;
+ vtypes = create_vtypes ["value_type", Stc_Abstract] } in
+let image2d_int =
+ Scoop_Class { super = image_entry;
+ vtypes = create_vtypes ["value_type", Std_Int] } in
+let value_morpher =
+ Scoop_Class { super = image_entry;
+ vtypes = create_vtypes [("delegatee_type", Stc_Abstract);
+ ("value_type", Stc_Not_delegated)]} in
+let value_cast__image2d_int__float =
+ Scoop_Class { super = value_morpher;
+ vtypes = create_vtypes [("delegatee_type", image2d_int);
+ ("value_type", Std_Float)] } in
+
+assert (find image2d_int "value_type" = Std_Int);
+assert (find value_cast__image2d_int__float "value_type" = Std_Float);;
Index: doc/algorithms.txt
--- doc/algorithms.txt (revision 715)
+++ doc/algorithms.txt (working copy)
@@ -2,8 +2,160 @@
These algorithms are expressed in a pseudo-Caml like syntax.
+
+===========================================================================
+* Preamble
+
+Notes:
+
+- syntax: foo#super returns the type of the super class of foo.
+
+- syntax: 'foo_type' stands for the SCOOP virtual type named foo_type.
+
+- stc::none#super is an error, but calling `find (none, ...)' returns
+ stc::not_found.
+
+
+===========================================================================
+* Top-down approach
+
+These algorithms have been prototyped in algorithms.ml.
+
+** find
+
+function find (source, target, string) =
+ let res = find_rec (source, target) in
+ match res with
+ | stc::abstract -> error "find: VT is abstract."
+ | stc::not_delegated_abstract -> error "find: VT is abstract."
+ | stc::not_delegated -> stc::not_found
+ | stc::final t -> t
+ | t -> t
+
+
+** find_rec
+
+function find_rec (source, target) =
+ if (source = mlc::none)
+ stc::not_found
+ else
+ let local_res = find_local (source, target) in
+
+ let super_res = find_rec (source#super, target) in
+ /* FIXME: This might not be efficient, since find_rec can be
+ called several times on the nodes of the delegation branch when
+ going down the inheritance branch. Of course, the declarative
+ nature of C++ templates will avoid this cost, but it might be
+ inelegant -- I'm not sure). */
+ let delegatee = find_rec_in_supers (source, 'delegatee_type') in
+ let delegatee_res =
+ match delegatee with
+ | stc::not_found -> stc::not_found
+ | stc::abstract -> stc::not_found
+ | _ -> find_rec delegatee target in
+
+ merge3 (local_res, super_res, delegatee_res)
+
+
+// Like find_rec, but only search in the inheritance branch.
+function find_rec_in_supers (source, target) =
+ if (source = mlc::none)
+ stc::not_found
+ else
+ let local_res = find_local (source, target) in
+ let super_res = find_rec (source#super, target) in
+ merge2 (local_res, super_res)
+
+
+merge2 (local_res, super_res) =
+ match local_res, super_res with
+
+ | stc::abstract, stc::not_found -> stc::abstract
+ | mlc::not_found, stc::not_found -> stc::not_found
+ | T, stc::not_found -> T
+ | stc::final<T>, stc::not_found -> stc::final<T>
+
+ | mlc::not_found, stc::abstract -> stc::not_found
+ | stc::abstract, stc::abstract -> stc::abstract
+ | T, stc::abstract -> T
+ | stc::final<T>, stc::abstract -> stc::final<T>
+
+ | stc::abstract, U -> error ("VT redefined abstract.")
+ | mlc::not_found, U -> U
+ | T, U -> T
+ | stc::final<T>, U -> stc::final<T>
+
+ | stc::abstract, stc::final<U> -> error ("Final VT redefined abstract")
+ | mlc::not_found, stc::final<U> -> stc::final<U>
+ | T, stc::final<U> -> error ("Final VT redefined.")
+ | stc::final<T>, stc::final<U> -> error ("Final VT redefined final.")
+
+
+merge3 (local_res, super_res, delegatee_res) =
+ match local_res, super_res, delegatee_res with
+
+ // local_res == stc::not_found.
+ | mlc::not_found, stc::not_found, stc::not_found -> stc::not_found
+ | mlc::not_found, stc::not_found, stc::abstract -> stc::not_found
+ | mlc::not_found, stc::not_found, stc::final<V> -> stc::final<V>
+ | mlc::not_found, stc::not_found, V -> V
+
+ | mlc::not_found, stc::abstract, stc::not_found -> stc::not_found
+ | mlc::not_found, stc::abstract, stc::abstract -> stc::abstract
+ | mlc::not_found, stc::abstract, stc::final<V> -> stc::final<V>
+ | mlc::not_found, stc::abstract, V -> V
+
+ | mlc::not_found, stc::final<U>, _ -> stc::final<U>
+ | mlc::not_found, U, _ -> U
+
+
+ // local_res == stc::not_abstract.
+ | stc::abstract, stc::not_found, stc::not_found -> stc::abstract
+ | stc::abstract, stc::not_found, stc::abstract -> stc::abstract
+ | stc::abstract, stc::not_found, stc::final<V> -> stc::final<V>
+ | stc::abstract, stc::not_found, V -> V
+
+ | stc::abstract, stc::abstract, stc::not_found -> stc::abstract
+ | stc::abstract, stc::abstract, stc::abstract -> stc::abstract
+ | stc::abstract, stc::abstract, stc::final<V> -> stc::final<V>
+ | stc::abstract, stc::abstract, V -> V
+
+ | stc::abstract, stc::not_delegated_abstract, _ -> stc::not_delegated_abstract
+ | stc::abstract, stc::not_delegated, _ -> stc::not_delegated_abstract
+
+ | stc::abstract, stc::final<U>, _ -> error ("Final VT "
+ "redefined abstract")
+ | stc::abstract, U, _ -> error ("VT redefined "
+ "abstract.")
+ // local_res == stc::not_delegated.
+ | stc::not_delegated, stc::not_found, _ -> stc::not_delegated
+ | stc::not_delegated, stc::abstract, _ -> stc::not_delegated_abstract
+ | stc::not_delegated, stc::not_delegated_abstract, _ -> 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::not_delegated_abstract, _, _ -> error ("Local "
+ "declaration of "
+ "not delegated "
+ "and abstract")
+
+ // local_res == stc::final<T>.
+ | stc::final<T>, stc::final<U>, _ -> error ("Final VT "
+ "redefined final.")
+ | stc::final<T>, _, _ -> stc::final<T>
+
+ // local_res == T.
+ | T, stc::final<U>, _ -> error ("Final VT "
+ "redefined.")
+ | T, _, _ -> T
+
+
+
+
===========================================================================
-* Bottom-up approach (not finished)
+* Bottom-up approach (FIXME: not finished, and old)
This implementation doesn't handle stc::not_delegated properly.
@@ -131,141 +283,3 @@
| stc::abstract, U -> U
| T, _ -> T
-
-
-Notes:
-
-- syntax: foo#super returns the type of the super class of foo.
-
-- syntax: 'foo_type' stands for the SCOOP virtual type named foo_type.
-
-- stc::none#super is an error, so calling `find (none, ...)' might be
- an error !
-
-
-===========================================================================
-* Top-down approach
-
-
-** find
-
-FIXME: To be written from algorithms.ml.
-
-** find_rec
-
-function find_rec (source, target) =
- if (source = mlc::none)
- stc::not_found
- else
- let local_res = find_local (source, target) in
-
- let super_res = find_rec (source#super, target) in
- // FIXME: This might not be efficient, since find_rec can be
- // called several times on the nodes of the delegation branch when
- // going down the inheritance branch. Of course, the declarative
- // nature of C++ templates will avoid this cost, but it remains
- // inelegant, IMHO.
-
- let delegatee = find_rec_in_supers (source, 'delegatee_type') in
- let delegatee_res =
- if (delegatee = stc::not_found)
- stc::not_found
- else
- find_rec (delegatee, target) in
-
- merge3 (local_res, super_res, delegatee_res)
-
-
-// Like find_rec, but only search in the inheritance branch.
-function find_rec_in_supers (source, target) =
- if (source = mlc::none)
- stc::not_found
- else
- let local_res = find_local (source, target) in
- let super_res = find_rec (source#super, target) in
- merge2 (local_res, super_res)
-
-
-merge2 (local_res, super_res) =
- match local_res, super_res with
-
- | stc::abstract, stc::not_found -> stc::abstract
- | mlc::not_found, stc::not_found -> stc::not_found
- | T, stc::not_found -> T
- | stc::final<T>, stc::not_found -> stc::final<T>
-
- | mlc::not_found, stc::abstract -> stc::not_found
- | stc::abstract, stc::abstract -> stc::abstract
- | T, stc::abstract -> T
- | stc::final<T>, stc::abstract -> stc::final<T>
-
- | stc::abstract, U -> error ("VT redefined abstract.")
- | mlc::not_found, U -> U
- | T, U -> T
- | stc::final<T>, U -> stc::final<T>
-
- | stc::abstract, stc::final<U> -> error ("Final VT redefined abstract")
- | mlc::not_found, stc::final<U> -> stc::final<U>
- | T, stc::final<U> -> error ("Final VT redefined.")
- | stc::final<T>, stc::final<U> -> error ("Final VT redefined final.")
-
-
-merge3 (local_res, super_res, delegatee_res) =
- match local_res, super_res, delegatee_res with
-
- // local_res == stc::not_found.
- | mlc::not_found, stc::not_found, stc::not_found -> stc::not_found
- | mlc::not_found, stc::not_found, stc::abstract -> stc::not_found
- | mlc::not_found, stc::not_found, stc::final<V> -> stc::final<V>
- | mlc::not_found, stc::not_found, V -> V
-
- | mlc::not_found, stc::abstract, stc::not_found -> stc::not_found
- | mlc::not_found, stc::abstract, stc::abstract -> stc::abstract
- | mlc::not_found, stc::abstract, stc::final<V> -> stc::final<V>
- | mlc::not_found, stc::abstract, V -> V
-
- | mlc::not_found, stc::final<U>, _ -> stc::final<U>
- | mlc::not_found, U, _ -> U
-
-
- // local_res == stc::not_abstract.
- | stc::abstract, stc::not_found, stc::not_found -> stc::abstract
- | stc::abstract, stc::not_found, stc::abstract -> stc::abstract
- | stc::abstract, stc::not_found, stc::final<V> -> stc::final<V>
- | stc::abstract, stc::not_found, V -> V
-
- | stc::abstract, stc::abstract, stc::not_found -> stc::abstract
- | stc::abstract, stc::abstract, stc::abstract -> stc::abstract
- | stc::abstract, stc::abstract, stc::final<V> -> stc::final<V>
- | stc::abstract, stc::abstract, V -> V
-
- | stc::abstract, stc::not_delegated_abstract, _ -> stc::not_delegated_abstract
- | stc::abstract, stc::not_delegated, _ -> stc::not_delegated_abstract
-
- | stc::abstract, stc::final<U>, _ -> error ("Final VT "
- "redefined abstract")
- | stc::abstract, U, _ -> error ("VT redefined "
- "abstract.")
- // local_res == stc::not_delegated.
- | stc::not_delegated, stc::not_found, _ -> stc::not_delegated
- | stc::not_delegated, stc::abstract, _ -> stc::not_delegated_abstract
- | stc::not_delegated, stc::not_delegated_abstract, _ -> 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::not_delegated_abstract, _, _ -> error ("Local "
- "declaration of "
- "not delegated "
- "and abstract")
-
- // local_res == stc::final<T>.
- | stc::final<T>, stc::final<U>, _ -> error ("Final VT "
- "redefined final.")
- | stc::final<T>, _, _ -> stc::final<T>
-
- // local_res == T.
- | T, stc::final<U>, _ -> error ("Final VT "
- "redefined.")
- | T, _, _ -> T
1
0
https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from Roland Levillain <roland(a)lrde.epita.fr>
Start a draft of Static's documentation.
* doc/README, doc/intro.txt, doc/rules.txt, doc/scool.txt,
* doc/algorithms.txt: New.
* doc/algorithms.ml: New (prototype of Static's type-checking rules,
written in Objective Caml).
* stc/scoop.hh: Typos, FIXMEs.
doc/README | 20 +
doc/algorithms.ml | 567 +++++++++++++++++++++++++++++++++++++++++++++++++++++
doc/algorithms.txt | 271 +++++++++++++++++++++++++
doc/intro.txt | 292 +++++++++++++++++++++++++++
doc/rules.txt | 514 ++++++++++++++++++++++++++++++++++++++++++++++++
doc/scool.txt | 12 +
stc/scoop.hh | 11 -
7 files changed, 1685 insertions(+), 2 deletions(-)
Index: doc/algorithms.ml
--- doc/algorithms.ml (revision 0)
+++ doc/algorithms.ml (revision 0)
@@ -0,0 +1,567 @@
+(* Prototyping SCOOP's algorithms on virtual types in Objective Caml. *)
+
+
+(*--------.
+| Types. |
+`--------*)
+
+module StringType =
+ struct
+ type t = string
+ let compare = String.compare
+ end
+;;
+
+module StringMap = Map.Make (StringType);;
+
+
+type cxx_type =
+ (* Static stypes. *)
+ | Stc_None
+ | Stc_Not_found
+ | Stc_Abstract
+ | Stc_Not_delegated
+ | Stc_Not_delegated_Abstract
+ | Stc_Final of cxx_type
+
+ (* C++ types. *)
+ | Std_Char
+ | Std_Short
+ | Std_Int
+ | Std_Unsigned
+ | Std_Float
+ | Scoop_Class of scoop_class
+
+and vtypes_dict = cxx_type StringMap.t
+and scoop_class = { super: cxx_type; vtypes: vtypes_dict }
+;;
+
+(* A helper to create virtual types sets. *)
+let rec create_vtypes = function
+ | [] -> StringMap.empty
+ | (type_name, type_val)::t ->
+ StringMap.add type_name type_val (create_vtypes t)
+;;
+
+
+(*-----------------.
+| Error handling. |
+`-----------------*)
+
+exception Scoop_exception of string;;
+
+let error =
+ function s -> raise (Scoop_exception s)
+;;
+
+
+(*----------------------.
+| Virtual type lookup. |
+`----------------------*)
+
+let find_local (source: cxx_type) (target: string) : cxx_type =
+ match source with
+ | Scoop_Class c ->
+ begin
+ try
+ StringMap.find target c.vtypes
+ with Not_found -> Stc_Not_found
+ end
+ | _ -> raise (Scoop_exception "find_local: source is not SCOOP class.")
+;;
+
+let merge2 (local_res : cxx_type) (super_res : cxx_type) : cxx_type =
+ match local_res, super_res with
+
+ | Stc_Abstract, Stc_Not_found -> Stc_Abstract
+ | Stc_Not_found, Stc_Not_found -> Stc_Not_found
+ | Stc_Final t, Stc_Not_found -> Stc_Final t
+ | t, Stc_Not_found -> t
+
+ | Stc_Not_found, Stc_Abstract -> Stc_Not_found
+ | Stc_Abstract, Stc_Abstract -> Stc_Abstract
+ | Stc_Final t, Stc_Abstract -> Stc_Final t
+ | t, Stc_Abstract -> t
+
+ | Stc_Abstract, Stc_Final u -> error "Final VT redefined abstract"
+ | Stc_Not_found, Stc_Final u -> Stc_Final u
+ | Stc_Final t, Stc_Final u -> error "Final VT redefined final."
+ | t, Stc_Final u -> error "Final VT redefined."
+
+ | Stc_Abstract, u -> error "VT redefined abstract."
+ | Stc_Not_found, u -> u
+ | Stc_Final t, u -> Stc_Final t
+ | t, u -> t
+
+;;
+
+(* Another version (rewriting) of merge3. *)
+let merge3 (local_res : cxx_type) (super_res : cxx_type)
+ (delegatee_res : cxx_type) : cxx_type =
+ match local_res, super_res, delegatee_res with
+
+ (* local_res == stc::not_found. *)
+ | Stc_Not_found, Stc_Not_found, Stc_Not_found -> Stc_Not_found
+ | Stc_Not_found, Stc_Not_found, Stc_Abstract -> Stc_Not_found
+ | Stc_Not_found, Stc_Not_found, Stc_Final v -> Stc_Final v
+ | Stc_Not_found, Stc_Not_found, v -> v
+
+ | Stc_Not_found, Stc_Abstract, Stc_Not_found -> Stc_Not_found
+ | Stc_Not_found, Stc_Abstract, Stc_Abstract -> Stc_Abstract
+ | Stc_Not_found, Stc_Abstract, Stc_Final v -> Stc_Final v
+ | Stc_Not_found, Stc_Abstract, v -> v
+
+ | Stc_Not_found, Stc_Final u, _ -> Stc_Final u
+ | Stc_Not_found, u, _ -> u
+
+ (* local_res == stc::not_abstract. *)
+ | Stc_Abstract, Stc_Not_found, Stc_Not_found -> Stc_Abstract
+ | Stc_Abstract, Stc_Not_found, Stc_Abstract -> Stc_Abstract
+ | Stc_Abstract, Stc_Not_found, Stc_Final v -> Stc_Final v
+ | Stc_Abstract, Stc_Not_found, v -> v
+
+ | Stc_Abstract, Stc_Abstract, Stc_Not_found -> Stc_Abstract
+ | Stc_Abstract, Stc_Abstract, Stc_Abstract -> Stc_Abstract
+ | Stc_Abstract, Stc_Abstract, Stc_Final v -> Stc_Final v
+ | Stc_Abstract, Stc_Abstract, v -> v
+
+ | Stc_Abstract, Stc_Not_delegated_Abstract, _ -> Stc_Not_delegated_Abstract
+ | Stc_Abstract, Stc_Not_delegated, _ -> Stc_Not_delegated_Abstract
+
+ | Stc_Abstract, Stc_Final u, _ -> error ("Final VT " ^
+ "redefined abstract")
+ | Stc_Abstract, u, _ -> error ("VT redefined " ^
+ "abstract.")
+
+ (* local_res == stc::not_delegated. *)
+ | Stc_Not_delegated, Stc_Not_found, _ -> Stc_Not_delegated
+ | Stc_Not_delegated, Stc_Abstract, _ -> Stc_Not_delegated_Abstract
+ | Stc_Not_delegated, Stc_Not_delegated_Abstract, _ -> 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_Not_delegated_Abstract, _, _ -> error ("Local declaration" ^
+ " of not delegated" ^
+ " and abstract")
+
+ (* local_res == stc::final<T>. *)
+ | Stc_Final t, Stc_Final u, _ -> error ("Final VT " ^
+ "redefined final.")
+ | Stc_Final t, _, _ -> Stc_Final t
+
+ (* local_res == T. *)
+ | t, Stc_Final u, _ -> error ("Final VT " ^
+ "redefined.")
+ | t, _, _ -> t
+
+;;
+
+
+let rec find_rec (source : cxx_type) (target : string) : cxx_type =
+ match source with
+ | Stc_None -> Stc_Not_found
+ | Scoop_Class c ->
+ begin
+ let local_res = find_local source target in
+
+ let super_res = find_rec c.super target in
+ (* FIXME: This might not be efficient, since
+ find_rec_in_super can be called several times on the
+ nodes of the delegation branch when going down the
+ inheritance branch. Of course, the declarative nature
+ of C++ templates will avoid this cost, but it remains
+ inelegant, IMHO. *)
+
+ let delegatee = find_rec_in_supers source "delegatee_type" in
+ let delegatee_res =
+ if delegatee = Stc_Not_found then
+ Stc_Not_found
+ else
+ find_rec delegatee target in
+
+ merge3 local_res super_res delegatee_res
+ end
+ | _ -> error "find_rec: source is not a SCOOP class."
+
+(* Like find_rec, but only search in the inheritance branch. *)
+and find_rec_in_supers (source : cxx_type) (target : string) : cxx_type =
+ match source with
+ | Stc_None -> Stc_Not_found
+ | Scoop_Class c ->
+ begin
+ let local_res = find_local source target in
+ let super_res = find_rec c.super target in
+ merge2 local_res super_res
+ end
+ | _ -> error "find_rec_in_supers: source is not a SCOOP class."
+;;
+
+
+let find (source : cxx_type) (target : string) : cxx_type =
+ match find_rec source target with
+ | Stc_Abstract -> error "find: VT is abstract."
+ | Stc_Not_delegated_Abstract -> error "find: VT is abstract."
+ | Stc_Not_delegated -> Stc_Not_found
+ | Stc_Final t -> t
+ | t -> t
+;;
+
+
+
+(*-----------.
+| Examples. |
+`-----------*)
+
+(* ** Virtual type definition
+
+ Ex.
+
+ class A < stc::none =
+ {
+ vtype my_type = int;
+ }
+*)
+let a = Scoop_Class { super = Stc_None;
+ vtypes = create_vtypes ["my_type", Std_Int] } in
+assert (find a "my_type" = Std_Int);;
+
+
+(* ** Virtual type re-definition.
+
+ Ex.
+
+ class A < stc::none =
+ {
+ vtype my_type = int;
+ }
+ // Valid.
+ class B < A =
+ {
+ vtype my_type = float;
+ }
+ // Valid.
+ class C < A =
+ {
+ vtype my_type = int;
+ }
+*)
+let a = Scoop_Class { super = Stc_None;
+ vtypes = create_vtypes ["my_type", Std_Int] } in
+let b = Scoop_Class { super = a;
+ vtypes = create_vtypes ["my_type", Std_Float] } in
+let c = Scoop_Class { super = b;
+ vtypes = create_vtypes ["my_type", Std_Int] } in
+assert (find c "my_type" = Std_Int);;
+
+
+(* ** Virtual type abstract declaration (i.e., deferred definition).
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ // my_type is abstract.
+ vtype my_type = 0;
+ }
+ class B < A =
+ {
+ vtype my_type = int;
+ }
+*)
+let a = Scoop_Class { super = Stc_None;
+ vtypes = create_vtypes ["my_type", Stc_Abstract] } in
+let b = Scoop_Class { super = a;
+ vtypes = create_vtypes ["my_type", Std_Int] } in
+assert (find b "my_type" = Std_Int);;
+
+(* - A concrete virtual type cannot be redefined as abstract.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ vtype my_type = int;
+ }
+ // Invalid.
+ class B < A =
+ {
+ vtype my_type = 0;
+ }
+*)
+let a = Scoop_Class { super = Stc_None;
+ vtypes = create_vtypes ["my_type", Std_Int] } in
+let b = Scoop_Class { super = a;
+ vtypes = create_vtypes ["my_type", Stc_Abstract] } in
+ try
+ ignore (find b "my_type")
+ with Scoop_exception "VT redefined abstract." -> ()
+;;
+
+
+(* ** Final virtual type
+
+ - A virtual type can be tagged as final.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ final vtype my_type = int;
+ }
+*)
+let a = Scoop_Class { super = Stc_None;
+ vtypes = create_vtypes ["my_type", Stc_Final Std_Int] }
+in
+assert (find a "my_type" = Std_Int);;
+
+(* - A virtual type tagged as final in a class cannot be redefined in its
+ subclasses, either tagged final or not, even if its value is
+ unchanged.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ final vtype my_type = int;
+ }
+ // Invalid.
+ class B < A =
+ {
+ vtype my_type = float;
+ }
+ // Invalid.
+ class C < A =
+ {
+ vtype my_type = int;
+ }
+ // Invalid.
+ class D < A =
+ {
+ final vtype my_type = int;
+ }
+ // Invalid.
+ class E < A =
+ {
+ final vtype my_type = float;
+ }
+*)
+let a = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes ["my_type", Stc_Final Std_Int] } in
+let b = Scoop_Class
+ { super = a;
+ vtypes = create_vtypes ["my_type", Std_Float] } in
+let c = Scoop_Class
+ { super = a;
+ vtypes = create_vtypes ["my_type", Std_Int] } in
+let d = Scoop_Class
+ { super = a;
+ vtypes = create_vtypes ["my_type", Stc_Final Std_Int] } in
+let e = Scoop_Class
+ { super = a;
+ vtypes = create_vtypes ["my_type", Stc_Final Std_Float] } in
+
+ assert (find a "my_type" = Std_Int);
+ try ignore (find b "my_type")
+ with Scoop_exception "Final VT redefined." -> ();
+ try ignore (find c "my_type")
+ with Scoop_exception "Final VT redefined." -> ();
+ try ignore (find d "my_type")
+ with Scoop_exception "Final VT redefined final." -> ();
+ try ignore (find e "my_type")
+ with Scoop_exception "Final VT redefined final." -> ();
+;;
+
+(* ** General virtual type lookup
+
+ *** Abstract
+
+ class A < stc::none
+ {
+ // my_vtype not defined.
+ }
+
+ class D < stc::none
+ {
+ vtype my_type = 0;
+ }
+
+ // A
+ // ^
+ // |
+ // C<>--D
+ class C < stc::none
+ {
+ vtype delegatee_type = D;
+ }
+
+ // FIXME: What should be the value of ``t''?
+ // I would say ``stc::not_found'', but I'm not sure (see intro.txt, too).
+ type t = C#my_type;
+*)
+let a = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes [] } in
+let d = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes ["my_type", Stc_Abstract] } in
+let c = Scoop_Class
+ { super = a;
+ vtypes = create_vtypes ["delegatee_type", d] } in
+assert (find c "my_type" = Stc_Not_found);;
+
+
+(* More examples.
+
+ ** A complex example, with stc::not_delegated.
+
+ A
+ ^
+ | X
+ B ^
+ ^ |
+ | Y
+ C<>-�
+ ^
+ |
+ D
+ ^
+ |
+ E
+
+
+ class A < stc::none | class C < B
+ { | {
+ } | vtype delegatee_type = Y;
+ class B < A | vtype foo = int;
+ { | vtype baz = not_delegated;
+ vtype foo = 0; | vtype hop = not_delegated;
+ } | }
+ | class D < C
+ class X < stc::none | {
+ { | vtype quux = unsigned;
+ vtype bar = 0; | }
+ vtype hop = int; | class E < D
+ } | {
+ class Y < X | vtype baz = float;
+ { | }
+ vtype baz = short; |
+ vtype bar = char; |
+ } |
+*)
+let a = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes [] } in
+let b = Scoop_Class
+ { super = a;
+ vtypes = create_vtypes ["foo", Stc_Abstract] } in
+
+let x = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes [("bar", Stc_Abstract);
+ ("hop", Std_Int)] } in
+let y = Scoop_Class
+ { super = x;
+ vtypes = create_vtypes [("bar", Std_Char);
+ ("baz", Std_Short)] } in
+
+let c = Scoop_Class
+ { super = b;
+ vtypes = create_vtypes [("delegatee_type", y);
+ ("foo", Std_Int);
+ ("baz", Stc_Not_delegated);
+ ("hop", Stc_Not_delegated)] } in
+let d = Scoop_Class
+ { super = c;
+ vtypes = create_vtypes [("quux", Std_Unsigned)] } in
+let e = Scoop_Class
+ { super = d;
+ vtypes = create_vtypes [("baz", Std_Float)] } in
+
+assert (find e "foo" = Std_Int);
+assert (find e "bar" = Std_Char);
+assert (find e "baz" = Std_Float);
+assert (find e "quux" = Std_Unsigned);
+assert (find e "hop" = Stc_Not_found);
+;;
+
+
+(* *** abstract redefined with tag stc::not_delegated.
+
+ class A < stc::none |
+ { |
+ vtype foo = 0 |
+ } |
+ class B < A | class X < stc::none
+ { | {
+ vtype delegatee_type = X; | vtype foo = int;
+ vtype foo = stc::not_delegated | }
+ } |
+ class C < B |
+ { |
+ } |
+*)
+let a = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes ["foo", Stc_Abstract] } in
+
+let x = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes ["foo", Std_Int] } in
+
+let b = Scoop_Class
+ { super = a;
+ vtypes = create_vtypes [("delegatee_type", x);
+ ("foo", Stc_Not_delegated)] } in
+let c = Scoop_Class
+ { super = b;
+ vtypes = create_vtypes [] } in
+
+(* foo is abstract and tagged ``not delegated'' for B. *)
+try ignore (find b "foo") with Scoop_exception "find: VT is abstract." -> ();
+(* Likewise for C. *)
+try ignore (find c "foo") with Scoop_exception "find: VT is abstract." -> ()
+;;
+
+
+(* *** abstract redefined with tag stc::not_delegated.
+
+ This is the converse situation from the previous example (foo is
+ declared abstract in C instead of A).
+
+ class A < stc::none |
+ { |
+ } |
+ class B < A | class X < stc::none
+ { | {
+ vtype delegatee_type = X; | vtype foo = int;
+ vtype foo = stc::not_delegated | }
+ } |
+ class C < B |
+ { |
+ vtype foo = 0 |
+ } |
+*)
+let a = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes [] } in
+
+let x = Scoop_Class
+ { super = Stc_None;
+ vtypes = create_vtypes ["foo", Std_Int] } in
+
+let b = Scoop_Class
+ { super = a;
+ vtypes = create_vtypes [("delegatee_type", x);
+ ("foo", Stc_Not_delegated)] } in
+let c = Scoop_Class
+ { super = b;
+ vtypes = create_vtypes ["foo", Stc_Abstract] } in
+
+(* foo is abstract and tagged ``not delegated'' for B. *)
+assert (find b "foo" = Stc_Not_found);
+(* Likewise for C. *)
+try ignore (find c "foo") with Scoop_exception "find: VT is abstract." -> ()
+;;
Index: doc/algorithms.txt
--- doc/algorithms.txt (revision 0)
+++ doc/algorithms.txt (revision 0)
@@ -0,0 +1,271 @@
+SCOOP 2 - algorithms -*- outline -*-
+
+These algorithms are expressed in a pseudo-Caml like syntax.
+
+===========================================================================
+* Bottom-up approach (not finished)
+
+This implementation doesn't handle stc::not_delegated properly.
+
+** find_local
+
+fun find_local (source, target) =
+ mlc::get_typedef (source, target)
+
+(get_typedef is a routine from Metalic.)
+
+
+** find
+
+// FIXME: Handle final.
+
+fun find (source, target) =
+ if (source == stc::none)
+ error ("find: cannot perform lookup on stc::none.") // FIXME: Detail.
+ else
+ let local_type = find_local (source, target) in
+ let delegatee_type = find_local (source, 'delegatee_type') in
+
+ match local_type with
+
+ | stc::abstract -> error ("find: abstract virtual type in leaf class.")
+
+ | stc::no_delegation ->
+ // Look only in the inheritance branch only.
+ find_rec (source#super, target)
+
+ | mlc::not_found ->
+ if (delegatee_type = mlc::not_found)
+ // Look only in the inheritance branch only.
+ find_rec (source#super, target)
+ else
+ let inheritance_branch_res = find_rec (source#super, target) in
+ let delegation_branch_res = find_rec (delegatee_type, target) in
+ merge (inheritance_branch_res, delegation_branch_res)
+
+ | T -> T
+
+
+** find_rec0
+
+(Previous version of find_rec.)
+
+fun find_rec0 (source, target, is_abstract = false) =
+ let local_type = find_local (source, target) in
+
+ match local_type, source#super, is_abstract with
+
+ | stc::not_delegated, _ , _ ->
+ error ("find_rec: stc::delegation found in non-leaf class.")
+
+ | mlc::not_found, mlc::none, _ -> stc::not_found
+ | mlc::not_found, S , _ -> find_rec (S, target, is_abstract)
+
+ | stc::abstract, mlc::none, _ -> stc::abstract
+ | stc::abstract, S , _ -> find_rec (S, target, true)
+
+ // Final<T> is handled like T (the checks are performed elsewhere).
+ | stc::final<T>, _, false -> T
+ | stc::final<T>, _, true ->
+ error ("find_rec: virtual type redefined abstract.")
+
+ | T, _, false -> T
+ | T, _, true ->
+ error ("find_rec: virtual type redefined abstract.")
+
+
+** find_rec
+
+FIXME: Improve the automaton of the states (abstract, defined, final,
+etc.)
+
+fun find_rec (source, target, res = stc::not_found) =
+ if (source = mlc::none)
+ res
+ else
+ let local_type = find_local (source, target) in
+
+ match local_type, res with
+
+ | stc::not_delegated, _ ->
+ error ("find_rec: stc::delegation found in non-leaf class.")
+
+ | mlc::not_found, _ -> find_rec (source#super, target, res)
+
+ // The values below cannot be used to redefine a *final* virtual type.
+
+ | stc::abstract, _ -> find_rec (source#super, target, stc::abstract)
+
+ | T, _ -> T
+ match res with
+ | stc::not_found -> find_rec (source#super, target, T)
+ | stc::abstract ->
+ // FIXME: Detail
+ error ("find_rec: virtual type redefined as abstract.")
+ | _ -> find_rec (source#super, target, T)
+
+ // stc::final<T> is handled like T, with additional checks.
+ | stc::final<T>, _ ->
+ match res with
+ | stc::not_found -> find_rec (source#super, target, T)
+ | stc::abstract ->
+ // FIXME: Detail
+ error ("find_rec: final virtual type redefined as abstract.")
+ | _ -> error ("find_rec: final virtual type redefined.")
+
+
+FIXME: Write another version where the search is performed top-down
+(in both branches). Handling the lookup this way seems to ease the
+writing of states and automata.
+
+** merge
+
+fun merge (inheritance_branch_res delegation_branch_res) =
+ match (inheritance_branch_res, delegation_branch_res)
+ | stc::not_found, stc::not_found -> stc::not_found
+ | stc::not_found, stc::abstract -> stc::not_found
+ | stc::not_found, U -> U
+
+ | stc::abstract, stc::not_found -> error () // FIXME: Detail.
+ | stc::abstract, stc::abstract -> error () // FIXME: Detail.
+ | stc::abstract, U -> U
+
+ | T, _ -> T
+
+
+Notes:
+
+- syntax: foo#super returns the type of the super class of foo.
+
+- syntax: 'foo_type' stands for the SCOOP virtual type named foo_type.
+
+- stc::none#super is an error, so calling `find (none, ...)' might be
+ an error !
+
+
+===========================================================================
+* Top-down approach
+
+
+** find
+
+FIXME: To be written from algorithms.ml.
+
+** find_rec
+
+function find_rec (source, target) =
+ if (source = mlc::none)
+ stc::not_found
+ else
+ let local_res = find_local (source, target) in
+
+ let super_res = find_rec (source#super, target) in
+ // FIXME: This might not be efficient, since find_rec can be
+ // called several times on the nodes of the delegation branch when
+ // going down the inheritance branch. Of course, the declarative
+ // nature of C++ templates will avoid this cost, but it remains
+ // inelegant, IMHO.
+
+ let delegatee = find_rec_in_supers (source, 'delegatee_type') in
+ let delegatee_res =
+ if (delegatee = stc::not_found)
+ stc::not_found
+ else
+ find_rec (delegatee, target) in
+
+ merge3 (local_res, super_res, delegatee_res)
+
+
+// Like find_rec, but only search in the inheritance branch.
+function find_rec_in_supers (source, target) =
+ if (source = mlc::none)
+ stc::not_found
+ else
+ let local_res = find_local (source, target) in
+ let super_res = find_rec (source#super, target) in
+ merge2 (local_res, super_res)
+
+
+merge2 (local_res, super_res) =
+ match local_res, super_res with
+
+ | stc::abstract, stc::not_found -> stc::abstract
+ | mlc::not_found, stc::not_found -> stc::not_found
+ | T, stc::not_found -> T
+ | stc::final<T>, stc::not_found -> stc::final<T>
+
+ | mlc::not_found, stc::abstract -> stc::not_found
+ | stc::abstract, stc::abstract -> stc::abstract
+ | T, stc::abstract -> T
+ | stc::final<T>, stc::abstract -> stc::final<T>
+
+ | stc::abstract, U -> error ("VT redefined abstract.")
+ | mlc::not_found, U -> U
+ | T, U -> T
+ | stc::final<T>, U -> stc::final<T>
+
+ | stc::abstract, stc::final<U> -> error ("Final VT redefined abstract")
+ | mlc::not_found, stc::final<U> -> stc::final<U>
+ | T, stc::final<U> -> error ("Final VT redefined.")
+ | stc::final<T>, stc::final<U> -> error ("Final VT redefined final.")
+
+
+merge3 (local_res, super_res, delegatee_res) =
+ match local_res, super_res, delegatee_res with
+
+ // local_res == stc::not_found.
+ | mlc::not_found, stc::not_found, stc::not_found -> stc::not_found
+ | mlc::not_found, stc::not_found, stc::abstract -> stc::not_found
+ | mlc::not_found, stc::not_found, stc::final<V> -> stc::final<V>
+ | mlc::not_found, stc::not_found, V -> V
+
+ | mlc::not_found, stc::abstract, stc::not_found -> stc::not_found
+ | mlc::not_found, stc::abstract, stc::abstract -> stc::abstract
+ | mlc::not_found, stc::abstract, stc::final<V> -> stc::final<V>
+ | mlc::not_found, stc::abstract, V -> V
+
+ | mlc::not_found, stc::final<U>, _ -> stc::final<U>
+ | mlc::not_found, U, _ -> U
+
+
+ // local_res == stc::not_abstract.
+ | stc::abstract, stc::not_found, stc::not_found -> stc::abstract
+ | stc::abstract, stc::not_found, stc::abstract -> stc::abstract
+ | stc::abstract, stc::not_found, stc::final<V> -> stc::final<V>
+ | stc::abstract, stc::not_found, V -> V
+
+ | stc::abstract, stc::abstract, stc::not_found -> stc::abstract
+ | stc::abstract, stc::abstract, stc::abstract -> stc::abstract
+ | stc::abstract, stc::abstract, stc::final<V> -> stc::final<V>
+ | stc::abstract, stc::abstract, V -> V
+
+ | stc::abstract, stc::not_delegated_abstract, _ -> stc::not_delegated_abstract
+ | stc::abstract, stc::not_delegated, _ -> stc::not_delegated_abstract
+
+ | stc::abstract, stc::final<U>, _ -> error ("Final VT "
+ "redefined abstract")
+ | stc::abstract, U, _ -> error ("VT redefined "
+ "abstract.")
+ // local_res == stc::not_delegated.
+ | stc::not_delegated, stc::not_found, _ -> stc::not_delegated
+ | stc::not_delegated, stc::abstract, _ -> stc::not_delegated_abstract
+ | stc::not_delegated, stc::not_delegated_abstract, _ -> 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::not_delegated_abstract, _, _ -> error ("Local "
+ "declaration of "
+ "not delegated "
+ "and abstract")
+
+ // local_res == stc::final<T>.
+ | stc::final<T>, stc::final<U>, _ -> error ("Final VT "
+ "redefined final.")
+ | stc::final<T>, _, _ -> stc::final<T>
+
+ // local_res == T.
+ | T, stc::final<U>, _ -> error ("Final VT "
+ "redefined.")
+ | T, _, _ -> T
Index: doc/rules.txt
--- doc/rules.txt (revision 0)
+++ doc/rules.txt (revision 0)
@@ -0,0 +1,514 @@
+SCOOP 2 -- rules -*- outline -*-
+
+
+* Keywords
+
+- Keywords added to the language (both SCOOL or C++):
+
+ delegatee_type (FIXME: or stc_delegatee_type?)
+ abstract (syntax: ``= 0'')
+ final (syntax: ``final vtype ...'')
+ stc::not_found (note: different from mlc::not_found)
+ stc::not_delegated
+
+ stc::not_delegated_abstract (private type, used internally --
+ cannot be used by the programmer).
+
+ stc::none (FIXME: What about stc::top ?)
+
+ deferred_type? (FIXME: Which syntax?)
+
+
+* Declaration/definition
+
+** Class definition
+
+- A class has almost the same meaning as in C++: an entity gathering
+ data and operations. C++ (as well as SCOOL) also allows classes to
+ define types (via typedefs); this ability is part of SCOOP, and is
+ extended to the notion of virtual types (see the relevant item).
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ // A variable.
+ var pi : float = 3.14;
+ // A function.
+ fun sqr : (a : int) -> int
+ => a * a;
+ // A (classical) type.
+ type t = int
+ // A virtual type.
+ vtype vt = float;
+ }
+
+ In the present document, we will mainly deal with virtual type.
+
+- A class must inherit from another class. When a class has
+ semantically no superclass, its superclass must be set to stc::none.
+ A class having no supertype is invalid.
+
+ Ex.:
+
+ // Valid (assuming S is a valid class).
+ class A < S =
+ {
+ // ...
+ }
+
+ Ex.:
+
+ // Valid.
+ class A < stc::none =
+ {
+ // ...
+ }
+
+ Ex.:
+
+ // Invalid.
+ class A =
+ {
+ // ...
+ }
+
+** Virtual type definition
+
+- Each class can provide zero, one or more virtual type(s).
+
+ // FIXME: Validity of the definition? What can the user put in RHS?
+ // What about deferred type?
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ vtype my_type = int;
+ }
+
+
+** Virtual type re-definition
+
+- Unless declared final (see relevant item), a virtual type of a class
+ can be redefined in its subclass(es). The new value can be the same
+ or different for the inital one. The syntax is the same as the one
+ for defining a virtual type.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ vtype my_type = int;
+ }
+ // Valid.
+ class B < A =
+ {
+ vtype my_type = float;
+ }
+ // Valid.
+ class C < A =
+ {
+ vtype my_type = int;
+ }
+
+FIXME: Restrictions on computed values? (-> deferred vtypes, etc.)
+
+** Virtual type abstract declaration (i.e., deferred definition)
+
+- The definition of a virtual type can be deferred, i.e. a virtual
+ type can be just /declared/. Such a virtual type is said to be
+ abstract. A non-abstract virtual type is said to be concrete.
+
+ A class containing at least an abstract virtual type
+ (resp. containing no virtual type) is said abstract
+ (resp. concrete).
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ // my_type is abstract.
+ vtype my_type = 0;
+ }
+ class B < A =
+ {
+ vtype my_type = int;
+ }
+
+- A concrete virtual type cannot be redefined as abstract.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ vtype my_type = int;
+ }
+ // Invalid.
+ class B < A =
+ {
+ vtype my_type = 0;
+ }
+
+
+** Final virtual type
+
+- A virtual type can be tagged as final.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ final vtype my_type = int;
+ }
+
+- A virtual type tagged as final in a class cannot be redefined in its
+ subclasses, either tagged final or not, even if its value is
+ unchanged.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ final vtype my_type = int;
+ }
+ // Invalid.
+ class B < A =
+ {
+ vtype my_type = float;
+ }
+ // Invalid.
+ class C < A =
+ {
+ vtype my_type = int;
+ }
+ // Invalid.
+ class D < A =
+ {
+ final vtype my_type = int;
+ }
+ // Invalid.
+ class E < A =
+ {
+ final vtype my_type = float;
+ }
+
+- A final type cannot be abstract.
+
+ Ex.:
+
+ // Invalid.
+ class A < stc::none =
+ {
+ final vtype my_type = 0;
+ }
+
+FIXME: Is that all concerning abstract and final?
+
+
+** Delegation
+
+As stated before, any class has a super class in the SCOOP paradigm.
+SCOOP also allows a class to have a /delegatee/, i.e., a type it can
+use or depend on -- but without fulfilling the ``IS A'' relationship.
+
+- There is at most one delegatee (having a delegatee is not
+ mandatory).
+
+- Delegation is introduced thanks to a special virtual type,
+ delegatee_type (see below).
+
+*** Delegatee type
+
+- The virtual type `delegatee_type' is special: it is not looked up like
+ the other virtual types (see the lookup section).
+
+ class D < stc::none =
+ {
+ }
+ class A < stc::none =
+ {
+ vtype delegatee_type = D;
+ }
+
+- A delagatee_type virtual type can be abstract in a class, and given
+ a concrete definition in a subclass. As for other virtual types,
+ the fact that it is abstract renders the class abstract.
+
+ Ex.:
+
+ class D < stc::none =
+ {
+ }
+ class A < stc::none =
+ {
+ // Deferred definition of delagatee_type.
+ vtype delegatee_type = 0;
+ }
+ class B < A =
+ {
+ vtype delegatee_type = D;
+ }
+
+- If its no abstract, the value of a delegatee_type virtual type must
+ be a (SCOOP) class name.
+
+ class A < stc::none =
+ {
+ // Invalid.
+ vtype delegatee_type = int;
+ }
+
+- The virtual type `delegatee_type' cannot be tagged as final.
+ However, if its is actually defined (not just declared) in a class,
+ the delegatee_type virtual type cannot be subsequently redefined in
+ any of its subclasses, either with the same value or with another
+ one.
+
+
+ Ex.:
+
+ class D1 < stc::none =
+ {
+ }
+ class D2 < stc::none =
+ {
+ }
+ class A < stc::none =
+ {
+ vtype delegatee_type = D1;
+ }
+ class B < A =
+ {
+ // Invalid.
+ vtype delegatee_type = D1;
+ }
+ class C < A =
+ {
+ // Invalid.
+ vtype delegatee_type = D2;
+ }
+
+FIXME: Continue.
+
+
+* Lookup
+
+The process of retrieving a virtual type given a class (``source'')
+and a type name (``target'') is call ``virtual type lookup''. We'll
+use a has (or pound) symbol (#) to a virtual type lookup.
+
+ Ex.:
+
+ class A < stc::none =
+ {
+ vtype foo = int;
+ }
+
+ // t contains the value of the virtual type foo from class A.
+ type t = A#foo;
+
+** Local lookup
+
+Recall: The lookup process is recursive: it starts from a class (a
+priori concrete).
+
+This process relies on an `atomic' lookup on each inspected class:
+each of them can be queried for a locally defined virtual type.
+(FIXME: reference to the local_find algorithm.)
+
+The result of this local lookup is
+- mlc::not_found: meaning there is no delegatee_type;
+- another C++ type: this is then the result of the lookup;
+- a compile-time error (mlc::assert or mlc::abort), meaning that
+ something is either wrong in the virtual type definitions or in the
+ query.
+
+
+** General virtual type lookup
+
+When looking for a virtual type from a class, the answer can come from
+- the class itself, if it directly defines the virtual type;
+- one of its super classes (``the inheritance branch'');
+- if applicable, its delegatee, or one of its super classes (``the
+ delegation branch'').
+
+
+So, the lookup is performed in a single or a double (if there is a
+delegatee) recursive search up from the class in the inheritance and
+the delegation branch (if applicable).
+
+
+Teh first step in the lookup is to find whether a local definition of
+the virtual type (i.e., within the ``source'' class) exists. (See item
+``Local lookup''). If so, it is returned.
+
+If (FIXME: Finish this sentence.)
+
+
+FIXME: Do we want to perform the checks of the inheritance and
+delegation branch (in that event).
+
+Then, a delegatee_type is looked for. The result of this search can
+be either
+- stc::not_found: meaning there is no delegatee_type;
+- another C++ type: this is then the result of the lookup;
+- a compile-time error (mlc::assert or mlc::abort), meaning that
+ something is either wrong in the virtual type definitions or in the
+ query.
+
+Note: the general lookup procedure (either for delegatee_type or any
+other other virtual type) return stc::not_found when it fails to find
+the target virtual type, whereas the local lookup return
+mlc::not_found.
+
+
+
+
+FIXME: Continue.
+
+*** stc::not_delegated
+
+Cannot appear in a class of the delegation branch (aside from the
+junction class).
+
+*** Abstract
+
+[...]
+
+stc::abstract in a delegation branch:
+
+ class A < stc::none
+ {
+ // my_vtype not defined.
+ }
+
+ class D < stc::none
+ {
+ vtype my_type = 0;
+ }
+
+ // A
+ // ^
+ // |
+ // C<>--D
+ class C < stc::none
+ {
+ vtype delegatee_type = D;
+ }
+
+ // Gives stc::not_found.
+ type t = C#my_type;
+
+
+** delagatee_type lookup
+
+The lookup of delegatee_type is different from the lookup of other
+virtual types. While other virtual types are searched for in both the
+inheritance and the delegation branch, delegatee_type is only seeked
+in the inheritance branch (for infinite recursion reasons).
+
+FIXME: Continue.
+
+
+*** Abstract
+
+FIXME: Continue.
+
+* Examples
+
+
+** A complex example
+
+ A
+ ^
+ | X
+ B ^
+ ^ |
+ | Y
+ C<>-�
+ ^
+ |
+ D
+ ^
+ |
+ E
+
+ class A < stc::none
+ {
+ }
+ class B < A
+ {
+ vtype foo = 0;
+ }
+
+ class X < stc::none
+ {
+ vtype bar = 0;
+ vtype hop = int;
+ }
+ class Y < X
+ {
+ vtype bar = char;
+ vtype baz = short;
+ }
+
+ class C < B
+ {
+ vtype delegatee_type = Y;
+ vtype foo = int;
+ vtype baz = not_delegated;
+ vtype hop = not_delegated;
+ }
+ class D < C
+ {
+ vtype quux = unsigned;
+ }
+ class E < D
+ {
+ vtype baz = float;
+ }
+
+*** E#bar
+
+ A local_find(A, bar) = mlc::not_found
+ ^
+ |
+ | X local_find(X, bar) = 0
+ | ^
+ | |
+ B | local_find(B, bar) = mlc::not_found
+ ^ |
+ | |
+ | Y local_find(Y, bar) = char
+ | |
+ | |
+ C<>-� local_find(D, bar) = mlc::not_found
+ ^
+ |
+ D local_find(D, bar) = mlc::not_found
+ ^
+ |
+ E local_find(E, bar) = mlc::not_found
+
+*** E#hop
+
+ A local_find(A, bar) = mlc::not_found
+ ^
+ | X
+ B ^ local_find(B, bar) = mlc::not_found
+ ^ |
+ | Y
+ C<>-� local_find(D, bar) = stc::not_delegated
+ ^
+ |
+ D local_find(D, hop) = mlc::not_found
+ ^
+ |
+ E local_find(E, hop) = mlc::not_found
+
+
+
+Local Variables:
+ispell-local-dictionary: "american"
+End:
Index: doc/intro.txt
--- doc/intro.txt (revision 0)
+++ doc/intro.txt (revision 0)
@@ -0,0 +1,292 @@
+Static - Equipment for Static Hierarchies and SCOOP 2 -*- outline -*-
+
+This a very rough, buggy and incomplete draft of explanations on
+SCOOP 2. To be improved, fixed, and completed!
+
+
+* On virtual types
+
+A description of the mechanism of virtual types in SCOOP 2.
+
+** Rules
+
+A virtual type is like a typedef in a class scope, with added
+possibilities. Like a method (in C++),
+- it can be abstract (i.e., only declared, with a postponed
+ definition, to be given in a concrete subclass);
+- it can be altered;
+- it is resolved (looked up for) bottom-up.
+
+SCOOP 2 describes a virtual type pattern where virtual types are
+declared and (re-)defined across a class hierarchy (thanks to the
+``super'' relationship), but also across a (single) delegation
+relationship.
+
+*** Virtual type name declaration
+
+The SCOOPed namespace must be equipped for every virtual type name.
+
+*** Class virtual types.
+
+- Each class can define any number of virtual types. Some of them
+ have a special meaning (see below):
+
+ - delegatee_type
+ - (supertype ?)
+
+ Some ``values'' (i.e., type assigned to the typedef standing for a
+ vtype) have a special meaning (see below):
+
+ - stc::abstract
+ - stc::final<T>
+ - stc::not_found
+ - stc::not_delegated
+
+*** Single inheritance
+
+**** Class definition
+ A
+ ^
+ |
+ B
+
+- A class *must* declare another class as being its superclass. When A
+ is a superclass of B, B is said to be a direct subclass or direct
+ derived class of A. Every subclass of B an (indirect) subclass or
+ (indirect) derived class of A.
+
+ Ex.:
+
+ A < B
+ {
+ // ...
+ }
+
+ When a class has semantically no superclass, its superclass must
+ be set to stc::none. A class having no supertype is invalid.
+
+ Ex.:
+
+ // Valid.
+ A < stc::none
+ {
+ // ...
+ }
+
+ // Invalid.
+ A
+ {
+ // ...
+ }
+
+- A virtual defined as stc::final<T> in a class cannot be redefined
+ in any of its derived class(es).
+
+- A (non final) virtual type defined in a class can be redefined in any
+ of its subclasses.
+
+- A vtype can be /declared/ as stc::abstract. Such a definition is
+ actually a making it a virtual declaration, meaning that an actual
+ type definition is required in a concrete subclass of the class
+ where this vtype was declared abstract, for this subclass to be
+ instantiable.
+
+ To put it in a nutshell: a valid virtual type cannot resolve as
+ stc::abstract.
+
+**** Virtual type look-up
+
+- The process of resolving a vtype involves a source (a class) and a
+ vtype (a typedef). If both the structures involved and the request
+ are valid, the result of this operation is
+
+ - a typedef, if the resolution succeeded;
+ - mlc::not_found.
+
+ Note that a source must be a *concrete* class.
+
+FIXME: Describe how the look-up works here.
+
+- A virtual type can resolve as mlc::not_found, if the queried class
+ doesn't have a value for this vtype (cf. supra).
+
+*** Single inheritance + single Delegation
+
+ A
+ ^
+ |
+ C<>--D
+
+- A class can have a special vtype named `delegatee_type', whose value
+ refers to another class name. The latter class will be a delegation
+ of the former class.
+
+- Prone to discussion:
+ The `delegatee_type' vtype is not looked up like other vtypes,
+ instead, only the considered concrete class is queried -- no
+ superclass is involved in this process.
+
+ Note: in Th�o's implementation of stc/scoop.hh (revision 712 in
+ the Olena repository), the `delegatee_type' vtype *is* looked up
+ throughout the super classes of the `from' class. Obviously, this
+ look-up doesn't occur not in the delegation branch!
+
+- The rules of the vtype look-up are affected by the presence of a
+ delegation. The default global rule is: unless defined in the
+ current class, a vtype if looked in the superclass branch first, then
+ in the delegation branch.
+
+FIXME: False.
+- The look-up w.r.t. stc::final<T> remains the same, but is performed
+ in the supertype branch and the delegation branch (if applicable).
+
+- When the vtype is defined in the class where it is looked for,
+ this value is returned.
+
+ Exception: if this typedef has value stc::not_delegated, the result
+ of the look-up is the same as if there was
+ - no delegation,
+ - no definition for this vtype in the considered class,
+ i.e., the result is computed from the superclass branch *only*.
+
+
+ When the vtype if not defined in the class, the look-up is done in
+ parallel, in the superclass branch and in the delegation branch. If
+ no error has arisen during theses (internal) look-ups, two typedefs
+ are returned (one for each branch). The final result of the overall
+ look-up is the result of a merge of the two typedefs, whose rules are
+ given by the following table.
+
+FIXME: For Olena 1.0, we'll consider that a vtype in the delegation
+branch cannot be stc::abstract.
+
+ +------------------------------+-----------------------------------------+
+ | | result of the delegation branch |
+ | +----------------+----------------+-------+
+ | | | stc::abstract | |
+ | | stc::not_found | (error must | U [2] |
+ | | | not occur [1]) | |
+ +-------------+----------------+----------------+----------------+-------+
+ | result of | stc::not_found | stc::not_found | stc::not_found | U |
+ | the look-up +----------------+----------------+----------------+-------+
+ | in the | stc::abstract | error | error | U |
+ | superclass +----------------+----------------+----------------+-------+
+ | branch | T [2] | T | T | T |
+ +-------------+----------------+----------------+----------------+-------+
+
+ Notes:
+ [1] The main idea being: delegation is additional material. Note
+ that we could have chosen the other convention
+
+ FIXME: Should there be error when the inheritance branch
+ answers stc::not_found and the delegation branch answers
+ stc::abstract?
+
+ [2] T and U are two types different from stc::not_found and
+ stc::abstract.
+
+
+* A bit of formalism
+
+** Types and algorithms signatures
+
+*** Built-in values
+
+cxx_type_name // any valid C++ type
+cxx_class_name :: cxx_type_name // a C++ class/struct
+
+*** SCOOP2 values
+
+vtype_name :: cxx_type_name
+scooped_class_name :: cxx_class_name
+
+
+find :: scooped_class_name, vtype_name -> cxx_type_name
+
+
+
+
+
+---------------------------------------------------------------------------
+* Open questions on this document, things to do, etc.
+
+In all these questions, we assume that A is a superclass of B.
+Let A be a superclass of B.
+
+- Can a vtype defined in A as concrete, be redefined in B as
+ stc::abstract? (at least not for Olena 1.0).
+
+- Can a virtual defined as stc::final<T> in a class A cannot be
+ ``redefined'' as stc::final<T> (i.e., the exact same type) in a
+ derived classed B? (No.)
+
+- Can a virtual type be assigned the type stc::not_found?
+
+- Is there a `exact_type' vtype? If so, does it have to be present in
+ every class?
+
+
+** Lookup Strategies
+
+*** Bottom-up, with fork at junction and merge of both results.
+Current strategy, half-designed in algorithm.txt.
+
+*** Top-down from each top class, with merge at junction.
+To be tried/written.
+
+
+*** Linear top-down (?)
+The walk in the delegation branch is performed between the upper part
+(above the junction) and the lower part (below the junction).
+
+*** Linear bottom-up (?)
+The walk in the delegation branch is performed between the lower
+part (below the junction) and the upper part (above the junction).
+
+*** Anything else (?)
+
+
+
+** Rule enforcement (virtual types checking)
+
+*** Ensuring the vtype name is known (i.e., declared in the SCOOPed namespace
+
+*** Existence of a superclass
+
+*** Absence/uniqueness of a delegation
+
+*** Checking Final vtypes
+
+(In both branches, if applicable.)
+
+*** Ensuring that the vtype is not abstract
+
+
+** Check algorithm
+
+// FIXME: To do.
+
+** Look-up algorithm
+
+ /** Virtual type look-up.
+
+ \a source is the (concrete) class from which the look-up is performed
+ \a target is the name of the virtual type looked for (without
+ the `_type' suffix). */
+ find :: scooped_class,
+ find(source, target)
+
+ // FIXME: Write algorithm.
+
+---------------------------------------------------------------------------
+
+
+
+
+
+Local Variables:
+ispell-local-dictionary: "american"
+End:
+
+ LocalWords: typedef SCOOPed namespace delegatee supertype vtype superclass
+ LocalWords: instantiable vtypes Th�o's stc typedefs ispell american
Index: doc/scool.txt
--- doc/scool.txt (revision 0)
+++ doc/scool.txt (revision 0)
@@ -0,0 +1,12 @@
+SCOOL -- summary and extensions -*- outline -*-
+
+
+This document doesn't describe the whole SCOOL language; see
+
+ https://trac.lrde.org/olena/trac.cgi/wiki/SCOOL
+
+for a detail documentation on the language. Instead, we'll mention
+only the traits needed to explain the novelties of SCOOP 2, both
+current elements of SCOOL and extensions.
+
+...
\ No newline at end of file
Index: doc/README
--- doc/README (revision 0)
+++ doc/README (revision 0)
@@ -0,0 +1,20 @@
+Static - Equipment for Static Hierarchies and SCOOP 2 -*- outline -*-
+
+(This a rough, buggy and incomplete draft of explanations on SCOOP 2.
+To be improved, fixed, and completed!)
+
+
+intro.txt General explanations on SCOOP 2
+scool.txt Short introduction to SCOOL and its extensions
+rules.txt More formal rules on SCOOP 2
+algorithms.txt Algorithms used in the SCOOP paradigm.
+algorithms.ml Likewise, written in Objective Caml.
+static.txt ?
+...
+
+
+
+Local Variables:
+ispell-local-dictionary: "american"
+End:
+
Index: stc/scoop.hh
--- stc/scoop.hh (revision 714)
+++ stc/scoop.hh (working copy)
@@ -81,7 +81,7 @@
/* FIXME: nothing here! \
* \
* mlc::none is not a default value \
- * so that the client should define stoppers \
+ * so that the client has to define stoppers \
*/ \
}; \
\
@@ -226,7 +226,7 @@
}; \
\
template <typename res1, typename res2> \
- struct helper_get_stm \
+ struct helper_get_stm /* FIXME: Insert mlc::abort_<> statement here? */ \
{ \
/* error */ \
}; \
@@ -246,6 +246,10 @@
\
\
\
+ /* -------------------- */ \
+ /* Checking algorithm. */ \
+ /* -------------------- */ \
+ \
/* \
* check_no_final_inherited \
* \
@@ -459,6 +463,9 @@
\
\
\
+ /* ------------------- */ \
+ /* Look-up algorithm. */ \
+ /* ------------------- */ \
\
/* \
* first_stm(from, target) \
1
0