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
 
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from  Roland Levillain  <roland(a)lrde.epita.fr>
	Enforce coding style in stc::exact.
	* stc/any.hh, tests/exact.cc: s/exact_t/exact_type/g.
	* stc/exact.hh: Likewise.
	s/case_t/case_type/.
	Remove superfluous `inline' qualifiers.
 stc/any.hh     |    6 +++---
 stc/exact.hh   |   17 ++++++++---------
 tests/exact.cc |    6 +++---
 3 files changed, 14 insertions(+), 15 deletions(-)
Index: tests/exact.cc
--- tests/exact.cc	(revision 487)
+++ tests/exact.cc	(working copy)
@@ -118,7 +118,7 @@
   //-----------------------------------------
   {
     concrete t;
-    const concrete::exact_t& tmp = stc::exact(t);
+    const concrete::exact_type& tmp = stc::exact(t);
     std::cout << &t << " = "
 	      << &tmp << std::endl;
   }
@@ -132,7 +132,7 @@
   {
     concrete t;
     sub_abstraction<concrete>& st = t;
-    const sub_abstraction<concrete>::exact_t& tmp = stc::exact(st);
+    const sub_abstraction<concrete>::exact_type& tmp = stc::exact(st);
     std::cout << &t << " = "
 	      << &tmp << std::endl;
     tmp.foo();
@@ -147,7 +147,7 @@
   {
     concrete t;
     abstraction<concrete>& a = t;
-    const abstraction<concrete>::exact_t& tmp = stc::exact(a);
+    const abstraction<concrete>::exact_type& tmp = stc::exact(a);
     std::cout << &t << " = "
 	      << &tmp << std::endl;
   }
Index: stc/exact.hh
--- stc/exact.hh	(revision 487)
+++ stc/exact.hh	(working copy)
@@ -94,9 +94,9 @@
   {
     struct protected_
     {
-      typedef typename T::exact_t ret;
+      typedef typename T::exact_type ret;
 
-      static inline ret& impl(T& t)
+      static ret& impl(T& t)
       {
 	return t.exact();
       }
@@ -110,12 +110,11 @@
     {
       typedef T ret;
 
-      static inline ret& impl(T& t)
+      static ret& impl(T& t)
       {
 	return t;
       }
     };
-
   };
 
 
@@ -124,10 +123,10 @@
   {
     typedef typename switch_<tag::exact, T>::ret ret;
 
-    static inline ret& impl(const T& t)
+    static ret& impl(const T& t)
     {
-      typedef typename case_<tag::exact, T>::ret case_t;
-      return case_t::impl(const_cast<T&>(t));
+      typedef typename case_<tag::exact, T>::ret case_type;
+      return case_type::impl(const_cast<T&>(t));
     }
   };
 
@@ -137,7 +136,7 @@
   {
     typedef const typename to_exact_<T>::ret ret;
 
-    static inline ret& impl(const T& t)
+    static ret& impl(const T& t)
     {
       return to_exact_<T>::impl(const_cast<T&>(t));
     }
@@ -149,7 +148,7 @@
   {
     typedef typename to_exact_<T>::ret * ret;
 
-    static inline ret impl(T* t)
+    static ret impl(T* t)
     {
       return & to_exact_<T>::impl(*t);
     }
Index: stc/any.hh
--- stc/any.hh	(revision 487)
+++ stc/any.hh	(working copy)
@@ -67,7 +67,7 @@
   struct any <E,
               dispatch_policy::best_speed>
   {
-    typedef E exact_t;
+    typedef E exact_type;
 
     E& exact() {
       precondition(exact_ptr != 0);
@@ -131,7 +131,7 @@
   struct any <E,
 	      dispatch_policy::best_memory>
   {
-    typedef E exact_t;
+    typedef E exact_type;
 
     E& exact() {
 # if defined __GNUC__ && __GNUC__ >= 3
@@ -189,7 +189,7 @@
   struct any <E,
               dispatch_policy::simple>
   {
-    typedef E exact_t;
+    typedef E exact_type;
 
     E& exact() {
       return *(E*)(void*)this;
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from  Thomas Moulard  <thomas.moulard(a)lrde.epita.fr>
	Add stc::exact.
	* static/tests/exact.cc: test suite of stc::exact (new file).
	* static/stc/exact.hh: implementation of stc::exact (new file).
	* static/stc/any.hh: adding a typedef exact_t in stc::any.
	* metalic/mlc/case.hh: fixing a bug in the protected defaults cases.
 metalic/mlc/case.hh   |   30 ++-----
 static/stc/any.hh     |    6 +
 static/stc/exact.hh   |  198 ++++++++++++++++++++++++++++++++++++++++++++++++++
 static/tests/exact.cc |  161 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 373 insertions(+), 22 deletions(-)
Index: static/tests/exact.cc
--- static/tests/exact.cc	(revision 0)
+++ static/tests/exact.cc	(revision 0)
@@ -0,0 +1,161 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 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.
+
+#include <iostream>
+#include <exact.hh> // FIXME: was stc/exact.hh
+
+template <typename E>
+struct abstraction : public stc::any<E>
+{
+};
+
+
+template <typename E>
+struct sub_abstraction : public abstraction<E>
+{
+};
+
+struct itself {};
+
+
+template <typename T = itself>
+struct concrete_ : public sub_abstraction< concrete_<T> >
+{
+  void foo() const
+  {
+    std::cout << "foo() " << std::endl;
+  }
+};
+
+typedef concrete_<> concrete;
+
+
+int main()
+{
+  //-----------------------------------------
+
+  {
+    std::cout << stc::exact(42) << std::endl;
+  }
+
+  {
+    int i = 42;
+    std::cout << stc::exact(i) << std::endl;
+  }
+
+  {
+    const int i = 42;
+    std::cout << stc::exact(i) << std::endl;
+  }
+
+
+  {
+    int i = 42;
+    int * pi = &i;
+    std::cout << pi << " = "
+	      << stc::exact(pi) << std::endl;
+  }
+
+  {
+    int i = 42;
+    int * const pi = &i;
+    std::cout << pi << " = "
+	      << stc::exact(pi) << std::endl;
+  }
+
+  {
+    int i = 42;
+    const int * pi = &i;
+    std::cout << pi << " = "
+	      << stc::exact(pi) << std::endl;
+  }
+
+  {
+    int i = 42;
+    const int * const pi = &i;
+    std::cout << pi << " = "
+	      << stc::exact(pi) << std::endl;
+  }
+
+  // FIXME: Doesn't work!
+  
+//   {
+//     int i = 42;
+//     int * pi = &i;
+//     int ** ppi = π
+//     // stc::exact(ppi);
+
+//     const int ci = 42;
+//     const int * cpi = &ci;
+//     const int ** cppi = &cpi;
+//     stc::exact(cppi);
+//   }
+
+  //-----------------------------------------
+  {
+    concrete t;
+    const concrete::exact_t& tmp = stc::exact(t);
+    std::cout << &t << " = "
+	      << &tmp << std::endl;
+  }
+  {
+    concrete *t = new concrete;
+    std::cout << t << " = "
+	      << stc::exact(t) << std::endl;
+  }
+
+  //-----------------------------------------
+  {
+    concrete t;
+    sub_abstraction<concrete>& st = t;
+    const sub_abstraction<concrete>::exact_t& tmp = stc::exact(st);
+    std::cout << &t << " = "
+	      << &tmp << std::endl;
+    tmp.foo();
+  }
+  {
+    sub_abstraction<concrete> *t = new concrete;
+    std::cout << t << " = "
+	      << stc::exact(t) << std::endl;
+  }
+
+  //-----------------------------------------
+  {
+    concrete t;
+    abstraction<concrete>& a = t;
+    const abstraction<concrete>::exact_t& tmp = stc::exact(a);
+    std::cout << &t << " = "
+	      << &tmp << std::endl;
+  }
+  {
+    abstraction<concrete> *t = new concrete;
+    std::cout << t << " = "
+	      << stc::exact(t) << std::endl;
+  }
+
+}
Property changes on: static/tests/exact.cc
___________________________________________________________________
Name: svn:executable
   + *
Index: static/stc/exact.hh
--- static/stc/exact.hh	(revision 0)
+++ static/stc/exact.hh	(revision 0)
@@ -0,0 +1,198 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 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.
+
+#ifndef STATIC_EXACT_HH
+# define STATIC_EXACT_HH
+
+# include <stc/any.hh>
+
+# include <mlc/is_a.hh>
+# include <mlc/case.hh>
+# include <mlc/bexpr.hh>
+
+
+
+
+# define stc_internal_is_any(T) \
+mlc::bexpr_< sizeof(internal::any_select(internal::makePtr< T >())) == sizeof(internal::yes_) >
+
+
+
+namespace stc
+{
+
+  namespace internal
+  {
+    typedef char yes_;
+    struct no_ { char dummy[2]; };
+
+    template <typename E, typename P>
+    yes_ any_select(const stc::any<E,P>* arg);
+
+    no_  any_select(...);
+
+    template <typename T>
+    T* makePtr();
+
+  }
+
+  template <typename T>
+  struct is_any_
+    : public stc_internal_is_any(T)
+  {
+  };
+
+  template <typename T>
+  struct is_any_ < T* >;
+
+  template <typename T>
+  struct is_any_ < const T >;
+
+} // end of namespace stc
+
+
+mlc_case_equipment_for_namespace(stc);
+
+
+namespace stc
+{
+
+
+  namespace tag
+  {
+    struct exact;
+  }
+
+
+  template <class T>
+  struct case_<tag::exact, T, 1> : public mlc::where_ < stc::is_any_<T> >
+  {
+    struct protected_
+    {
+      typedef typename T::exact_t ret;
+
+      static inline ret& impl(T& t)
+      {
+	return t.exact();
+      }
+    };
+  };
+
+  template <typename T>
+  struct default_case_<tag::exact, T>
+  {
+    struct protected_
+    {
+      typedef T ret;
+
+      static inline ret& impl(T& t)
+      {
+	return t;
+      }
+    };
+
+  };
+
+
+  template <typename T>
+  struct to_exact_
+  {
+    typedef typename switch_<tag::exact, T>::ret ret;
+
+    static inline ret& impl(const T& t)
+    {
+      typedef typename case_<tag::exact, T>::ret case_t;
+      return case_t::impl(const_cast<T&>(t));
+    }
+  };
+
+
+  template <typename T>
+  struct to_exact_ < const T >
+  {
+    typedef const typename to_exact_<T>::ret ret;
+
+    static inline ret& impl(const T& t)
+    {
+      return to_exact_<T>::impl(const_cast<T&>(t));
+    }
+  };
+
+
+  template <typename T>
+  struct to_exact_ < T* >
+  {
+    typedef typename to_exact_<T>::ret * ret;
+
+    static inline ret impl(T* t)
+    {
+      return & to_exact_<T>::impl(*t);
+    }
+  };
+
+
+
+  template <typename T>
+  const typename to_exact_<const T>::ret&
+  exact(const T& t)
+  {
+    return to_exact_<const T>::impl(t);
+  }
+
+  template <typename T>
+  typename to_exact_<T>::ret&
+  exact(T& t)
+  {
+    return to_exact_<T>::impl(t);
+  }
+
+  template <typename T>
+  typename to_exact_<const T*>::ret
+  exact(const T* t)
+  {
+    return to_exact_<const T*>::impl(t);
+  }
+
+  template <typename T>
+  typename to_exact_<T*>::ret
+  exact(T* t)
+  {
+    return to_exact_<T*>::impl(t);
+  }
+
+
+  template <typename T>
+  void exact(const T** t);
+
+  template <typename T>
+  void exact(T** t);
+
+
+} // end of namespace stc
+
+#endif // ! STATIC_EXACT_HH
Property changes on: static/stc/exact.hh
___________________________________________________________________
Name: svn:executable
   + *
Index: static/stc/any.hh
--- static/stc/any.hh	(revision 485)
+++ static/stc/any.hh	(working copy)
@@ -67,6 +67,8 @@
   struct any <E,
               dispatch_policy::best_speed>
   {
+    typedef E exact_t;
+
     E& exact() {
       precondition(exact_ptr != 0);
       return *exact_ptr;
@@ -129,6 +131,8 @@
   struct any <E,
 	      dispatch_policy::best_memory>
   {
+    typedef E exact_t;
+
     E& exact() {
 # if defined __GNUC__ && __GNUC__ >= 3    
       return static_cast<E&>(*this);
@@ -185,6 +189,8 @@
   struct any <E,
               dispatch_policy::simple>
   {
+    typedef E exact_t;
+
     E& exact() {
       return *(E*)(void*)this;
     }
Index: metalic/mlc/case.hh
--- metalic/mlc/case.hh	(revision 485)
+++ metalic/mlc/case.hh	(working copy)
@@ -264,9 +264,15 @@
 																			\
     {																			\
       typedef NAMESPACE::default_case_<context, data> case_t;												\
+      typedef typename protected_in_<case_t>::the protected_case_t;											\
+																			\
+      typedef typename mlc::if_< mlc::is_found_<protected_case_t>,											\
+	                         protected_case_t,													\
+	                         case_t >::ret eff_case_t;												\
+												       							\
       typedef typename mlc::if_<mlc_is_a(case_t, mlc::undefined),											\
 	                        mlc::none,														\
-	                        case_t>::ret ret;													\
+	                        eff_case_t>::ret ret;													\
     };																			\
 																			\
 																			\
@@ -339,27 +345,7 @@
 						 mlc::where_),												\
 					mlc_is_a(mlc_comma_2(NAMESPACE::case_<context, data, i>),							\
 						 mlc::undefined) >,											\
-			      mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >,								\
-																			\
-	private mlc::assert_< mlc::implies_< mlc::and_< mlc::eq_<use, mlc::internal::a_switch_case>,							\
-							mlc::is_defined_< NAMESPACE::case_<context, data, i> > >,					\
-					     mlc::or_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >,					\
-						       typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >,			\
-			      mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_EITHER_A_ret_OR_A_protected >,					\
-																			\
-	private mlc::assert_< mlc::implies_< mlc::and_list_< mlc::eq_<use, mlc::internal::a_switch_case>,						\
-							     mlc::is_defined_< NAMESPACE::case_<context, data, i> >,					\
-							     mlc::or_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >,			\
-								       typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >,	\
-					     mlc::xor_< mlc::ret_found_in_< NAMESPACE::case_<context, data, i> >,					\
-							typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found > >,			\
-			      mlc::ERROR::A_case_STATEMENT_IN_A_switch_SHOULD_NOT_HAVE_BOTH_A_ret_AND_A_protected >,					\
-																			\
-	private mlc::assert_< mlc::implies_< mlc::and_list_< mlc::eq_<use, mlc::internal::a_switch_case>,						\
-							     mlc::is_defined_< NAMESPACE::case_<context, data, i> >,					\
-							     typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found >,			\
-      					     typename protected_in_< NAMESPACE::case_<context, data, i> >::is_found_with_ret >,				\
-			      mlc::ERROR::THE_protected_PART_OF_A_case_STATEMENT_IN_A_switch_SHOULD_HAVE_A_ret >					\
+			      mlc::ERROR::A_case_STATEMENT_SHOULD_DERIVE_FROM_mlc_where_ >					       			\
     {																			\
       typedef mlc_is_a(mlc_comma_2(NAMESPACE::case_<context, data, i+1>),										\
 		       mlc::case_selected) next_case_is_selected;											\
                    
                  
                  
                          
                            
                            2
                            
                          
                          
                            
                            1
                            
                          
                          
                            
    
                          
                        
                    01 Jun '06
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from  Roland Levillain  <roland(a)lrde.epita.fr>
	Have tests/exact.cc be (actually) part of Static's test-suite.
	* stc/exact.hh: Aesthetic change.
	Fix copyright headers.
	* tests/exact.cc: Likewise.
	Fix an inclusion of header.
	* tests/Makefile.am (check_PROGRAMS): Add exact.
	(exact_SOURCES): New.
	* tests/any.cc: Aesthetic change.
 stc/exact.hh      |    6 +++---
 tests/Makefile.am |    2 ++
 tests/any.cc      |    2 +-
 tests/exact.cc    |    5 ++---
 4 files changed, 8 insertions(+), 7 deletions(-)
Index: tests/exact.cc
--- tests/exact.cc	(revision 486)
+++ tests/exact.cc	(working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006  EPITA Research and
-// Development Laboratory.
+// 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
@@ -27,7 +26,7 @@
 // Public License.
 
 #include <iostream>
-#include <exact.hh> // FIXME: was stc/exact.hh
+#include <stc/exact.hh>
 
 template <typename E>
 struct abstraction : public stc::any<E>
Index: tests/Makefile.am
--- tests/Makefile.am	(revision 486)
+++ tests/Makefile.am	(working copy)
@@ -10,10 +10,12 @@
 check_PROGRAMS =				\
   any						\
   entry						\
+  exact						\
   vtypes
 
 any_SOURCES    = any.cc
 entry_SOURCES  = entry.cc
+exact_SOURCES  = exact.cc
 vtypes_SOURCES = vtypes.cc
 
 TESTS = $(check_PROGRAMS)
Index: tests/any.cc
--- tests/any.cc	(revision 486)
+++ tests/any.cc	(working copy)
@@ -28,8 +28,8 @@
 /// Test stc::any.
 
 #include <stc/any.hh>
-#include <mlc/cmp.hh>
 #include <mlc/assert.hh>
+#include <mlc/cmp.hh>
 #include <mlc/logic.hh>
 #include <mlc/is_a.hh>
 
Index: stc/exact.hh
--- stc/exact.hh	(revision 486)
+++ stc/exact.hh	(working copy)
@@ -1,5 +1,4 @@
-// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006  EPITA Research and
-// Development Laboratory.
+// 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
@@ -39,7 +38,8 @@
 
 
 # define stc_internal_is_any(T) \
-mlc::bexpr_< sizeof(internal::any_select(internal::makePtr< T >())) == sizeof(internal::yes_) >
+  mlc::bexpr_< sizeof(internal::any_select(internal::makePtr< T >())) == \
+    sizeof(internal::yes_) >
 
 
 
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    15 May '06
                    
                        
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from  Nicolas Widynski  <nicolas.widynski(a)lrde.epita.fr>
	Fix bugs and update snakes for multi segmentation.
	* oln/appli/snakes/snakes.cc: Fix bugs.
	* oln/appli/snakes/snakes.hh: Update snakes for multi segmentation.
 snakes.cc |  289 +++++++++++++++++++++++++++++++++++++++++++++-----------------
 snakes.hh |   75 +++++++++++-----
 2 files changed, 269 insertions(+), 95 deletions(-)
Index: oln/appli/snakes/snakes.cc
--- oln/appli/snakes/snakes.cc	(revision 484)
+++ oln/appli/snakes/snakes.cc	(working copy)
@@ -24,12 +24,8 @@
     mask[*it] = true;
 
   for_all(p)
-    {
       if (mask[p] == true)
 	out[p] = 255;
-      else
-	out[p] = input[p];
-    }
 }
 
 template <typename T>
@@ -52,17 +48,30 @@
       for (; it2 != vec.end(); it2++)
 	mask[*it2] = true;
     }
-
   for_all(p)
-    {
       if (mask[p] == true)
 	out[p] = 255;
-      else
-	out[p] = input[p];
-    }
 }
 
 
+template <typename T>
+void my_copy(const oln::image2d<T>& input,
+	     oln::image2d<T>& out)
+{
+  oln_iter_type(oln::image2d<T>) p(input);
+  for_all(p)
+    out[p] = input[p];
+}
+
+template <typename T>
+bool is_element_vec(const std::vector<T>& v, const T& elt)
+{
+  typename std::vector<T>::const_iterator it = v.begin();
+  for (; it != v.end(); it++)
+    if (*it == elt)
+      return true;
+  return false;
+}
 
 bool nearly_equal(int x1, int x2, int y1, int y2)
 {
@@ -70,78 +79,130 @@
 }
 
 template <typename T>
-std::vector<oln::point2d> tri_vec(const oln::image2d<T>& ima,
+int chemin(const std::vector<oln::point2d>& v,
+	   const oln::image2d<T>& ima,
+	   std::vector<oln::point2d>& seen,
+	   //	   const oln::point2d& pred,
+	   const oln::point2d& p,
+	   oln::point2d& f,
+	   oln::point2d& tmp,
+	   int& max,
+	   bool& stop)
+{
+  oln_neighb_type(oln::window2d) q(oln::win_c8p(), p);
+  bool end = true;
+  seen.push_back(p);
+  for_all (q)
+    {
+      if (is_element_vec(seen, (oln::point2d)(q)) == 0 and
+	  is_element_vec(v, (oln::point2d)(q)))
+	    {
+	      int res = 1 + chemin(v, ima, seen, q, f, tmp, max, stop);
+	      if (res > max)
+		{
+		  max = res;
+		  f = tmp;
+		}
+	      end = false;
+	    }
+    }
+  if (end)
+    {
+      tmp = p;
+      return 1;
+    }
+  return 0;
+}
+
+
+std::vector<oln::point2d> verify_snaxels(const std::vector<oln::point2d>& v_init,
 				  const std::vector<oln::point2d>& v)
 {
   std::vector<oln::point2d> res;
+
+  if (v_init.size() - v.size() > 5)
+    {
   std::vector<oln::point2d>::const_iterator it;
-  std::vector<oln::point2d>::iterator it2;
+      for (it = v_init.begin(); it != v_init.end(); it++)
+	if (is_element_vec(v, *it) == 0)
+	  res.push_back(*it);
+    }
+  return res;
+}
 
-  int ex_1_x = -100;
-  int ex_1_y = -100;
-  int ex_2_x = 0;
-  int ex_2_y = 0;
-  int save_x = -1;
-  int save_y = -1;
 
 
-  for (int i = 0; i < 2; i++)
+template <typename T>
+std::vector<oln::point2d> tri_vec(const oln::image2d<T>& ima,
+				  const std::vector<oln::point2d>& v,
+				  snake_type type) // OUVERT || FERME
     {
-      double min = 100000000;
+  std::vector<oln::point2d> res;
+  std::vector<oln::point2d>::const_iterator it;
+  std::vector<oln::point2d>::iterator it2;
+  oln::point2d dep;
+  oln::point2d tmp2;
+  oln::point2d arr;
+
+  bool stop = false;
+  oln::point2d beg(-1,-1);
 
       for (it = v.begin(); it != v.end(); it++)
 	{
-	  if (i and nearly_equal((*it).row(), ex_1_x, (*it).col(), ex_1_y))
-	    continue;
-
-	  double tmp1 = oln::snakes::impl::euclidian_distance((*it).row(), 0, 0, 0);
-	  double tmp2 = oln::snakes::impl::euclidian_distance((*it).row(), ima.nrows(), 0, 0);
-	  double tmp3 = oln::snakes::impl::euclidian_distance(0, 0, (*it).col(), 0);
-	  double tmp4 = oln::snakes::impl::euclidian_distance(0, 0, (*it).col(), ima.ncols());
-
-	  double tmp_min;
-
-	  if (tmp1 <= tmp2 and tmp1 <= tmp3 and tmp1 <= tmp4)
-	    tmp_min = tmp1;
-	  if (tmp2 <= tmp1 and tmp2 <= tmp3 and tmp2 <= tmp4)
-	    tmp_min = tmp2;
-	  if (tmp3 <= tmp1 and tmp3 <= tmp2 and tmp3 <= tmp4)
-	    tmp_min = tmp3;
-	  if (tmp4 <= tmp1 and tmp4 <= tmp2 and tmp4 <= tmp3)
-	    tmp_min = tmp4;
-
-	  if (tmp_min < min)
-	    {
-	      min = tmp_min;
-	      save_x = (*it).row();
-	      save_y = (*it).col();
+      unsigned nb_nbh = 0;
+      oln_neighb_type(oln::window2d) q(oln::win_c8p(), *it);
+      for_all (q)
+	if ((oln::point2d)(q) != *it and ima.hold(q) and is_element_vec(v, (oln::point2d)(q)))
+	  ++nb_nbh;
+      if (nb_nbh == 2)
+	{
+	  beg = *it;
+	  break;
 	    }
 	}
-      if (not i)
+  if (beg.row() == -1)
+    beg = *(v.begin() + v.size() / 2);
+
+  dep = beg;
+  arr = beg;
+  std::vector<oln::point2d> seen;
+
+  int i = 0;
+  oln_neighb_type(oln::window2d) q(oln::win_c8p(), beg);
+  for_all (q)
 	{
-	  ex_1_x = save_x;
-	  ex_1_y = save_y;
-	}
-      else
+      if ((oln::point2d)(q) != beg and ima.hold(q) and is_element_vec(v, (oln::point2d)(q)))
 	{
-	  ex_2_x = save_x;
-	  ex_2_y = save_y;
+	  bool s = false;
+	  int max = 0;
+
+	  seen.push_back(beg);
+	  if (not i)
+	    chemin(v, ima, seen, (oln::point2d)(q), dep, tmp2, max, s);
+	  else
+	    chemin(v, ima, seen, (oln::point2d)(q), arr, tmp2, max, s);
+
+	  seen.clear();
+	  i++;
 	}
     }
-
-  res.push_back(oln::point2d(ex_1_x, ex_1_y));
+  res.push_back(dep);
 
   std::vector<oln::point2d> tmp;
   for (it = v.begin(); it != v.end(); it++)
-    if (((*it).row() != ex_1_x or (*it).col() != ex_1_y) and
-	((*it).row() != ex_2_x or (*it).col() != ex_2_y))
+    if (*it != dep)
+      if (type == OUVERT)
+	{
+	  if (*it != arr)
+	    tmp.push_back(*it);
+	}
+      else
       tmp.push_back(*it);
 
 
-  bool stop = false;
-
-  int tmp_x = ex_1_x;
-  int tmp_y = ex_1_y;
+  stop = false;
+  int tmp_x = dep.row();
+  int tmp_y = dep.col();
 
   while (stop == false)
     {
@@ -160,23 +221,83 @@
 		  p_ref = it2;
 		}
 	    }
+ 	  if (min <= 10)
 	  res.push_back(p);
 	  tmp.erase(p_ref);
+ 	  if (min <= 10)
+	    {
 	  tmp_x = p.row();
 	  tmp_y = p.col();
 	}
-      else
-	{
-	  res.push_back(oln::point2d(tmp.front().row(), tmp.front().col()));
+	  if (tmp.size() == 1)
 	  stop = true;
 	}
     }
 
-  res.push_back(oln::point2d(ex_2_x, ex_2_y));
+  if (type == OUVERT or is_element_vec(res, arr) == 0)
+    res.push_back(arr);
+  return res;
+}
+
+
+std::vector<std::vector<oln::point2d> > filter_size(std::vector<std::vector<oln::point2d> >& v)
+{
+  std::vector<std::vector<oln::point2d> > res;
+
+  for (int i = 0; i < v.size(); i++)
+    if (v[i].size() > 4)
+      res.push_back(v[i]);
+
   return res;
 }
 
 
+void decoup_set(std::vector<std::vector<oln::point2d> >& v)
+{
+  std::vector<oln::point2d>::iterator it;
+  std::vector<oln::point2d>::iterator it2;
+  bool stop = false;
+
+  for (int i = 0; stop == false and i < v.size(); i++)
+    for (int j = i + 1; stop == false and j < v.size(); j++)
+      for (it = v[i].begin(); stop == false and it != v[i].end(); it++)
+	for (it2 = v[j].begin(); stop == false and it2 != v[j].end(); it2++)
+	  if (nearly_equal((*it).row(), (*it2).row(), (*it).col(), (*it2).col()))
+	    {
+	      std::vector<oln::point2d> n1;
+	      std::vector<oln::point2d> n2;
+
+	      std::vector<oln::point2d>::iterator it3;
+	      std::vector<oln::point2d>::iterator it4;
+
+	      if (it + 1 != v[i].end() and it + 2 != v[i].end() and it + 3 != v[i].end() and
+		  it != v[i].begin() and it + 1 != v[i].begin() and it + 2 != v[i].begin())
+		{
+		  for (it3 = it + 1; it3 != v[i].end(); it3++)
+		    n1.push_back(*it3);
+		  v[i].erase(it + 1, v[i].end() - 1);
+		}
+
+	      if (it2 + 1 != v[j].end() and it2 + 2 != v[j].end() and it2 + 3 != v[j].end() and
+		  it2 != v[j].begin() and it2 + 1 != v[j].begin() and it2 + 2 != v[j].begin())
+		{
+		  for (it4 = it2 + 1; it4 != v[j].end(); it4++)
+		    n2.push_back(*it4);
+		  v[j].erase(it2 + 1, v[j].end() - 1);
+		}
+	      if (n1.size())
+		v.push_back(n1);
+	      if (n2.size())
+		v.push_back(n2);
+	      if (n2.size() or n1.size())
+		decoup_set(v);
+	      stop = true;
+	    }
+
+}
+
+
+
 int main(int argc, char **argv)
 {
   using namespace oln;
@@ -187,18 +308,33 @@
       exit(1);
     }
 
-  std::vector<oln::point2d> v;
+  std::vector<std::vector<oln::point2d> > v;
   unsigned max_pts = (unsigned)atoi(argv[7]);
 
   oln::image2d<ntg::bin> mask = load(argv[8]);
   oln::image2d<int_u8> input1 = load(argv[9]);
 
   v = morpho::watersnakes(input1, mask, win_c8p(), 5);
+  v = filter_size(v);
+  //  decoup_set(v);
 
-  v = tri_vec(input1, v);
-
-  if (max_pts)
-    v = oln::snakes::impl::redispatch(v, max_pts);
+  for (int cpt = 0; cpt < v.size(); cpt++)
+    {
+      std::vector<oln::point2d> v_new = tri_vec(input1, v[cpt], (snake_type)atoi(argv[6]));
+      std::vector<oln::point2d> v_verif = verify_snaxels(v[cpt], v_new);
+      v[cpt] = v_new;
+      if (v_verif.size() > 0)
+	v.push_back(v_verif);
+      if (v[cpt].size() > max_pts)
+	v[cpt] = oln::snakes::impl::redispatch(v[cpt], max_pts);
+    }
+
+  std::vector<unsigned> v_max_pts;
+  for (int cpt = 0; cpt < v.size(); cpt++)
+    if ((unsigned)((float)(v[cpt].size()) * 0.6) > max_pts)
+      v_max_pts.push_back(max_pts);
+    else
+      v_max_pts.push_back((unsigned)((float)(v[cpt].size()) * 0.6));
 
   for (int i = 9; i < argc; i++)
     {
@@ -209,16 +345,19 @@
       oln::image2d<int_u8> out(input.size());
       unsigned nb_gen = 0;
 
-      if (i == 9)
-	nb_gen = (unsigned)atoi(argv[3]);
-      else
-	nb_gen = 1;
-
-      v = oln::snakes::snakes(input, v, (force_type)(atoi(argv[1])), (unsigned)atoi(argv[2]), nb_gen, max_pts, atof(argv[4]), (unsigned)atoi(argv[5]), (snake_type)atoi(argv[6]));
+      my_copy(input, out);
 
-      aff_droites(input, v, out);
-      //      aff_points(input, v, out);
+      nb_gen = (unsigned)atoi(argv[3]);
 
+      for (int cpt = 0; cpt < v.size(); cpt++)
+	{
+	  if (v[cpt].size() > v_max_pts[cpt])
+	    v[cpt] = oln::snakes::impl::redispatch(v[cpt], v_max_pts[cpt]);
+	  else
+	    v[cpt] = oln::snakes::impl::redispatch_normal(v[cpt], v[cpt].size());
+	  v[cpt] = oln::snakes::snakes(input, v[cpt], (force_type)(atoi(argv[1])), (unsigned)atoi(argv[2]), nb_gen, v_max_pts[cpt], atof(argv[4]), (unsigned)atoi(argv[5]), (snake_type)atoi(argv[6]));
+	  aff_droites(input, v[cpt], out);
+	}
       char t[30];
       sprintf(t, "snakes_%d.pgm", i - 8);
 
Index: oln/appli/snakes/snakes.hh
--- oln/appli/snakes/snakes.hh	(revision 484)
+++ oln/appli/snakes/snakes.hh	(working copy)
@@ -40,7 +40,6 @@
 typedef enum FORCE_TYPE { GRADIENT = 0, VARIANCE = 1 } force_type;
 const float PI = 3.14159265;
 
-
 namespace oln {
 
   namespace snakes {
@@ -80,22 +79,17 @@
 	  y2 = force.ncols() - 1;
       }
 
-
       std::vector<point2d> draw_line_(const point2d& p,
 				      const point2d& q)
       {
 	std::vector<point2d> res;
-
 	point2d p_cur = p;
+
 	if (q.col() == p.col()) // cas vertical
 	  {
 	    int sens = q.row() > p.row() ? 1 : -1;
 	    while (p_cur != q)
 	      {
-		double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
-		double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
-		double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
-
 		res.push_back(p_cur);
 		p_cur.row() = p_cur.row() + sens;
 	      }
@@ -107,10 +101,6 @@
 		int sens = q.col() > p.col() ? 1 : -1;
 		while (p_cur != q)
 		  {
-		    double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
-		    double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
-		    double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
-
 		    res.push_back(p_cur);
 		    p_cur.col() = p_cur.col() + sens;
 		  }
@@ -132,10 +122,6 @@
 
 		while (p_cur != q)
 		  {
-		    double pc_p = euclidian_distance(p_cur.row(), p.row(), p_cur.col(), p.col());
-		    double pc_q = euclidian_distance(p_cur.row(), q.row(), p_cur.col(), q.col());
-		    double p_q = euclidian_distance(p.row(), q.row(), p.col(), q.col());
-
 		    res.push_back(p_cur);
 
 		    if (abs(decalage) >= abs(denom))
@@ -154,8 +140,6 @@
 	return res;
       }
 
-
-
       template <typename T>
       std::vector<point2d> compute_normal_points_(const image2d<T>& force,
 						  const point2d& p1,
@@ -163,9 +147,12 @@
 						  const point2d& p3,
 						  unsigned int dmax)
       {
+	point2d pp1(p1.row(), p1.col());
+	point2d pp3(p3.row(), p3.col());
+
 	float x_c = p2.row();
 	float y_c = p2.col();
-	float a_p1_p3 = (p1.col() - p3.col()) != 0 ? (float)(((float)(p1.row() - p3.row())) / (p1.col() - p3.col())) : 0;
+	float a_p1_p3 = (pp1.col() - pp3.col()) != 0 ? (float)(((float)(pp1.row() - pp3.row())) / (pp1.col() - pp3.col())) : 0;
 	float a = -a_p1_p3;
 	float b = p2.col() - a * p2.row(); // use of - slope of p1 et p3
 
@@ -203,11 +190,21 @@
 	  }
 	else
 	  {
+	    if (pp3.row() == pp1.row())
+	      {
 	    x1 = p2.row() - dmax;
 	    y1 = p2.col();
 	    x2 = p2.row() + dmax;
 	    y2 = p2.col();
 	  }
+	    else
+	      {
+		x1 = p2.row();
+		y1 = p2.col() - dmax;
+		x2 = p2.row();
+		y2 = p2.col() + dmax;
+	      }
+	  }
 
 	verify_integrity_(force, x1, x2, y1, y2);
 
@@ -226,6 +223,7 @@
 	return sqr(180 - angle) / sqr(180);
       }
 
+
       template <typename T>
       double variance(const image2d<T>& input,
 		      const point2d& p,
@@ -255,6 +253,7 @@
 	return res / sqr(fen);
       }
 
+
       template <typename T>
       std::vector<point2d> gen_snakes_(const image2d<T>& force,
 				       const std::vector<point2d>& v,
@@ -267,6 +266,9 @@
 	std::vector<point2d>::const_iterator it = v.begin();
 	std::vector<point2d> res;
 
+	if (type == OUVERT)
+	  res.push_back(*(v.begin()));
+
 	for (; it != v.end(); it++)
 	  {
 	    point2d p1 = *it;
@@ -322,7 +324,6 @@
 	  }
 	else
 	  res.push_back(*(v.end() - 1));
-
 	return res;
       }
 
@@ -376,9 +377,16 @@
 	int nb_pts = v.size() * 2;
 	int cpt = 0;
 
+	if (tmp.size() > nb_pts)
+	  {
 	for (it2 = tmp.begin(); it2 != tmp.end(); it2++, cpt++)
 	  if ((cpt % (tmp.size() / nb_pts)) == 0)
 	    res.push_back(*it2);
+	  }
+	else
+	  for (it2 = tmp.begin(); it2 != tmp.end(); it2++, cpt++)
+	    res.push_back(*it2);
+
 
 	if (type == FERME)
 	  {
@@ -391,7 +399,6 @@
 	return res;
       }
 
-
       std::vector<point2d> redispatch(const std::vector<point2d>& v,
 				      int nb_snaxels)
       {
@@ -418,6 +425,33 @@
       }
 
 
+      std::vector<point2d> redispatch_normal(const std::vector<point2d>& v,
+					     int nb_snaxels)
+      {
+	std::vector<point2d> res;
+	std::vector<point2d> tmp;
+	std::vector<point2d>::const_iterator it = v.begin();
+	int cpt = 0;
+
+	for (; it + 1 != v.end(); it++)
+	  {
+	    std::vector<point2d> vec = draw_line_(*it, *(it+1));
+	    std::vector<point2d>::const_iterator it2 = vec.begin();
+
+	    for (; it2 != vec.end(); it2++)
+	      tmp.push_back(*it2);
+	  }
+
+	for (it = tmp.begin(); it != tmp.end(); it++, cpt++)
+	  if ((cpt % (int)(roundf(((float)(tmp.size()) / nb_snaxels)))) == 0)
+	    res.push_back(*it);
+
+	res.push_back(*(v.end() - 1));
+	return res;
+      }
+
+
+
       template <typename T>
       void clean_ima(image2d<T>& ima)
       {
@@ -475,6 +509,7 @@
 	while (i < nb_gen)
 	  {
 	    res = gen_snakes_(force, res, f, fen, lambda, dmax, type);
+	    if (res.size() > max_pts)
 	    res = redispatch(res, max_pts);
 	    i++;
 	    if (i < nb_gen)
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        
https://svn/svn/oln/prototypes/proto-1.0/olena
Index: ChangeLog
from  Nicolas Widynski  <nicolas.widynski(a)lrde.epita.fr>
	Update Watersnake for multi segmentation.
	* oln/morpho/watersnakes.hh: Update for multi segmentation.
 watersnakes.hh |   44 +++++++++++++++++++++++++++-----------------
 1 file changed, 27 insertions(+), 17 deletions(-)
Index: oln/morpho/watersnakes.hh
--- oln/morpho/watersnakes.hh	(revision 483)
+++ oln/morpho/watersnakes.hh	(working copy)
@@ -29,6 +29,7 @@
 # define OLENA_MORPHO_WATERSNAKES_HH
 
 # include <string>
+# include <map>
 
 # include <oln/basics.hh>
 # include <oln/morpho/erosion.hh>
@@ -409,7 +410,7 @@
       }
 
       template<typename T, typename T2>
-      std::vector<point2d>
+      std::vector<std::vector<point2d> >
       watershed_line(const image2d<T>& input,
 		     const image2d<T>& orig,
 		     const image2d<T2>& marqueur,
@@ -417,12 +418,14 @@
 		     int b,
 		     version v)
       {
-	image2d<int> final(input.size());
 	image2d<int> label;
 	image2d<T2> mark(input.size());
 	oln_iter_type(image2d<T>) p(input);
 	image2d<bool> is_wshed_line(input.size());
-	std::vector<point2d> res;
+	std::vector<point2d> tmp;
+	std::vector<std::vector<point2d> > res;
+	std::map<std::pair<int, int>, int> num_wshed;
+	int cpt = 0;
 	unsigned nb_compo = 0;
 
 	for_all(p)
@@ -432,7 +435,6 @@
 	  propagate_minima_(input, mark, ng, p);
 
 	image2d<T> recon;
-
 	if (v == NORMAL)
 	  recon = reconstruction_by_erosion(input, mark);
 	else
@@ -441,10 +443,9 @@
 	    op_type op(marqueur, input, ng);
 	    recon = op.output;
 	  }
-	image2d<float> LS = lower_slope(recon, ng);
 
+	image2d<float> LS = lower_slope(recon, ng);
 	label = init_watershed_(recon, mark, ng, nb_compo);
-
 	image2d<float*> topo = topographic_distance(recon, LS, mark, label, ng, nb_compo);
 
 	for_all(p)
@@ -463,21 +464,30 @@
 	while (snake_iteration(label, topo, b))
 	  ;
 
-	level::fill(final, 0);
 	for_all(p)
 	  {
 	    oln_neighb_type(window2d) q(win_c4p(), p);
 	    for_all (q)
 	      if (input.hold(q))
-		if (label[p] != label[q] and final[q] != WSHED)
-		  final[p] = WSHED;
-	    if (final[p] == 0)
-	      final[p] = orig[p];
+		if (label[p] != label[q])
+		  {
+		    int p1 = std::min(label[p], label[q]);
+		    int p2 = std::max(label[p], label[q]);
+		    if (num_wshed.find(std::pair<int, int>(p1, p2)) == num_wshed.end())
+		      {
+			num_wshed[std::pair<int, int>(p1, p2)] = cpt++;
+			std::vector<point2d> tmp;
+			tmp.push_back(p);
+			res.push_back(tmp);
+		      }
+		    else
+		      {
+			if (res[(*(num_wshed.find(std::pair<int, int>(p1, p2)))).second].back() != p)
+			  if (label[p] == p1)
+			    res[(*(num_wshed.find(std::pair<int, int>(p1, p2)))).second].push_back(p);
+		      }
+		  }
 	  }
-
-	for_all(p)
-	  if (final[p] == WSHED)
-	    res.push_back(p);
 
 	return res;
       }
@@ -485,7 +495,7 @@
 
 
       template<typename T, typename T2>
-      std::vector<point2d>
+      std::vector<std::vector<point2d> >
       watersnakes_(const image2d<T>& input,
 		   const image2d<T2>& marqueur,
 		   const window2d& ng,
@@ -503,7 +513,7 @@
 
 
     template<typename T, typename T2>
-    std::vector<point2d>
+    std::vector<std::vector<point2d> >
     watersnakes(const image2d<T>& input,
 		const image2d<T2>& marqueur,
 		const window2d& ng,
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from  Quentin Hocquet  <quentin.hocquet(a)lrde.epita.fr>
	Fix previous patch
	* Fix error in svn external link to transformers
	* tools: .
	* tools/tests/good/funcall_no-args.scl, tools/tests/good/funcall.scl: 
fix typo
  funcall.scl         |    2 +-
  funcall_no-args.scl |    2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Index: tools/tests/good/funcall_no-args.scl
--- tools/tests/good/funcall_no-args.scl	(revision 482)
+++ tools/tests/good/funcall_no-args.scl	(working copy)
@@ -1,4 +1,4 @@
  doit : () -> int =
  {
-  -> chiche();
+  -> foo();
  }
\ No newline at end of file
Index: tools/tests/good/funcall.scl
--- tools/tests/good/funcall.scl	(revision 482)
+++ tools/tests/good/funcall.scl	(working copy)
@@ -1,4 +1,4 @@
  doit : () -> int =
  {
-  -> chiche("pelle", "branle");
+  -> foo("bar", "baz");
  }
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                        
                            
                                
                            
                            481: Fix a duplicate where-clause and perform some	aesthetic changes in image abstractions.
                        
                        
by Roland Levillain 02 May '06
                    by Roland Levillain 02 May '06
02 May '06
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/olena
Index: ChangeLog
from  Roland Levillain  <roland(a)lrde.epita.fr>
	Fix a duplicate where-clause and perform some aesthetic changes in
	image abstractions.
	* oln/core/abstract/image_dimension.hh: Move the static switch
	statement before the cases.
	Aesthetic changes.
	* olena/oln/core/abstract/image_typeness.hh: Likewise.
	(case_<value_type_tag, value_type, 2>): Fix a copy-and-paste bug:
	remove a duplicate `unsigned char' type in the where-clause and
	replace it with `signed char'.
	* oln/core/abstract/image_typeness_integre.hh,
	* tests/image_entry.cc: Aesthetic changes.
 oln/core/abstract/image_dimension.hh        |   58 +++++++++++++++++++---------
 oln/core/abstract/image_typeness.hh         |   58 ++++++++++++++++++----------
 oln/core/abstract/image_typeness_integre.hh |    7 +--
 tests/image_entry.cc                        |    4 -
 4 files changed, 84 insertions(+), 43 deletions(-)
Index: tests/image_entry.cc
--- tests/image_entry.cc	(revision 480)
+++ tests/image_entry.cc	(working copy)
@@ -28,7 +28,7 @@
 /// Test oln::abstract::image_entry.
 
 // FIXME: Check also with a (possibly fake) ntg::int_u<1, B> type, to
-// stress image_typeness.hh.  This should be done in another test, of
+// stress image_typeness.hh.  This might be done in another test, of
 // course.
 
 #include <oln/core/1d/grid1d.hh>
@@ -64,7 +64,7 @@
 
 namespace my
 {
-  // A very simple 1D image.
+  // A very simple 1-D image.
   class image : public oln::set_super_type<my::image>::ret
   {
     typedef image self_type;
Index: oln/core/abstract/image_dimension.hh
--- oln/core/abstract/image_dimension.hh	(revision 480)
+++ oln/core/abstract/image_dimension.hh	(working copy)
@@ -65,13 +65,17 @@
 
 */
 
+/*-------------------------.
+| Dimension abstractions.  |
+`-------------------------*/
+
 namespace oln
 {
  
   namespace abstract
   {
 
-    /// Class of 1D images.
+    /// Class of 1-D images.
     template <typename E>
     struct image1d : public virtual image<E>
     {
@@ -80,7 +84,7 @@
       image1d() {}
     };
 
-    /// Class of 2D images.
+    /// Class of 2-D images.
     template <typename E>
     struct image2d : public virtual image<E>
     {
@@ -89,7 +93,7 @@
       image2d() {}
     };
  
-    /// Class of 3d images.
+    /// Class of 3-D images.
     template <typename E>
     struct image3d : public virtual image<E>
     {
@@ -100,21 +104,45 @@
  
   } // end of namespace oln::abstract
 
+} // end of namespace oln
+
 
   /*-------------------.
   | Dimension switch.  |
   `-------------------*/
 
+namespace oln
+{
+  /// Case tag for the dimension.
+  struct grid_dim_tag; 
+}
+
+
+// Register the dimension switch for oln::abstract::image_entry.
+namespace stc
+{
+  template <typename I>
+  struct set_entry_node<I, oln::abstract::dimension_tag> :
+    public oln::switch_< oln::grid_dim_tag, oln_type_of(I, grid) >::ret
+      ::template instantiated_with<I>::ret
+  {
+  };
+} // end of namespace stc
+
+
+namespace oln
+{
+
   // Forward declarations.
   class grid1d;
   class grid2d;
   class grid3d;
   
-  /// Case tag for the dimension.
-  struct grid_dim_tag;
   
   /// Switch on on the grid dimension.
   /// \{
+
+  /// 1-D case.
   template <typename grid_type>
   struct case_<grid_dim_tag, grid_type, 1> :
     // Test.
@@ -124,6 +152,7 @@
     typedef stc::abstraction_as_type<abstract::image1d> ret;
   };
 
+  /// 2-D case.
   template <typename grid_type>
   struct case_<grid_dim_tag, grid_type, 2> :
     // Test.
@@ -133,6 +162,7 @@
     typedef stc::abstraction_as_type<abstract::image2d> ret;
   };
 
