https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Move op-related traits into trait::op:: to be consistent.
* mln/trait/op_plus.hh,
* mln/trait/op_minus.hh,
* mln/trait/op_uminus.hh,
* mln/trait/op_times.hh: Rename as...
* mln/trait/op/times.hh,
* mln/trait/op/plus.hh,
* mln/trait/op/minus.hh,
* mln/trait/op/uminus.hh: ...those.
(op_): Rename as...
(op::): ...those.
* mln/trait/op/all.hh: New.
* mln/trait/all.hh: Update; include op/all.hh.
* tests/trait_op_uminus.cc,
* tests/trait_super.cc,
* tests/trait_op_plus.cc,
* mln/core/ops.hh,
* mln/metal/mat.hh,
* mln/metal/vec.hh,
* mln/arith/plus.hh,
* mln/pw/all.hh: Update.
mln/arith/plus.hh | 2 -
mln/core/ops.hh | 6 +----
mln/metal/mat.hh | 10 ++++-----
mln/metal/vec.hh | 8 +++----
mln/pw/all.hh | 3 --
mln/trait/all.hh | 11 +++-------
mln/trait/op/all.hh | 50 +++++++++++++++++++++++++++++++++++++++++++++++
mln/trait/op/minus.hh | 14 ++++++++-----
mln/trait/op/plus.hh | 14 ++++++++-----
mln/trait/op/times.hh | 14 ++++++++-----
mln/trait/op/uminus.hh | 15 +++++++++-----
tests/trait_op_plus.cc | 10 ++++-----
tests/trait_op_uminus.cc | 10 ++++-----
tests/trait_super.cc | 4 +--
14 files changed, 116 insertions(+), 55 deletions(-)
Index: tests/trait_op_uminus.cc
--- tests/trait_op_uminus.cc (revision 1275)
+++ tests/trait_op_uminus.cc (working copy)
@@ -27,10 +27,10 @@
/*! \file tests/trait_op_uminus.cc
*
- * \brief Tests on mln::trait::op_uminus.
+ * \brief Tests on mln::trait::op::uminus.
*/
-#include <mln/trait/op_uminus.hh>
+#include <mln/trait/op/uminus.hh>
#include <mln/core/concept/object.hh>
@@ -79,19 +79,19 @@
{
// template <>
-// struct set_precise_unary_< op_uminus, test >
+// struct set_precise_unary_< op::uminus, test >
// {
// typedef bool ret;
// };
// template <typename T>
-// struct set_unary_< op_uminus, Sub_Concept, T >
+// struct set_unary_< op::uminus, Sub_Concept, T >
// {
// typedef int ret;
// };
// template <typename T>
-// struct set_unary_< op_uminus, Top_Concept, T >
+// struct set_unary_< op::uminus, Top_Concept, T >
// {
// typedef float ret;
// };
Index: tests/trait_super.cc
--- tests/trait_super.cc (revision 1275)
+++ tests/trait_super.cc (working copy)
@@ -30,7 +30,7 @@
* \brief Tests on mln::trait::solve.
*/
-#include <mln/trait/op_uminus.hh>
+#include <mln/trait/op/uminus.hh>
#include <mln/core/concept/object.hh>
#include <mln/value/int_u8.hh>
@@ -127,7 +127,7 @@
{
template <typename T>
- struct set_unary_< op_uminus, my::Integer, T >
+ struct set_unary_< op::uminus, my::Integer, T >
{
typedef bool ret;
};
Index: tests/trait_op_plus.cc
--- tests/trait_op_plus.cc (revision 1275)
+++ tests/trait_op_plus.cc (working copy)
@@ -27,12 +27,12 @@
/*! \file tests/trait_op_plus.cc
*
- * \brief Tests on mln::trait::op_plus.
+ * \brief Tests on mln::trait::op::plus.
*/
#include <mln/core/concept/image.hh>
#include <mln/value/concept/all.hh>
-#include <mln/trait/op_plus.hh>
+#include <mln/trait/op/plus.hh>
namespace mln
@@ -52,7 +52,7 @@
// int + float -> float
template <>
- struct set_precise_binary_< op_plus, int, float >
+ struct set_precise_binary_< op::plus, int, float >
{
typedef float ret;
};
@@ -61,7 +61,7 @@
// Image I + Image J -> bool (demo type!)
template <typename I, typename J>
- struct set_binary_< op_plus, Image, I, Image, J >
+ struct set_binary_< op::plus, Image, I, Image, J >
{
typedef bool ret;
};
@@ -69,7 +69,7 @@
// precise definition: my_image2d<T> + my_image2d<U> ->
my_image2d<V> ('&' is to avoid compiling an empty class)
template <typename T, typename U>
- struct set_precise_binary_< op_plus, my_image2d<T>, my_image2d<U>
>
+ struct set_precise_binary_< op::plus, my_image2d<T>, my_image2d<U>
>
{
typedef mln_trait_op_plus(T, U) V;
typedef my_image2d<V>& ret;
Index: mln/trait/all.hh
--- mln/trait/all.hh (revision 1275)
+++ mln/trait/all.hh (working copy)
@@ -32,24 +32,21 @@
namespace mln
{
- // FIXME: Doc!
+ /// Namespace where traits are defined.
namespace trait
{}
} // end of namespace mln
+// meta-program to solve a trait call
# include <mln/trait/solve.hh>
// promote
# include <mln/trait/promote.hh>
-// arith
-# include <mln/trait/op_plus.hh>
-# include <mln/trait/op_times.hh>
-# include <mln/trait/op_minus.hh>
-# include <mln/trait/op_uminus.hh>
-
+// ops
+# include <mln/trait/op/all.hh>
#endif // ! MLN_TRAIT_ALL_HH
Index: mln/trait/op/times.hh
--- mln/trait/op/times.hh (revision 1275)
+++ mln/trait/op/times.hh (working copy)
@@ -31,8 +31,8 @@
# include <mln/trait/promote.hh>
-# define mln_trait_op_times(L, R) typename mln::trait::op_times< L , R >::ret
-# define mln_trait_op_times_(L, R) mln::trait::op_times< L , R >::ret
+# define mln_trait_op_times(L, R) typename mln::trait::op::times< L , R >::ret
+# define mln_trait_op_times_(L, R) mln::trait::op::times< L , R >::ret
@@ -42,16 +42,20 @@
namespace trait
{
+ namespace op
+ {
template <typename L, typename R>
- struct op_times : public solve_binary<op_times, L, R>
+ struct times : public solve_binary<times, L, R>
{
};
+ } // end of namespace mln::trait::op
+
- /// Default definition of op_times is given by the promote trait.
+ /// Default definition of op::times is given by the promote trait.
template <typename L, typename R>
- struct set_binary_< op_times, Object, L, Object, R >
+ struct set_binary_< op::times, Object, L, Object, R >
:
public promote< L, R >
{
Index: mln/trait/op/plus.hh
--- mln/trait/op/plus.hh (revision 1275)
+++ mln/trait/op/plus.hh (working copy)
@@ -31,8 +31,8 @@
# include <mln/trait/promote.hh>
-# define mln_trait_op_plus(L, R) typename mln::trait::op_plus< L , R >::ret
-# define mln_trait_op_plus_(L, R) mln::trait::op_plus< L , R >::ret
+# define mln_trait_op_plus(L, R) typename mln::trait::op::plus< L , R >::ret
+# define mln_trait_op_plus_(L, R) mln::trait::op::plus< L , R >::ret
@@ -42,16 +42,20 @@
namespace trait
{
+ namespace op
+ {
template <typename L, typename R>
- struct op_plus : public solve_binary<op_plus, L, R>
+ struct plus : public solve_binary<plus, L, R>
{
};
+ } // end of namespace mln::trait::op
+
- /// Default definition of op_plus is given by the promote trait.
+ /// Default definition of op::plus is given by the promote trait.
template < typename L, typename R >
- struct set_binary_< op_plus, Object, L, Object, R >
+ struct set_binary_< op::plus, Object, L, Object, R >
:
public promote< L, R >
{
Index: mln/trait/op/all.hh
--- mln/trait/op/all.hh (revision 0)
+++ mln/trait/op/all.hh (revision 0)
@@ -0,0 +1,50 @@
+// 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 MLN_TRAIT_OP_ALL_HH
+# define MLN_TRAIT_OP_ALL_HH
+
+
+namespace mln
+{
+
+ namespace trait
+ {
+ /// Namespace of traits related to operators.
+ namespace op {}
+ }
+
+} // end of namespace mln
+
+
+# include <mln/trait/op/plus.hh>
+# include <mln/trait/op/times.hh>
+# include <mln/trait/op/minus.hh>
+# include <mln/trait/op/uminus.hh>
+
+
+#endif // ! MLN_TRAIT_OP_ALL_HH
Index: mln/trait/op/minus.hh
--- mln/trait/op/minus.hh (revision 1275)
+++ mln/trait/op/minus.hh (working copy)
@@ -31,8 +31,8 @@
# include <mln/trait/promote.hh>
-# define mln_trait_op_minus(L, R) typename mln::trait::op_minus< L , R >::ret
-# define mln_trait_op_minus_(L, R) mln::trait::op_minus< L , R >::ret
+# define mln_trait_op_minus(L, R) typename mln::trait::op::minus< L , R >::ret
+# define mln_trait_op_minus_(L, R) mln::trait::op::minus< L , R >::ret
@@ -42,16 +42,20 @@
namespace trait
{
+ namespace op
+ {
template <typename L, typename R>
- struct op_minus : public solve_binary<op_minus, L, R>
+ struct minus : public solve_binary<minus, L, R>
{
};
+ } // end of namespace mln::trait::op
+
- /// Default definition of op_minus is given by the promote trait.
+ /// Default definition of op::minus is given by the promote trait.
template <typename L, typename R>
- struct set_binary_< op_minus, Object, L, Object, R >
+ struct set_binary_< op::minus, Object, L, Object, R >
:
public promote< L, R >
{
Index: mln/trait/op/uminus.hh
--- mln/trait/op/uminus.hh (revision 1275)
+++ mln/trait/op/uminus.hh (working copy)
@@ -31,8 +31,8 @@
# include <mln/trait/solve.hh>
-# define mln_trait_op_uminus(T) typename mln::trait::op_uminus< T >::ret
-# define mln_trait_op_uminus_(T) mln::trait::op_uminus< T >::ret
+# define mln_trait_op_uminus(T) typename mln::trait::op::uminus< T >::ret
+# define mln_trait_op_uminus_(T) mln::trait::op::uminus< T >::ret
@@ -46,15 +46,20 @@
namespace trait
{
+ namespace op
+ {
+
template <typename T>
- struct op_uminus : public solve_unary<op_uminus, T>
+ struct uminus : public solve_unary<uminus, T>
{
};
+ } // end of namespace mln::trait::op
+
- /// Default definition of op_uminus is the input type itself.
+ /// Default definition of op::uminus is the input type itself.
template <typename T>
- struct set_unary_< op_uminus, Object, T >
+ struct set_unary_< op::uminus, Object, T >
{
typedef T ret;
};
Index: mln/core/ops.hh
--- mln/core/ops.hh (revision 1275)
+++ mln/core/ops.hh (working copy)
@@ -35,9 +35,7 @@
# include <mln/core/concept/object.hh>
# include <mln/core/exact.hh>
# include <mln/value/builtin.hh>
-
-# include <mln/trait/op_plus.hh>
-# include <mln/trait/op_times.hh>
+# include <mln/trait/op/all.hh>
namespace mln
@@ -120,7 +118,7 @@
// namespace trait {
// template < typename L, typename R >
-// struct set_binary_< op_plus, Built_In, L, Object, R >
+// struct set_binary_< op::plus, Built_In, L, Object, R >
// {
// typedef mln_trait_op_plus(R, L)
// };
Index: mln/metal/mat.hh
--- mln/metal/mat.hh (revision 1275)
+++ mln/metal/mat.hh (working copy)
@@ -99,7 +99,7 @@
template <unsigned n, unsigned m, typename T,
typename U>
- struct set_precise_binary_<op_plus, metal::mat<n, m, T>, metal::mat<n, m,
U> >
+ struct set_precise_binary_<op::plus, metal::mat<n, m, T>, metal::mat<n,
m, U> >
{
typedef metal::mat<n, m, mln_trait_op_plus(T, U)> ret;
};
@@ -110,7 +110,7 @@
template <unsigned n, unsigned m, typename T,
typename U>
- struct set_precise_binary_<op_minus, metal::mat<n, m, T>, metal::mat<n,
m, U> >
+ struct set_precise_binary_<op::minus, metal::mat<n, m, T>, metal::mat<n,
m, U> >
{
typedef metal::mat<n, m, mln_trait_op_minus(T, U)> ret;
};
@@ -118,7 +118,7 @@
// - mat
template <unsigned n, unsigned m, typename T>
- struct set_precise_unary_<op_uminus, metal::mat<n, m, T> >
+ struct set_precise_unary_<op::uminus, metal::mat<n, m, T> >
{
typedef metal::mat<n, m, mln_trait_op_uminus(T)> ret;
};
@@ -127,7 +127,7 @@
template <unsigned n, unsigned o, typename T,
unsigned m, typename U>
- struct set_precise_binary_<op_times, metal::mat<n,o,T>,
metal::mat<o,m,U> >
+ struct set_precise_binary_<op::times, metal::mat<n,o,T>,
metal::mat<o,m,U> >
{
typedef metal::mat< n, m, mln_trait_op_times(T,U) > ret;
};
@@ -136,7 +136,7 @@
template <unsigned n, unsigned m, typename T,
typename S>
- struct set_precise_binary_<op_times, metal::mat<n,m,T>, S >
+ struct set_precise_binary_<op::times, metal::mat<n,m,T>, S >
{
typedef metal::mat< n, m, mln_trait_op_times(T,S) > ret;
};
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1275)
+++ mln/metal/vec.hh (working copy)
@@ -187,7 +187,7 @@
// vec + vec
template <unsigned n, typename T, typename U>
- struct set_precise_binary_<op_plus, metal::vec<n, T>, metal::vec<n, U>
>
+ struct set_precise_binary_<op::plus, metal::vec<n, T>, metal::vec<n,
U> >
{
typedef metal::vec<n, mln_trait_op_plus(T, U)> ret;
};
@@ -197,7 +197,7 @@
// vec - vec
template <unsigned n, typename T, typename U>
- struct set_precise_binary_<op_minus, metal::vec<n, T>, metal::vec<n,
U> >
+ struct set_precise_binary_<op::minus, metal::vec<n, T>, metal::vec<n,
U> >
{
typedef metal::vec<n, mln_trait_op_minus(T, U)> ret;
};
@@ -205,7 +205,7 @@
// - vec
template <unsigned n, typename T>
- struct set_precise_unary_<op_uminus, metal::vec<n, T> >
+ struct set_precise_unary_<op::uminus, metal::vec<n, T> >
{
typedef metal::vec<n, mln_trait_op_uminus(T)> ret;
};
@@ -213,7 +213,7 @@
// vec * s
template <unsigned n, typename T, typename S>
- struct set_precise_binary_<op_times, metal::vec<n, T>, S >
+ struct set_precise_binary_<op::times, metal::vec<n, T>, S >
{
typedef metal::vec<n, mln_trait_op_times(T, S)> ret;
};
Index: mln/arith/plus.hh
--- mln/arith/plus.hh (revision 1275)
+++ mln/arith/plus.hh (working copy)
@@ -39,7 +39,7 @@
# include <mln/pw/cst.hh>
# include <mln/pw/image.hh>
-# include <mln/trait/op_plus.hh>
+# include <mln/trait/op/plus.hh>
namespace mln
Index: mln/pw/all.hh
--- mln/pw/all.hh (revision 1275)
+++ mln/pw/all.hh (working copy)
@@ -37,8 +37,7 @@
namespace mln
{
- /*! Namespace of "point-wise" expression tools.
- */
+ /// Namespace of "point-wise" expression tools.
namespace pw {}
} // end of namespace mln