https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Preparing a revamp of value types.
* mln/core/concept/proxy.hh (mln_def_binop_proxy): Add
operators to disambiguate the case of Proxy Op Literal.
(set_binary_): New overload for Proxy Op Literal.
* mln/core/concept/image.hh (~image): New check.
* mln/literal/black.hh,
* mln/literal/white.hh (operator float, operator double): New.
They are guarded by...
(MLN_NEW_VALUE_TYPES): ...this new variable.
* mln/value/rgb.hh (quant): Fix definition.
When n was low, say 3, then the quant was also set to low,
though there was no way to browse the set of values!
(rgb): New ctor overload for vec<3,float>; useful for
accu::mean.
core/concept/image.hh | 6 +++++-
core/concept/proxy.hh | 37 +++++++++++++++++++++++++++++++++++++
literal/black.hh | 31 +++++++++++++++++++++++++------
literal/white.hh | 31 +++++++++++++++++++++++++------
value/rgb.hh | 12 +++++++++++-
5 files changed, 103 insertions(+), 14 deletions(-)
Index: mln/core/concept/proxy.hh
--- mln/core/concept/proxy.hh (revision 4354)
+++ mln/core/concept/proxy.hh (working copy)
@@ -114,6 +114,22 @@
return exact(o) Symb exact(p).unproxy_(); \
} \
\
+ template <typename P, typename L> \
+ inline \
+ mln_trait_op_##Name(P, L) \
+ operator Symb (const Proxy<P>& p, const Literal<L>& l) \
+ { \
+ return exact(p).unproxy_() Symb exact(l); \
+ } \
+ \
+ template <typename L, typename P> \
+ inline \
+ mln_trait_op_##Name(L, P) \
+ operator Symb (const Literal<L>& l, const Proxy<P>& p) \
+ { \
+ return exact(l) Symb exact(p).unproxy_(); \
+ } \
+ \
struct e_n_d__w_i_t_h__s_e_m_i_c_o_l_u_m_n
@@ -124,6 +140,8 @@
// Forward declarations.
template <typename E> struct Proxy;
+ template <typename E> struct Literal;
+
namespace convert
{
@@ -175,6 +193,25 @@
typedef mln_trait_binary(Op, O, S) ret;
};
+
+ // Disambiguate between (Proxy Op Object) and (Object Op Literal).
+
+ template < template <class, class> class Op,
+ typename P, typename L >
+ struct set_binary_< Op, mln::Proxy, P, mln::Literal, L >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_binary(Op, S, L) ret;
+ };
+
+ template < template <class, class> class Op,
+ typename L, typename P >
+ struct set_binary_< Op, mln::Literal, L, mln::Proxy, P >
+ {
+ typedef mlc_unqualif(mln_q_subject(P)) S;
+ typedef mln_trait_binary(Op, L, S) ret;
+ };
+
} // end of namespace mln::trait
Index: mln/core/concept/image.hh
--- mln/core/concept/image.hh (revision 4354)
+++ mln/core/concept/image.hh (working copy)
@@ -52,8 +52,10 @@
{
- // Forward declaration.
+ // Forward declarations.
template <typename E> struct Image;
+ template <typename E> struct Literal;
+
// Image category flag type.
template <>
@@ -239,6 +241,8 @@
typedef mln_rvalue(E) rvalue;
typedef mln_lvalue(E) lvalue;
+ mlc_is_not_a(value, Literal)::check();
+
// FIXME Doc
//typedef mln_vset(E) vset;
//const vset& (E::*m5)() const = & E::values;
Index: mln/literal/black.hh
--- mln/literal/black.hh (revision 4354)
+++ mln/literal/black.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -26,13 +27,12 @@
#ifndef MLN_LITERAL_BLACK_HH
# define MLN_LITERAL_BLACK_HH
-/*! \file
- * \brief Definition of the literal of mln::black.
- *
- */
+/// \file
+/// \brief Definition of the 'black' literal.
# include <mln/core/concept/literal.hh>
+
namespace mln
{
@@ -42,17 +42,36 @@
/// Type of literal black.
struct black_t : public Literal<black_t>
{
+# ifdef MLN_NEW_VALUE_TYPES
+ operator float() const;
+ operator double() const;
+# endif // MLN_NEW_VALUE_TYPES
};
/// Literal black.
extern const black_t& black;
+
# ifndef MLN_INCLUDE_ONLY
const black_t& black = black_t();
-# endif
+# ifdef MLN_NEW_VALUE_TYPES
+ inline
+ black_t::operator float() const
+ {
+ return 0.f;
+ }
+
+ inline
+ black_t::operator double() const
+ {
+ return 0.;
+ }
+# endif // MLN_NEW_VALUE_TYPES
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: mln/literal/white.hh
--- mln/literal/white.hh (revision 4354)
+++ mln/literal/white.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory (LRDE)
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development
+// Laboratory (LRDE)
//
// This file is part of Olena.
//
@@ -26,13 +27,12 @@
#ifndef MLN_LITERAL_WHITE_HH
# define MLN_LITERAL_WHITE_HH
-/*! \file
- * \brief Definition of the literal of mln::white.
- *
- */
+/// \file
+/// \brief Definition of the 'white' literal.
# include <mln/core/concept/literal.hh>
+
namespace mln
{
@@ -42,17 +42,36 @@
/// Type of literal white.
struct white_t : public Literal<white_t>
{
+# ifdef MLN_NEW_VALUE_TYPES
+ operator float() const;
+ operator double() const;
+# endif // MLN_NEW_VALUE_TYPES
};
/// Literal white.
extern const white_t& white;
+
# ifndef MLN_INCLUDE_ONLY
const white_t& white = white_t();
-# endif
+# ifdef MLN_NEW_VALUE_TYPES
+ inline
+ white_t::operator float() const
+ {
+ return 1.f;
+ }
+
+ inline
+ white_t::operator double() const
+ {
+ return 1.;
+ }
+# endif // MLN_NEW_VALUE_TYPES
+
+# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::literal
Index: mln/value/rgb.hh
--- mln/value/rgb.hh (revision 4354)
+++ mln/value/rgb.hh (working copy)
@@ -205,7 +205,7 @@
typedef trait::value::nature::vectorial nature;
typedef trait::value::kind::color kind;
- typedef mln_value_quant_from_(card) quant;
+ typedef trait::value::quant::high /*mln_value_quant_from_(card)*/ quant;
typedef void comp;
typedef mln::value::int_u<n> comp_0;
@@ -275,6 +275,7 @@
rgb<n>(const algebra::vec<3, int>& rhs);
rgb<n>(const algebra::vec<3, unsigned>& rhs);
rgb<n>(const algebra::vec<3, int_u<n> >& rhs);
+ rgb<n>(const algebra::vec<3, float>& rhs);
// Conversion to the interoperation type.
operator algebra::vec<3, int>() const { return this->v_; }
@@ -436,6 +437,15 @@
template <unsigned n>
inline
+ rgb<n>::rgb(const algebra::vec<3, float>& v)
+ {
+ this->v_[0] = v[0];
+ this->v_[1] = v[1];
+ this->v_[2] = v[2];
+ }
+
+ template <unsigned n>
+ inline
rgb<n>::rgb(int r, int g, int b)
{
mln_precondition(r >= 0);