+  /// 3-D case.
   template <typename grid_type>
   struct case_<grid_dim_tag, grid_type, 3> :
     // Test.
@@ -142,7 +172,7 @@
     typedef stc::abstraction_as_type<abstract::image3d> ret;
   };
 
-  /// Abort when grid_type is not handled by the previous cases.
+  /// Default case: abort when grid_type is not handled by the previous cases.
   template <typename grid_type>
   struct default_case_<grid_dim_tag, grid_type>
   {
@@ -153,19 +183,11 @@
 } // end of namespace oln
 
 
-// Register the dimension switch for oln::abstract::image_entry.
-namespace stc
-{
-  template <typename I>
-  struct set_entry_node<I, oln::abstract::dimension_tag> :
-    public oln::switch_< oln::grid_dim_tag, oln_type_of(I, grid) >::ret
-      ::template instantiated_with<I>::ret
-  {
-  };
-} // end of namespace stc
-
+/*----------------------------------.
+| Dimension external virtual type.  |
+`----------------------------------*/
 
-// FIXME: Is this external property really useful?
+// FIXME: Is this external vtype really useful?
 namespace oln
 {
   /// Image dimension type as an external vtype of abstract::image.
Index: oln/core/abstract/image_typeness_integre.hh
--- oln/core/abstract/image_typeness_integre.hh	(revision 480)
+++ oln/core/abstract/image_typeness_integre.hh	(working copy)
@@ -77,11 +77,12 @@
 } // end of namespace ntg
 
 
