
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena/sandbox ChangeLog: 2009-03-11 Etienne FOLIO <folio@lrde.epita.fr> Pipo type. * folio/test/value/pipo.cc: New tests for the pipo type. * folio/test/value: New directory for testing value-related algorithms. * folio/value/pipo.hh: New pipo type. * folio/value: New directory for value-related algorithms. --- test/value/pipo.cc | 21 ++++++++++++ value/pipo.hh | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) Index: trunk/milena/sandbox/folio/test/value/pipo.cc =================================================================== --- trunk/milena/sandbox/folio/test/value/pipo.cc (revision 0) +++ trunk/milena/sandbox/folio/test/value/pipo.cc (revision 3514) @@ -0,0 +1,21 @@ +/*! + * \file test_pipo.cc + * \author etiennefolio <ornthalas@gmail.com> + */ + +#include "../../value/pipo.hh" + +int main() +{ + using namespace mln; + + value::pipo p; + std::cout << p << std::endl; + + p.c0 = -1; + p.c1 = 0.42f; + p.c2 = 42; + std::cout << p << std::endl; + + return 0; +} Index: trunk/milena/sandbox/folio/value/pipo.hh =================================================================== --- trunk/milena/sandbox/folio/value/pipo.hh (revision 0) +++ trunk/milena/sandbox/folio/value/pipo.hh (revision 3514) @@ -0,0 +1,88 @@ +/*! + * \file pipo.hh + * \author etiennefolio <ornthalas@gmail.com> + */ + +#ifndef PIPO_HH_ +# define PIPO_HH_ + +#include <mln/value/int_s.hh> +#include <mln/value/int_u.hh> +#include <mln/value/float01.hh> + +namespace mln +{ + namespace value + { + class pipo + { + public: + + int_s<3> c0; + float01_<8> c1; + int_u<7> c2; + + pipo(); + pipo(int_s<3> _c0, + float01_<8> _c1, + int_u<7> _c2); + + pipo& operator=(const pipo& rhs); + + }; + +# ifndef MLN_INCLUDE_ONLY + + inline + pipo::pipo() + : c0(mln_min(int_s<3>)), + c1(mln_min(float01_<8>)), + c2(mln_min(int_u<7>)) + { + } + + inline + pipo::pipo(int_s<3> _c0, + float01_<8> _c1, + int_u<7> _c2) + : c0(_c0), + c1(_c1), + c2(_c2) + { + } + + inline + pipo& + pipo::operator=(const pipo& rhs) + { + if (& rhs == this) + return *this; + this->c0 = rhs.c0; + this->c1 = rhs.c1; + this->c2 = rhs.c2; + return *this; + } + + inline + std::ostream& operator<<(std::ostream& ostr, const pipo& v) + { + return ostr << '(' << debug::format(v.c0) + << ',' << debug::format(v.c1) + << ',' << debug::format(v.c2) + << ')'; + } + +// dunno why this doesn't compile... *_*" + +// inline +// std::istream& operator>>(std::istream& istr, pipo& c) +// { +// return istr >> c.c0 >> c.c1 >> c.c2; +// } + +# endif // ! MLN_INCLUDE_ONLY + + } +} + +#endif /* !PIPO_HH_ */
participants (1)
-
Etienne FOLIO