URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox
ChangeLog:
2009-02-09 Edwin Carlinet <carlinet(a)lrde.epita.fr>
Add untake and setvalue property to card accu.
* edwin/accu_trait.hh: Add properties untake, stop, setvalue.
* edwin/card.hh: Add untake/setvalue method.
---
accu_trait.hh | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
card.hh | 2 +
2 files changed, 63 insertions(+), 8 deletions(-)
Index: trunk/milena/sandbox/edwin/card.hh
===================================================================
--- trunk/milena/sandbox/edwin/card.hh (revision 3316)
+++ trunk/milena/sandbox/edwin/card.hh (revision 3317)
@@ -18,6 +18,8 @@
void init () { c_ = 0; };
void take (const card<T>& accu) { c_ += accu.c_; };
void take (const T& elt) { ++c_; };
+ void untake (const T& elt) { --c_; };
+ void setvalue (const unsigned v) { c_ = v; };
unsigned to_result() const { return c_; };
bool is_valid () const { return true; };
Index: trunk/milena/sandbox/edwin/accu_trait.hh
===================================================================
--- trunk/milena/sandbox/edwin/accu_trait.hh (revision 3316)
+++ trunk/milena/sandbox/edwin/accu_trait.hh (revision 3317)
@@ -3,7 +3,18 @@
# include <mln/trait/undef.hh>
-# define mln_trait_accu_when_pix(A) typename trait::accu::accu_traits<A>::when_pix
+/// Shortcut to the accumulator property about untake method disponibility
+# define mln_trait_accu_has_untake(A) typename mln::trait::accu::accu_traits< A
>::has_untake
+
+/// Shortcut to the accumulator property about setvalue method disponibility
+# define mln_trait_accu_has_setvalue(A) typename mln::trait::accu::accu_traits< A
>::has_setvalue
+
+/// Shortcut to the accumulator property about stop method disponibility
+# define mln_trait_accu_has_stop(A) typename mln::trait::accu::accu_traits< A
>::has_stop
+
+/// Shortcut to the accumulator property about behavior when pixel is given as take()
value
+/// Used for instance in mln::canvas::morpho::leveling
+# define mln_trait_accu_when_pix(A) typename mln::trait::accu::accu_traits< A
>::when_pix
namespace mln
@@ -21,18 +32,57 @@
namespace accu
{
+ // Basic accumulators properties
+
+ struct has_untake
+ {
+ struct any { protected: any() {}; };
+
+ struct no : any { std::string name() const { return "has_untake::no"; }
};
+
+ struct yes : any { std::string name() const { return "has_untake::yes";
} };
+ };
+
+ struct has_stop
+ {
+ struct any { protected: any() {}; };
+
+ struct no : any { std::string name() const { return "has_setvalue::no";
} };
+
+ struct yes : any { std::string name() const { return "has_stop::yes"; }
};
+ };
+
+ struct has_setvalue
+ {
+ struct any { protected: any() {}; };
+
+ struct no : any { std::string name() const { return "has_setvalue::no";
} };
+
+ struct yes : any { std::string name() const { return
"has_setvalue::yes"; } };
+ };
+
+ // Morphological accumulators properties
struct when_pix
{
- struct use_v {};
- struct use_p {};
- struct use_pix {};
- struct use_whatever {};
- struct not_ok {};
+ struct any { protected: any() {}; };
+
+ struct use_v : any { std::string name() const { return
"when_pix::use_v"; } };
+
+ struct use_p : any { std::string name() const { return
"when_pix::use_p"; } };
+
+ struct use_pix : any { std::string name() const { return
"when_pix::use_pix"; } };
+
+ struct use_whatever { std::string name() const { return
"when_pix::use_whatever"; } };
+
+ struct not_ok : any { std::string name() const { return
"when_pix::not_ok"; } };
};
template <typename A>
struct accu_traits
{
+ typedef undef has_untake;
+ typedef undef has_stop;
+ typedef undef has_setvalue;
typedef undef when_pix;
};
@@ -40,11 +90,14 @@
template <typename T>
struct accu_traits< mln::morpho::accu::card <T> >
{
+ typedef has_stop::no has_stop;
+ typedef has_untake::yes has_untake;
+ typedef has_setvalue::yes has_setvalue;
typedef when_pix::use_p when_pix;
};
- } //accu
+ } //mln::accu
- }//trait
+ } //mln::trait
} //mln
#endif /* !ACCU_TRAIT_HH_ */