+/*--------------------------.
+| Typeness switch (cont.).  |
+`--------------------------*/
+
 namespace oln {
 
-  /*--------------------.
-  | Value type switch.  |
-  `--------------------*/
   
   /// Switch on on the value type.
   /// \{
Index: oln/core/abstract/image_typeness.hh
--- oln/core/abstract/image_typeness.hh	(revision 480)
+++ oln/core/abstract/image_typeness.hh	(working copy)
@@ -68,7 +68,12 @@
 
 */
 
-namespace oln {
+/*------------------------.
+| Typeness abstractions.  |
+`------------------------*/
+
+namespace oln
+{
 
   namespace abstract
   {
@@ -142,9 +147,9 @@
     };
 
 
-    /*---------------------.
-    | Conjunctions types.  |
-    `---------------------*/
+    // -------------------- //
+    // Conjunctions types.  //
+    // -------------------- //
 
     namespace internal
     {
@@ -204,13 +209,34 @@
 
   } // end of namespace oln::abstract
 
+} // end of namespace oln
+
 
-  /*--------------------.
-  | Value type switch.  |
-  `--------------------*/
+/*------------------.
+| Typeness switch.  |
+`------------------*/
 
+namespace oln
+{
   /// Case tag for the dimension.
   struct value_type_tag;
+}
+
+
+// Register the dimension switch/case for oln::abstract::image_entry.
+namespace stc
+{
+  template <typename I>
+  struct set_entry_node<I, oln::abstract::typeness_tag> :
+    public oln::case_< oln::value_type_tag, oln_type_of(I, value) >::ret
+      ::super_type::template instantiated_with<I>::ret
+  {
+  };
+} // end of namespace stc
+
+
+namespace oln
+{
   
   /// Switch on on the grid dimension.
   /// \{
@@ -236,7 +262,7 @@
   struct case_<value_type_tag, value_type, 2> :
     public mlc::where_<
              mlc::or_list_< mlc_eq(value_type, char),
-			    mlc_eq(value_type, unsigned char),
+			    mlc_eq(value_type,   signed char),
 			    mlc_eq(value_type, unsigned char) > >
   {
     // Definition of the super class corresponding to this case
@@ -273,19 +299,11 @@
 } // end of namespace oln
 
 
-// Register the dimension switch/case for oln::abstract::image_entry.
-namespace stc
-{
-  template <typename I>
-  struct set_entry_node<I, oln::abstract::typeness_tag> :
-    public oln::case_< oln::value_type_tag, oln_type_of(I, value) >::ret
-      ::super_type::template instantiated_with<I>::ret
-  {
-  };
-} // end of namespace stc
-
+/*---------------------------------.
+| Typeness external virtual type.  |
+`---------------------------------*/
 
-// FIXME: Is this external property really useful?
+// FIXME: Is this external vtype really useful?
 namespace oln
 {
   /// Image ``typeness'' as an external vtype of abstract::image.
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/olena
I don't know where to put oln/core/abstract/image_typeness_integre.hh;
it adds cases to the typeness hierarchy in, Olena but it depends on
Integre.  Maybe we could have a third-party place for this kind of
``glue'' between two subprojects of Olena.
Another (straightforward) solution is to enclose this file within
#if HAVE_NTG / #endif directives.
Index: ChangeLog
from  Roland Levillain  <roland(a)lrde.epita.fr>
	Add image ``typeness'' abstraction hierarchy.
	* tests/image_entry.cc (my): Check image_typeness_type vtype and
	inheritance.
	* oln/core/typedefs.hh (value_type, image_typeness_type): Enable
	typedef.
	* oln/core/abstract/image.hh (vtypes::value_type): Enable typedef.
	(packed_vtypes::value_type): New typedef.
	(packed_vtypes::echo): Print value_type and image_typeness_type.
	(packed_vtypes::ensure): Check value_type and image_typeness_type.
	(image::value_type): Enable typedef.
	* oln/core/abstract/image_entry.hh: Include images abstractions
	headers.
	Don't include mlc/case.hh nor oln/core/abstract/image.hh.
	(mlc_case_equipment_for_namespace(oln))
	(abstraction_tags): Move...
	* oln/core/abstract/image_abstractions.hh: ...here (new file).
	* oln/core/abstract/image_dimension.hh: Include it.
	Include stc/entry.hh.
	Aesthetic changes.
	* oln/core/abstract/image_typeness.hh: New file (imported from
	Olena proto-1.0, and modified).
	* oln/core/abstract/image_typeness_integre.hh: New file
	* oln/Makefile.am (nobase_oln_HEADERS): Add
	core/abstract/image_abstractions.hh,
	core/abstract/image_typeness.hh and
	core/abstract/image_typeness_integre.hh.
 oln/Makefile.am                             |    3 
 oln/core/abstract/image.hh                  |   39 ++
 oln/core/abstract/image_abstractions.hh     |   61 ++++
 oln/core/abstract/image_dimension.hh        |   50 +--
 oln/core/abstract/image_entry.hh            |   21 -
 oln/core/abstract/image_typeness.hh         |  410 ++++++++++++++--------------
 oln/core/abstract/image_typeness_integre.hh |  161 ++++++++++
 oln/core/typedefs.hh                        |    8 
 tests/image_entry.cc                        |   33 +-
 9 files changed, 521 insertions(+), 265 deletions(-)
Index: tests/image_entry.cc
--- tests/image_entry.cc	(revision 479)
+++ tests/image_entry.cc	(working copy)
@@ -27,9 +27,13 @@
 
 /// Test oln::abstract::image_entry.
 
+// FIXME: Check also with a (possibly fake) ntg::int_u<1, B> type, to
+// stress image_typeness.hh.  This should be done in another test, of
+// course.
+
 #include <oln/core/1d/grid1d.hh>
 #include <oln/core/abstract/image_entry.hh>
-#include <oln/core/abstract/image_dimension.hh>
+
 
 namespace my
 {
@@ -51,6 +55,10 @@
     // class using the sole grid information (the grid can be seen
     // here as a ``tag'').
     typedef oln::grid1d grid_type;
+
+    // Likewise, for the switch of image_typeness using the type of
+    // the value of the image.
+    typedef char value_type;
   };
 }
 
@@ -60,24 +68,37 @@
   class image : public oln::set_super_type<my::image>::ret
   {
     typedef image self_type;
-    // An internal vtype.
+    // Internal vtypes.
     typedef oln_type_of_(self_type, grid) grid_type;
-    // An external vtype.
+    typedef oln_type_of_(self_type, value) value_type;
+    // External vtypes.
     typedef oln_type_of_(self_type, image_dimension) image_dimension_type;
+    typedef oln_type_of_(self_type, image_typeness) image_typeness_type;
   };
 }
 
 int
 main()
 {
-  // Check its internally defined vtype.
+  // Check its internally defined vtypes.
   mlc::assert_< mlc_eq(my::image::grid_type, oln::grid1d) >::check();
-  // Check its externally defined vtype.
-  mlc::assert_< mlc_eq( my::image::image_dimension_type,
+  mlc::assert_< mlc_eq(my::image::value_type, char) >::check();
+  // Check its externally defined vtypes.
+  mlc::assert_<
+    mlc_eq( my::image::image_dimension_type,
 		        stc::abstraction_as_type<oln::abstract::image1d> )
               >::check();
+  mlc::assert_<
+    mlc_eq( my::image::image_typeness_type,
+	    stc::abstraction_as_type<oln::abstract::grey_level_image> )
+    >::check();
+
   // Check its image dimension abstraction.
   mlc::assert_< mlc_is_a_(my::image, oln::abstract::image1d) >::check();
+  // Check its image ``typeness'' abstraction.
+  mlc::assert_< mlc_is_a_(my::image,
+			  oln::abstract::grey_level_image) >::check();
+
   // Ensure we can instantiate it.
   my::image i;
 
Index: oln/core/typedefs.hh
--- oln/core/typedefs.hh	(revision 479)
+++ oln/core/typedefs.hh	(working copy)
@@ -95,7 +95,11 @@
 // FIXME: To be enabled later.
 // --------------------------------------------------------------------
 //   mlc_decl_typedef(data_type);
-//   mlc_decl_typedef(value_type);
+// --------------------------------------------------------------------
+  mlc_decl_typedef(value_type);
+// --------------------------------------------------------------------
+// FIXME: To be enabled later.
+// --------------------------------------------------------------------
 //   mlc_decl_typedef(neighb_type);
 //   mlc_decl_typedef(value_storage_type);
 //   mlc_decl_typedef(storage_type);
@@ -120,10 +124,10 @@
 //   mlc_decl_typedef(image_constness_type);
 // --------------------------------------------------------------------
   mlc_decl_typedef(image_dimension_type);
+  mlc_decl_typedef(image_typeness_type);
 // --------------------------------------------------------------------
 // FIXME: To be enabled later.
 // --------------------------------------------------------------------
-//   mlc_decl_typedef(image_typeness_type);
 //   mlc_decl_typedef(image_valuedness_type);
 //   mlc_decl_typedef(image_rawness_type);
 // --------------------------------------------------------------------
Index: oln/core/abstract/image.hh
--- oln/core/abstract/image.hh	(revision 479)
+++ oln/core/abstract/image.hh	(working copy)
@@ -67,7 +67,11 @@
 // FIXME: To be enabled later.
 // --------------------------------------------------------------------
 //     typedef mlc::undefined concrete_type;
-//     typedef mlc::undefined value_type;
+// --------------------------------------------------------------------
+    typedef mlc::undefined value_type;
+// --------------------------------------------------------------------
+// FIXME: To be enabled later.
+// --------------------------------------------------------------------
 //     typedef mlc::undefined point_type;
 //     typedef mlc::undefined size_type;
 
@@ -103,7 +107,11 @@
 // FIXME: To be enabled later.
 // --------------------------------------------------------------------
 //     typedef oln_type_of(I, concrete) concrete_type;
-//     typedef oln_type_of(I, value) value_type;
+// --------------------------------------------------------------------
+    typedef oln_type_of(I, value) value_type;
+// --------------------------------------------------------------------
+// FIXME: To be enabled later.
+// --------------------------------------------------------------------
 //     typedef oln_type_of(I, point) point_type;
 //     typedef oln_type_of(I, size) size_type;
 
@@ -128,6 +136,7 @@
 
     // Defined externally virtual types.
     typedef oln_type_of(I, image_dimension) image_dimension_type;
+    typedef oln_type_of(I, image_typeness)  image_typeness_type;
 
     /// Pretty-printing.
     static void echo(std::ostream& ostr)
@@ -144,7 +153,11 @@
 // FIXME: To be enabled later.
 // --------------------------------------------------------------------
 // 	<< "  concrete_type = " << mlc_to_string(concrete_type) << std::endl
-// 	<< "  value_type = " << mlc_to_string(value_type) << std::endl
+// --------------------------------------------------------------------
+  	<< "  value_type = " << mlc_to_string(value_type) << std::endl
+// --------------------------------------------------------------------
+// FIXME: To be enabled later.
+// --------------------------------------------------------------------
 // 	<< "  point_type = " << mlc_to_string(point_type) << std::endl
 // 	<< "  size_type = " << mlc_to_string(size_type) << std::endl
 
@@ -165,7 +178,10 @@
 // 	<< "  image_constness_type = " << mlc_to_string(image_constness_type) << std::endl
 // 	<< "  image_rawness_type = " << mlc_to_string(image_rawness_type) << std::endl
 // --------------------------------------------------------------------
-	<< "  image_dimension_type = " << mlc_to_string(image_dimension_type) << std::endl
+	<< "  image_dimension_type = " << mlc_to_string(image_dimension_type)
+	<< std::endl
+	<< "  image_typeness_type = " << mlc_to_string(image_typeness_type)
+	<< std::endl
 	<< "}" << std::endl;
     }
 
@@ -179,7 +195,11 @@
 // FIXME: To be enabled later.
 // --------------------------------------------------------------------
 //       mlc::assert_< mlc_is_ok(concrete_type) >::check();
-//       mlc::assert_< mlc_is_ok(value_type) >::check();
+// --------------------------------------------------------------------
+      mlc::assert_< mlc_is_ok(value_type) >::check();
+// --------------------------------------------------------------------
+// FIXME: To be enabled later.
+// --------------------------------------------------------------------
 //       mlc::assert_< mlc_is_ok(point_type) >::check();
 //       mlc::assert_< mlc_is_ok(size_type) >::check();
 //       mlc::assert_< mlc_is_ok(piter_type) >::check();
@@ -200,6 +220,7 @@
 //       mlc::assert_< mlc_is_ok(image_rawness_type) >::check();
 // --------------------------------------------------------------------
       mlc::assert_< mlc_is_ok(image_dimension_type) >::check();
+      mlc::assert_< mlc_is_ok(image_typeness_type) >::check();
     }
   };
 
@@ -235,12 +256,16 @@
     template <typename E>
     struct image : public internal::get_image_impl < image<E>, E >
     {
+      /// Typedefs.
 // --------------------------------------------------------------------
 // FIXME: To be enabled later.
 // --------------------------------------------------------------------
-//       /// typedefs
 //       typedef oln_type_of(E, size)  size_type;
-//       typedef oln_type_of(E, value) value_type;
+// --------------------------------------------------------------------
+      typedef oln_type_of(E, value) value_type;
+// --------------------------------------------------------------------
+// FIXME: To be enabled later.
+// --------------------------------------------------------------------
 //       typedef oln_type_of(E, point) point_type;
 // --------------------------------------------------------------------
 
Index: oln/core/abstract/image_entry.hh
--- oln/core/abstract/image_entry.hh	(revision 479)
+++ oln/core/abstract/image_entry.hh	(working copy)
@@ -28,9 +28,13 @@
 #ifndef OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
 # define OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
 
-# include <mlc/case.hh>
 # include <stc/entry.hh>
-# include <oln/core/abstract/image.hh>
+
+# include <oln/core/abstract/image_abstractions.hh>
+// Abstraction hierachies.
+# include <oln/core/abstract/image_dimension.hh>
+# include <oln/core/abstract/image_typeness.hh>
+
 
 namespace oln
 {
@@ -62,22 +66,9 @@
       image_entry() {}
     };
 
-    /// \brief Tags for abstractions.
-    /// Use them instead of hard-coded numbers.
-    enum abstraction_tags
-      {
-	dimension_tag = 1,
-	constness_tag
-	// ...
-      };
-
   }  // end of namespace oln::abstract
 
 } // end of namespace oln
 
 
-// Add switch/case equipment in the oln namespace.
-mlc_case_equipment_for_namespace(oln);
-
-
 #endif // ! OLENA_CORE_ABSTRACT_IMAGE_ENTRY_HH
Index: oln/core/abstract/image_dimension.hh
--- oln/core/abstract/image_dimension.hh	(revision 479)
+++ oln/core/abstract/image_dimension.hh	(working copy)
@@ -28,7 +28,10 @@
 #ifndef OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
 # define OLENA_CORE_ABSTRACT_IMAGE_DIMENSION_HH
 
+# include <stc/entry.hh>
 # include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_abstractions.hh>
+
 
 /* Image dimension hierarchy (summary).
 
@@ -62,55 +65,36 @@
 
 */
 
-/*! \namespace oln
-** \brief oln namespace.
-*/
-namespace oln {
+namespace oln
+{
 
-  /*! \namespace oln::abstract
-  ** \brief oln::abstract namespace.
-  */
-  namespace abstract {
+  namespace abstract
+  {
 
-    /*! \class abstract::image1d<E>
-    **
-    ** Class of 1d images.
-    */
+    /// Class of 1D images.
     template <typename E>
     struct image1d : public virtual image<E>
     {
     protected:
-
-      /*! \brief Constructor (protected, empty).
-      */
+      /// Constructor (protected, empty).
       image1d() {}
     };
 
-    /*! \class abstract::image2d<E>
-    **
-    ** Class of 2d images.
-    */
+    /// Class of 2D images.
     template <typename E>
     struct image2d : public virtual image<E>
     {
     protected:
-
-      /*! \brief Constructor (protected, empty).
-      */
+      /// Constructor (protected, empty).
       image2d() {}
     };
  
-    /*! \class abstract::image3d<E>
-    **
-    ** Class of 3d images.
-    */
+    /// Class of 3d images.
     template <typename E>
     struct image3d : public virtual image<E>
     {
     protected:
-
-      /*! \brief Constructor (protected, empty).
-      */
+      /// Constructor (protected, empty).
       image3d() {}
     };
  
@@ -121,12 +105,10 @@
   | Dimension switch.  |
   `-------------------*/
 
-  /// Forward declarations.
-  /// \{
+  // Forward declarations.
   class grid1d;
   class grid2d;
   class grid3d;
-  /// \}
   
   /// Case tag for the dimension.
   struct grid_dim_tag;
@@ -182,9 +164,11 @@
   };
 } // end of namespace stc
 
+
+// FIXME: Is this external property really useful?
 namespace oln
 {
-  /// An external type associated to my::B.
+  /// Image dimension type as an external vtype of abstract::image.
   template <typename I>
   struct ext_vtype< category::image,
 		    abstract::image<I>,
Index: oln/core/abstract/image_typeness_integre.hh
--- oln/core/abstract/image_typeness_integre.hh	(revision 0)
+++ oln/core/abstract/image_typeness_integre.hh	(revision 0)
@@ -0,0 +1,161 @@
+// 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.
+
+
+// FIXME: Move this file into Integre? Or in a another project,
+// serving as a glue between Integre and Olena?
+
+#ifndef OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_INTEGRE_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_INTEGRE_HH
+
+# include <oln/core/abstract/image_typeness.hh>
+
+
+// Forward declarations.
+/* FIXME: These are Integre values; should'nt we let Integre add the
+   necessary cases itself?  */
+namespace ntg
+{
+  class bin;
+  template <unsigned nbits, typename behavior> class int_u;
+  template <unsigned nbits, typename behavior> class int_s;
+  template <typename E> class color_value;
+  template <typename E> class enum_value;
+  template <typename E> class real_value;
+
+    /** \brief ``eq'' operator dedicated to ntg::int_u<nbits, behavior> and
+	ntg::int_s<nbits, behavior>, with nbits a known unsigned (e.g.,
+	int_u<1, behavior>).
+
+	Checking whether value_type is a ntg::int_u<1, behavior>
+	(behavior being a template parameter) is a bit tricky: we
+	can't use mlc_eq() since ntg::int_u<1, B> is not a (complete)
+	type, nor mlc_is_a(), since it is a partially-valued template.
+	Hence this dedicated approach, used for ntg::int_u and
+	ntg::int_s.
+
+	(Olena proto-1.0 used to mimic mlc_is_a with its own
+	machinery, for all kind of value type, which is redundant with
+	mlc_is_a).
+	\{ */
+    template< template <unsigned, class> class T, unsigned nbits, typename U >
+    struct eq_ : public mlc::bexpr_<false>
+    {
+    };
+
+    template< template <unsigned, class> class T, unsigned nbits,
+	      typename behavior >
+    struct eq_< T, nbits, T<nbits, behavior> > : public mlc::bexpr_<true>
+    {
+    };
+    /** \} */
+
+} // end of namespace ntg
+
+
+namespace oln {
+
+  /*--------------------.
+  | Value type switch.  |
+  `--------------------*/
+  
+  /// Switch on on the value type.
+  /// \{
+
+  // ----------------------------------------------- //
+  // Cases where the value type is an Integre type.  //
+  // ----------------------------------------------- //
+
+  // (The first cases are located in oln/core/abstract/image_typeness.hh).
+
+
+  /// Binary case.
+  template <typename value_type>
+  struct case_<value_type_tag, value_type, 3> :
+    public mlc::where_<
+             mlc::or_list_< mlc_eq(value_type, ntg::bin),
+			    ntg::eq_<ntg::int_u, 1, value_type>,
+			    ntg::eq_<ntg::int_s, 1, value_type> > >
+  {
+    // Definition of the super class corresponding to this case.
+    typedef stc::abstraction_as_type<abstract::binary_image> super_type;
+    // Definition of the external virtual type (same as the super
+    // class in this case).
+    typedef super_type image_typeness_type;
+  };
+
+  /// Grey-level case.
+  template <typename value_type>
+  struct case_<value_type_tag, value_type, 4> :
+    public mlc::where_< mlc_is_a(value_type, ntg::real_value) >
+  {
+    // Definition of the super class corresponding to this case
+    // (abstract::grey_level_image_ is the conjunction of
+    // abstract::grey_level_image and abstract::not_binary_image).
+    typedef
+      stc::abstraction_as_type<abstract::internal::grey_level_image_>
+      super_type;
+    // Definition of the external virtual type.
+    typedef stc::abstraction_as_type<abstract::grey_level_image>
+      image_typeness_type;
+  };
+
+  /// Label case.
+  template <typename value_type>
+  struct case_<value_type_tag, value_type, 5> :
+    public mlc::where_< mlc_is_a(value_type, ntg::enum_value) >
+  {
+    // Definition of the super class corresponding to this case
+    // (abstract::label_image_ is the conjunction of
+    // abstract::label_image and abstract::not_binary_image).
+    typedef stc::abstraction_as_type<abstract::internal::label_image_>
+      super_type;
+    // Definition of the external virtual type.
+    typedef stc::abstraction_as_type<abstract::label_image>
+      image_typeness_type;
+  };
+
+  /// Color case.
+  template <typename value_type>
+  struct case_<value_type_tag, value_type, 6> :
+    public mlc::where_< mlc_is_a(value_type, ntg::color_value) >
+  {
+    // Definition of the super class corresponding to this case
+    // (abstract::color_image_ is the conjunction of
+    // abstract::color_image and abstract::not_binary_image).
+    typedef stc::abstraction_as_type<abstract::internal::color_image_>
+      super_type;
+    // Definition of the external virtual type.
+    typedef stc::abstraction_as_type<abstract::color_image>
+      image_typeness_type;
+  };
+
+  /// \}
+
+} // end of namespace oln
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_INTEGRE_HH
Index: oln/core/abstract/image_typeness.hh
--- oln/core/abstract/image_typeness.hh	(revision 0)
+++ oln/core/abstract/image_typeness.hh	(working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2005 EPITA Research and Development Laboratory
+// 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
@@ -12,8 +12,8 @@
 //
 // 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, 59 Temple Place - Suite 330, Boston,
-// MA 02111-1307, USA.
+// 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
@@ -28,275 +28,281 @@
 #ifndef OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
 # define OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
 
-# include <ntg/decls.hh>
+# include <stc/entry.hh>
 # include <oln/core/abstract/image.hh>
+# include <oln/core/abstract/image_abstractions.hh>
 
 
-//                         image
-//
-//                           ^
-//                           |
-//         -------------------------------------------------
-//        |              |            |           |         |
-//
-// greylevel_image  color_image  label_image  data_image   ...
-//
-//                                    ^
-//                                    |
-//
-//                               binary_image
+/* Image ``typeness'' hierarchy (summary).
 
 
+                                    /image<I>/
+                                        ^
+                                        |
+           ,--------------+-------------+-------------+--------+---------.
+           |              |             |             |        |         |
+ /grey_level_image/ /color_image/ /label_image/ /data_image/  ...  /not_binary_
+           ^              ^         ^       ^         ^        ^       image/
+           |              |         |       |         |        |         ^
+           |              |         |  /binary_image/ |        |         |
+           |              |         |       ^         |        |         |
+           |              |         |       |         |        |         |
+       ,---------------------------------------------------------------------.
+       | The selection of the super classe(s) is made according to the value |
+       |                      of type_of(I, value).                          |
+       `---------------------------------------------------------------------'
+           |              |         |       |         |        |         |
+           o              o         o       o         o        o         o
+
+                                        o
+                                        | 
+                       stc::set_entry_node<I, typeness_tag>
+                            (image typeness selector)
+                                        ^
+                                        |
+                                 /image_entry<I>/
+                                        ^
+                                        |
+                                        I
+                                (a concrete image)
 
-// fwd decls
-namespace oln {
-  namespace abstract {
-    template <typename E> struct greylevel_image;
-    template <typename E> struct color_image;
-    template <typename E> struct label_image;
-    template <typename E> struct binary_image;
-    template <typename E> struct not_binary_image;
-    template <typename E> struct data_image;
-  }
-}
-
-
-/// Macro.
-# define oln_typeness_of(T) typename typeness::tag_< typeness::of<T>::val >::ret
-
-
-
-/*! \namespace oln
-** \brief oln namespace.
 */
-namespace oln {
-
 
-  /*! \namespace oln::typeness
-  ** \brief oln::typeness namespace.
-  */
-  namespace typeness {
-
-    enum {
-      _greylevel_tag = 1,
-      _color_tag     = 2,
-      _label_tag     = 3,
-      _binary_tag    = 4,
-      _data_tag      = 5
-    };
-
-    struct greylevel_tag;
-    struct color_tag;
-    struct label_tag;
-    struct binary_tag;
-    struct data_tag;
-
-    template <int tag> struct tag_;
-    template <> struct tag_ <_greylevel_tag> { typedef greylevel_tag ret; };
-    template <> struct tag_ <_color_tag>     { typedef color_tag ret; };
-    template <> struct tag_ <_label_tag>     { typedef label_tag ret; };
-    template <> struct tag_ <_binary_tag>    { typedef binary_tag ret; };
-    template <> struct tag_ <_data_tag>      { typedef data_tag ret; };
+namespace oln {
 
-    template <typename T>
-    struct of
+  namespace abstract
     {
-    protected:
-
-      static T* makeT();
-      template <int tag> struct tag_is { char c[tag]; };
-
-      template <typename E>
-      static tag_is<_color_tag>     selector(ntg::color_value<E>*);
-
-      template <typename E>
-      static tag_is<_label_tag>     selector(ntg::enum_value<E>*);
 
+    /// \brief Class of grey-level images.
+    /// 
+    /// An image that contains values whose type is \c int or
+    /// <tt>unsigned char</tt>, or ntg::int_u<8> (...) is <b>not</b> a
+    /// grey-level image.
+    ///
+    /// FIXME: Say more.
       template <typename E>
-      static tag_is<_greylevel_tag> selector(ntg::real_value<E>*);
-
-      static tag_is<_greylevel_tag> selector(char*);
-      static tag_is<_greylevel_tag> selector(unsigned char*);
-
-      static tag_is<_binary_tag>    selector(bool*);
-      static tag_is<_binary_tag>    selector(ntg::bin*);
-      template <class b>
-      static tag_is<_binary_tag>    selector(ntg::int_u<1,b>*);
-      template <class b>
-      static tag_is<_binary_tag>    selector(ntg::int_s<1,b>*);
-
-      static tag_is<_data_tag>      selector(...); // default
-
-    public:
-
-      enum { val = sizeof(selector(makeT())) };
+    struct grey_level_image : public virtual image<E>
+    {
+    protected:
+      /// Constructor (protected, empty).
+      grey_level_image() {}
     };
 
-
-    // specializations:
-
-    template <class T, class interval>
-    struct of < ntg::cycle<T, interval> >
+    /// Class of color images.
+    template <typename E>
+    struct color_image : public virtual image<E>
     {
-      enum { val = of<T>::val };
+    protected:
+      /// Constructor (protected, empty).
+      color_image() {}
     };
 
-    template <class T, class interval, class behavior>
-    struct of < ntg::range<T, interval, behavior> >
+    /// \brief Class of images whose data are NOT Boolean values.
+    ///
+    /// However such images can derive from abstract::label_image (we
+    /// can have labels that are not binary ones).
+    template <typename E>
+    struct not_binary_image : public virtual image<E>
     {
-      enum { val = of<T>::val };
+    protected:
+      /// Constructor (protected, empty).
+      not_binary_image() {}
     };
 
-
-    // inheritance mechanism:
-
-    template <typename tag, typename E>
-    struct inheritance_case;
-
-    // case: greylevel
+    /// \brief Class of images whose data are labels.
+    /// 
+    /// Such images do not support arithmetics.
     template <typename E>
-    struct inheritance_case <greylevel_tag, E> :
-      public abstract::greylevel_image<E>,
-      public abstract::not_binary_image<E>
-    {};
-    // case: color
-    template <typename E> struct inheritance_case <color_tag, E> :
-      public abstract::color_image<E>,
-      public abstract::not_binary_image<E>
-    {};
-    // case: label
-    template <typename E> struct inheritance_case <label_tag, E> :
-      public abstract::label_image<E>,
-      public abstract::not_binary_image<E>
-    {};
-    // case: binary
-    template <typename E> struct inheritance_case <binary_tag, E> :
-      public abstract::binary_image<E>
-    {};
-    // case: data
-    template <typename E> struct inheritance_case <data_tag, E> :
-      public abstract::data_image<E>,
-      public abstract::not_binary_image<E>
-    {};
+    struct label_image : public virtual image<E>
+    {
+    protected:
+      /// Constructor (protected, empty).
+      label_image() {}
+    };
 
-    // switch
+    /// \brief Class of images whose data are Boolean values.
+    ///
+    /// Such images are also oln::abstract::label_image.
     template <typename E>
-    struct inheritance_switch :
-      public inheritance_case < typename tag_< of<oln_type_of(E, value)>::val >::ret, E >
+    struct binary_image : public label_image<E>
     {
+    protected:
+      /// Constructor (protected, empty).
+      binary_image() {}
     };
 
-
-  } // end of namespace oln::typeness
-
-
-
-
-  /*! \namespace oln::abstract
-  ** \brief oln::abstract namespace.
-  */
-  namespace abstract {
-
-
-    /*! \class abstract::greylevel_image<E>
-    **
-    ** Class of greylevel images.  An image that contains values whose
-    ** type is 'int' or 'unsigned char', or 'ntg::int_u<8>' (...) is
-    ** NOT a greylevel image.  FIXME: say more.
-    */
-
+    /// \brief Class of images whose data cannot be qualified of
+    /// grey-levels, colors, or labels.
     template <typename E>
-    struct greylevel_image : public virtual image<E>
+    struct data_image : public virtual image<E>
     {
     protected:
       /// Constructor (protected, empty).
-      greylevel_image() {}
+      data_image() {}
     };
 
 
+    /*---------------------.
+    | Conjunctions types.  |
+    `---------------------*/
 
-    /*! \class abstract::color_image<E>
-    **
-    ** Class of color images.
-    */
+    namespace internal
+    {
+
+      /// \brief Conjunctions types
+      ///
+      /// These types are helpers to express the inheritance relation
+      /// ``is a X and not_binary_image''.  These abstractions are not
+      /// to be used by client code (i.e., algorithms), they are only
+      /// part of the inheritance machinery.
+      //
+      /// \{
 
+      /// <em>Grey-level image</em> and <em>not binary image</em> abstraction.
     template <typename E>
-    struct color_image : public virtual image<E>
+      struct grey_level_image_ : public grey_level_image<E>,
+				 public not_binary_image<E>
     {
     protected:
       /// Constructor (protected, empty).
-      color_image() {}
+	grey_level_image_() {}
     };
 
-
-
-    /*! \class abstract::label_image<E>
-    **
-    ** Class of images whose data are labels.  Such images do not
-    ** support arithmetics.
-    */
-
+      /// <em>Label image</em> and <em>not binary image</em> abstraction.
     template <typename E>
-    struct label_image : public virtual image<E>
+      struct label_image_ : public label_image<E>,
+			    public not_binary_image<E>
     {
     protected:
       /// Constructor (protected, empty).
-      label_image() {}
+	label_image_() {}
     };
 
-
-
-    /*! \class abstract::binary_image<E>
-    **
-    ** Class of images whose data are Boolean values.  Such images are
-    ** abstract::label_image.
-    */
-
+      /// <em>Color image</em> and <em>not binary image</em> abstraction.
     template <typename E>
-    struct binary_image : public label_image<E>
+      struct color_image_ : public color_image<E>,
+			    public not_binary_image<E>
     {
     protected:
       /// Constructor (protected, empty).
-      binary_image() {}
+	color_image_() {}
     };
 
-    /*! \class abstract::not_binary_image<E>
-    **
-    ** Class of images whose data are NOT Boolean values.  However
-    ** such images can derive from abstract::label_image (we can have
-    ** labels that are not binary ones).
-    */
-
+      /// <em>Data image</em> and <em>not binary image</em> abstraction.
     template <typename E>
-    struct not_binary_image : public virtual image<E>
+      struct data_image_ : public data_image<E>,
+			   public not_binary_image<E>
     {
     protected:
       /// Constructor (protected, empty).
-      not_binary_image() {}
+	data_image_() {}
     };
 
+    /// \}
 
+    } // end of namespace oln::abstract::internal
 
-    /*! \class abstract::data_image<E>
-    **
-    ** Class of images whose data cannot be qualified of greylevels,
-    ** colors, or labels.
-    */
+  } // end of namespace oln::abstract
 
-    template <typename E>
-    struct data_image : public virtual image<E>
+
+  /*--------------------.
+  | Value type switch.  |
+  `--------------------*/
+
+  /// Case tag for the dimension.
+  struct value_type_tag;
+  
+  /// Switch on on the grid dimension.
+  /// \{
+
+  // ----------------------------------------------- //
+  // Cases where the value type is an builtin type.  //
+  // ----------------------------------------------- //
+
+  /// Binary case.
+  template <typename value_type>
+  struct case_<value_type_tag, value_type, 1> :
+    public mlc::where_< mlc_eq(value_type, bool) >
     {
-    protected:
-      /// Constructor (protected, empty).
-      data_image() {}
+    // Definition of the super class corresponding to this case.
+    typedef stc::abstraction_as_type<abstract::binary_image> super_type;
+    // Definition of the external virtual type (same as the super
+    // class in this case).
+    typedef super_type image_typeness_type;
     };
 
+  /// Grey-level case.
+  template <typename value_type>
+  struct case_<value_type_tag, value_type, 2> :
+    public mlc::where_<
+             mlc::or_list_< mlc_eq(value_type, char),
+			    mlc_eq(value_type, unsigned char),
+			    mlc_eq(value_type, unsigned char) > >
+  {
+    // Definition of the super class corresponding to this case
+    // (abstract::grey_level_image_ is the conjunction of
+    // abstract::grey_level_image and abstract::not_binary_image).
+    typedef stc::abstraction_as_type<abstract::internal::grey_level_image_>
+      super_type;
+    // Definition of the external virtual type.
+    typedef stc::abstraction_as_type<abstract::grey_level_image>
+      image_typeness_type;
+  };
 
 
-  } // end of namespace oln::abstract
+  // -------------- //
+  // Default case.  //
+  // -------------- //
+
+  /// Default case: image of ``data''.
+  template <typename value_type>
+  struct default_case_<value_type_tag, value_type>
+  {
+    // Definition of the super class corresponding to this case
+    // (abstract::data_image_ is the conjunction of
+    // abstract::data_image and abstract::not_binary_image).
+    typedef stc::abstraction_as_type<abstract::internal::data_image_>
+      super_type;
+    // Definition of the external virtual type.
+    typedef stc::abstraction_as_type<abstract::data_image>
+      image_typeness_type;
+  };
 
+  /// \}
 
 } // end of namespace oln
 
 
+// Register the dimension switch/case for oln::abstract::image_entry.
+namespace stc
+{
+  template <typename I>
+  struct set_entry_node<I, oln::abstract::typeness_tag> :
+    public oln::case_< oln::value_type_tag, oln_type_of(I, value) >::ret
+      ::super_type::template instantiated_with<I>::ret
+  {
+  };
+} // end of namespace stc
+
+
+// FIXME: Is this external property really useful?
+namespace oln
+{
+  /// Image ``typeness'' as an external vtype of abstract::image.
+  template <typename I>
+  struct ext_vtype< category::image,
+		    abstract::image<I>,
+		    // FIXME: Get rid of this typedef_:: qualifier.
+		    typedef_::image_typeness_type >
+  {
+    // Use the same case as the one use in the inheritance-plugging
+    // mechanism above, but retrieve the external vtype
+    // (image_typename_type), not the super type.
+    typedef
+      typename oln::case_< oln::value_type_tag,
+			   oln_type_of(I, value) >::ret::image_typeness_type
+      ret;
+  };
+}
+
 #endif // ! OLENA_CORE_ABSTRACT_IMAGE_TYPENESS_HH
Index: oln/core/abstract/image_abstractions.hh
--- oln/core/abstract/image_abstractions.hh	(revision 0)
+++ oln/core/abstract/image_abstractions.hh	(revision 0)
@@ -0,0 +1,61 @@
+// 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.
+
+#ifndef OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
+# define OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
+
+# include <mlc/case.hh>
+
+// Add switch/case equipment in the oln namespace.
+mlc_case_equipment_for_namespace(oln);
+
+
+namespace oln
+{
+  namespace abstract
+  {
+
+    /// \brief Tags for abstractions.
+    ///
+    /// Use them instead of hard-coded numbers.
+    enum abstraction_tags
+      {
+	// constness_tag,
+	dimension_tag = 1,
+	typeness_tag
+	// valuedness_tag,
+	// rawness_tag,
+	// neighbness_tag,
+	// ...
+      };
+
+  } // end of namespace oln::abstract
+
+} // end of namespace oln
+
+
+#endif // ! OLENA_CORE_ABSTRACT_IMAGE_ABSTRACTIONS_HH
Index: oln/Makefile.am
--- oln/Makefile.am	(revision 479)
+++ oln/Makefile.am	(working copy)
@@ -13,8 +13,11 @@
   core/abstract/any.hh				\
   core/abstract/grid.hh				\
   core/abstract/image.hh			\
+  core/abstract/image_abstractions.hh		\
   core/abstract/image_entry.hh			\
   core/abstract/image_dimension.hh		\
+  core/abstract/image_typeness.hh		\
+  core/abstract/image_typeness_integre.hh	\
   core/abstract/macros.hh			\
 						\
   core/abstract/internal/image_impl.hh
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    
                    
                        https://svn.lrde.epita.fr/svn/oln/trunk/static
Index: ChangeLog
from  Roland Levillain  <roland(a)lrde.epita.fr>
	Remove the mlc::eqv and mlc::neqv workarounds.
	* stc/vtypes.hh (mlc::eqv, mlc::neqv): Remove these workarounds.
	(mlc_eqv, mlc_neqv): Remove macros.
	(rec_get_vtype, rec_get_ext_vtype): No longer use these
	workarounds, and revert to mlc_eq and mlc_neq usage (since they
	have been fixed in Metalic).
	* tests/vtypes.cc (main): Adjust.
 stc/vtypes.hh   |   57 +++-----------------------------------------------------
 tests/vtypes.cc |   10 +--------
 2 files changed, 6 insertions(+), 61 deletions(-)
Index: tests/vtypes.cc
--- tests/vtypes.cc	(revision 478)
+++ tests/vtypes.cc	(working copy)
@@ -218,16 +218,10 @@
 {
   // Check types associated to A.
   mlc::assert_<mlc_eq(my::A::foo_type, int)>::check();
-  /* FIXME: Note that we use mlc_eqv, not mlc_eq, since the latter
-     doesn't accept Metalic values.  Try to get rid of this
-     limitation.  */
-  mlc::assert_<mlc_eqv(my::A::bar_type, mlc::int_<42>)>::check();
+  mlc::assert_<mlc_eq(my::A::bar_type, mlc::int_<42>)>::check();
 
   // Check types associated to B.
-  /* FIXME: Note that we use mlc_neqv, not mlc_neq, since the latter
-     doesn't accept Metalic values.  Try to get rid of this
-     limitation.  */
-  mlc::assert_<mlc_neqv(my::B::bar_type, my::A::bar_type)>::check();
+  mlc::assert_<mlc_neq(my::B::bar_type, my::A::bar_type)>::check();
   mlc::assert_<mlc_eq(my::B::baz_type, char)>::check();
   mlc::assert_<mlc_eq(my::B::quux_type, long)>::check();
   mlc::assert_<mlc_eq(my::B::yin_type, unsigned long)>::check();
Index: stc/vtypes.hh
--- stc/vtypes.hh	(revision 478)
+++ stc/vtypes.hh	(working copy)
@@ -42,55 +42,6 @@
 # include <mlc/is_a.hh>
 
 
-/*----------------------.
-| Metalic workarounds.  |
-`----------------------*/
-
-/// Shortcuts.
-/// \{
-# define mlc_eqv( T1, T2) mlc::eqv_ <T1, T2>
-# define mlc_neqv(T1, T2) mlc::neqv_<T1, T2>
-/// \}
-
-namespace mlc
-{
-  /* FIXME: This really is a work around Metalic's limitations
-     regarding the operands of its logic operators than cannot be
-     subtypes of mlc::abstract::value.  This limitations breaks Static
-     when a virtual type *is* a Metalic value!  Hence the introduction
-     of this more laxist version of mlc_neq.  */
-
-  /// Equality test between a couple of types, also accepting Metalic
-  /// values (i.e., subtypes of mlc::abstract::value).
-  /// \{
-  template <typename T1, typename T2>
-  struct eqv_ : public bexpr_<false>
-  {
-  };
-
-  template <typename T>
-  struct eqv_ <T, T> : public bexpr_<true>
-  {
-  };
-  /// \}
-
-  /// Inequality test between a couple of types, also accepting Metalic
-  /// values (i.e., subtypes of mlc::abstract::value).
-  /// \{
-  template <typename T1, typename T2>
-  struct neqv_ : public bexpr_<true>
-  {
-  };
-
-  template <typename T>
-  struct neqv_ <T, T> : public bexpr_<false>
-  {
-  };
-  /// \}
-
-} // end of namespace mlc
-
-
 /*------------.
 | Equipment.  |
 `------------*/
@@ -208,7 +159,7 @@
 									      \
       typedef typename							      \
       mlc::if_<								      \
-	mlc::neqv_< type, mlc::not_found >,				      \
+	mlc::neq_< type, mlc::not_found >,				      \
 	/* then	*/							      \
 	/*   return it					*/		      \
 	/*   (the typedef has been found in the vtypes	*/		      \
@@ -218,7 +169,7 @@
 	/*   check if the vtype of the `super' of FROM_TYPE */		      \
 	/*   has the typedef				    */		      \
 	typename							      \
-	mlc::if_< mlc::neqv_< typename rec_get_vtype<category,		      \
+	mlc::if_< mlc::neq_< typename rec_get_vtype< category,		      \
 						     super,		      \
 						     typedef_type>::ret,      \
 			     mlc::not_found >,				      \
@@ -276,7 +227,7 @@
 									      \
       typedef typename							      \
       mlc::if_<								      \
-	mlc::neqv_< type, mlc::not_found >,				      \
+	mlc::neq_< type, mlc::not_found >,				      \
 	/* then	*/							      \
 	/*   return it					*/		      \
 	/*   (the typedef has been found in the vtypes	*/		      \
@@ -286,7 +237,7 @@
 	/*   check if the vtype of the `super' of FROM_TYPE */		      \
 	/*   has the typedef				    */		      \
 	typename							      \
-	mlc::if_< mlc::neqv_< typename rec_get_ext_vtype<category,	      \
+	mlc::if_< mlc::neq_< typename rec_get_ext_vtype< category,	      \
 							 super,		      \
 							 typedef_type>::ret,  \
 			     mlc::not_found >,				      \
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0
                            
                          
                          
                            
    
                          
                        
                    26 Apr '06
                    
                        
https://svn.lrde.epita.fr/svn/oln/trunk/metalic
Index: ChangeLog
from  Thierry Geraud  <theo(a)lrde.epita.fr>
	Add mlc_propagate_typedef_from; fix mlc::eq_ and _neq_.
	* mlc/typedef.hh (mlc_propagate_typedef_from): New macro.
	* mlc/cmp.hh (eq_, neq_): Change assertions so that it works on value
	types.
 cmp.hh     |   44 ++++++++++++++++++++++++++++++++++----------
 typedef.hh |    9 +++++++++
 2 files changed, 43 insertions(+), 10 deletions(-)
Index: mlc/typedef.hh
--- mlc/typedef.hh	(revision 477)
+++ mlc/typedef.hh	(working copy)
@@ -34,6 +34,15 @@
 # include <mlc/cmp.hh>
 
 
+/*! \macro mlc_propagate_typedef_from(Typedef, Type)
+**
+** FIXME: doc and say "end with ';'"
+*/
+# define mlc_propagate_typedef_from(Typedef, Type) \
+   typedef  typename Type :: Typedef  Typedef
+
+
+
 /*! \macro mlc_decl_typedef(TypedefName)
 **
 ** This macro is for declaring the use of a typedef embedded in
Index: mlc/cmp.hh
--- mlc/cmp.hh	(revision 477)
+++ mlc/cmp.hh	(working copy)
@@ -47,6 +47,9 @@
 /// \{
 /// Macros mlc_something(T) corresponding to mlc::something_<T>.
 
+# define mlc_is_bexpr(T)     mlc::is_bexpr_<T>
+# define mlc_is_not_bexpr(T) mlc::is_not_bexpr_<T>
+
 # define mlc_is_found(T)     mlc::is_found_<T>
 # define mlc_is_not_found(T) mlc::is_not_found_<T>
 
@@ -67,6 +70,10 @@
 namespace mlc
 {
 
+  /*----------------------------------------------------------------.
+  | Syntactic sugar for checking that a type is a value / a bexpr.  |
+  `-----------------------------------------------------------------*/
+
   /// Check whether \a T is a mlc::abstract::value.
   template <typename T>
   struct is_value : public mlc_is_a(T, mlc::abstract::value)::bexpr
@@ -80,45 +87,62 @@
   };
 
 
+  /// Check whether \a T is a mlc::abstract::bexpr.
+  template <typename T>
+  struct is_bexpr : public mlc_is_a(T, mlc::abstract::bexpr)::bexpr
+  {
+  };
+
+  /// Check whether \a T is not a mlc::abstract::bexpr.
+  template <typename T>
+  struct is_not_bexpr : public not_<mlc_is_a(T, mlc::abstract::bexpr)>::bexpr
+  {
+  };
+
+
+
+  /*--------------------------.
+  | Comparison between types  |
+  `---------------------------*/
 
   /// Equality test between a couple of types.
   /// \{
   template <typename T1, typename T2>
-  struct eq_ : private multiple_assert_< is_not_value<T1>,
-					 is_not_value<T2> >,
+  struct eq_ : private multiple_assert_< is_not_bexpr<T1>,
+					 is_not_bexpr<T2> >,
 	       public bexpr_<false>
   {
   };
 
   template <typename T>
-  struct eq_ <T, T> : private assert_< is_not_value<T> >,
+  struct eq_ <T, T> : private assert_< is_not_bexpr<T> >,
 		      public bexpr_<true>
   {
   };
   /// \}
 
 
-
   /// Inequality test between a couple of types.
   /// \{
   template <typename T1, typename T2>
-  struct neq_ : private multiple_assert_< is_not_value<T1>,
-					  is_not_value<T2> >,
+  struct neq_ : private multiple_assert_< is_not_bexpr<T1>,
+					  is_not_bexpr<T2> >,
 		public bexpr_<true>
   {
   };
 
   template <typename T>
-  struct neq_ <T, T> : private assert_< is_not_value<T> >,
+  struct neq_ <T, T> : private assert_< is_not_bexpr<T> >,
 		       public bexpr_<false>
   {
   };
   /// \}
 
 
-  /*--------------------------------------.
-  | Syntactic sugar for flag comparison.  |
-  `--------------------------------------*/
+
+  /*--------------------------------------------------------------------------.
+  | Syntactic sugar for checking the relationship between a type and a flag.  |
+  `---------------------------------------------------------------------------*/
 
   /// Shortcuts for comparison with mlc::not_found.
   /// \{
                    
                  
                  
                          
                            
                            1
                            
                          
                          
                            
                            0