
Index: ChangeLog from Damien Thivolle <damien@lrde.epita.fr> * ChangeLog: New. * ntg/real/int_u8.hh: Fix unauthorized access to private attribute. * ntg/real/bin.hh: New. Binary data type. * ntg/makefile.src: Adds file dependencies. * ntg/color: New. * ntg/color/rgb_8.hh: New. RGB 8-bit quantified data type. color/rgb_8.hh | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ makefile.src | 60 +---------------------------- real/bin.hh | 80 ++++++++++++++++++++++++++++++++++++++ real/int_u8.hh | 12 ++--- 4 files changed, 207 insertions(+), 62 deletions(-) Index: ChangeLog Index: ntg/real/int_u8.hh --- ntg/real/int_u8.hh (revision 4) +++ ntg/real/int_u8.hh (working copy) @@ -1,5 +1,5 @@ -#ifndef INTEGRE_INT_U8_HH -# define INTEGRE_INT_U8_HH +#ifndef INTEGRE_REAL_INT_U8_HH +# define INTEGRE_REAL_INT_U8_HH # include <mlc/traits.hh> @@ -21,13 +21,13 @@ } int_u8(const int_u8& rhs) : - value_(rhs.value_) + value_(rhs) { } int_u8& operator=(const int_u8& rhs) { - this->value_ = rhs.value_; + this->value_ = rhs; return *this; } @@ -57,7 +57,7 @@ private: - unsigned char value_; + unsigned char value_; }; @@ -77,4 +77,4 @@ -#endif // ! INTEGRE_INT_U8_HH +#endif // ! INTEGRE_REAL_INT_U8_HH Index: ntg/real/bin.hh --- ntg/real/bin.hh (revision 0) +++ ntg/real/bin.hh (revision 0) @@ -0,0 +1,80 @@ +#ifndef INTEGRE_REAL_BIN_HH +# define INTEGRE_REAL_BIN_HH + + +# include <mlc/traits.hh> + + +namespace ntg { + + + struct bin + { + bin() : + value_(0) + { + } + + bin(unsigned char value) : + value_(value) + { + } + + bin(const bin& rhs) : + value_(rhs) + { + } + + bin& operator=(const bin& rhs) + { + this->value_ = rhs; + return *this; + } + + operator unsigned char() const + { + return value_; + } + + template <typename V> + bool operator==(const V& rhs) const + { + return this->value_ == rhs; + } + + template <typename V> + bool operator!=(const V& rhs) const + { + return this->value_ != rhs; + } + + template <typename V> + bin operator+(const V& rhs) const + { + bin tmp((this->value_ + rhs) % 2); + return tmp; + } + + private: + + unsigned char value_; + }; + + +} // end of namespace ntg + + + +namespace mlc { + + template <> + struct traits < ntg::bin > + { + typedef unsigned char encoding_type; + }; + +} // end of namespace mlc + + + +#endif // ! INTEGRE_REAL_BIN_HH Index: ntg/makefile.src --- ntg/makefile.src (revision 4) +++ ntg/makefile.src (working copy) @@ -4,60 +4,8 @@ ## NTG_DEP = \ - all.hh \ - basics.hh \ - bin.hh \ - color.hh \ - color/color.hh \ - color/hsi.hh \ - color/hsl.hh \ - color/hsv.hh \ - color/nrgb.hh \ - color/rgb.hh \ - color/xyz.hh \ - color/yiq.hh \ - color/yuv.hh \ - config/math.hh \ + color/rgb_8.hh \ config/system.hh \ - core/abstract_hierarchy.hh \ - real/behavior.hh \ - core/contract.hh \ - core/internal/global_ops.hh \ - core/internal/global_ops_defs.hh \ - core/internal/global_ops_traits.hh \ - core/internal/macros.hh \ - core/internal/traits.hh \ - core/interval.hh \ - core/macros.hh \ - core/pred_succ.hh \ - core/predecls.hh \ - core/type.hh \ - core/type_traits.hh \ - core/value.hh \ - cplx.hh \ - cycle.hh \ - enum/bin.hh \ - enum/builtin_bool.hh \ - enum/enum_value.hh \ - float.hh \ - int.hh \ - range.hh \ - real/builtin_int.hh \ - real/builtin_float.hh \ - real/builtin_properties.hh \ - real/cycle.hh \ - real/int_s.hh \ - real/int_u.hh \ - real/optraits_builtin_int.hh \ - real/optraits_real.hh \ - real/optraits_real_defs.hh \ - real/range.hh \ - real/real_value.hh \ - real/typetraits_builtin_int.hh \ - utils/cast.hh \ - utils/debug.hh \ - vec.hh \ - vect/cplx.hh \ - vect/cplx_representation.hh \ - vect/vec.hh \ - vect/vect_value.hh + config/math.hh \ + real/bin.hh \ + real/int_u8.hh Index: ntg/color/rgb_8.hh --- ntg/color/rgb_8.hh (revision 0) +++ ntg/color/rgb_8.hh (revision 0) @@ -0,0 +1,117 @@ +#ifndef INTEGRE_COLOR_RGB_8_HH +# define INTEGRE_COLOR_RGB_8_HH + + +# include <mlc/traits.hh> + + +namespace ntg { + + + enum { + rgb_red = 0, + rgb_green = 1, + rgb_blue = 2 + }; + + struct rgb_8 + { + rgb_8() + { + this->value_[rgb_red] = 0; + this->value_[rgb_green] = 0; + this->value_[rgb_blue] = 0; + } + + rgb_8(unsigned char red, + unsigned char green, + unsigned char blue) + { + this->value_[rgb_red] = red; + this->value_[rgb_green] = green; + this->value_[rgb_blue] = blue; + } + + rgb_8(const rgb_8& rhs) + { + this->value_[rgb_red] = rhs.red(); + this->value_[rgb_green] = rhs.green(); + this->value_[rgb_blue] = rhs.blue(); + } + + rgb_8& operator=(const rgb_8& rhs) + { + this->value_[rgb_red] = rhs.red(); + this->value_[rgb_green] = rhs.green(); + this->value_[rgb_blue] = rhs.blue(); + return *this; + } + + bool operator==(const rgb_8& rhs) const + { + return this->value_[rgb_red] == rhs.red() && + this->value_[rgb_green] == rhs.green() && + this->value_[rgb_blue] == rhs.blue(); + } + + template <typename V> + bool operator!=(const V& rhs) const + { + return this->value_[rgb_red] != rhs.red() || + this->value_[rgb_green] != rhs.green() || + this->value_[rgb_blue] != rhs.blue(); + } + + unsigned char& red() + { + return value_[rgb_red]; + } + + const unsigned char red() const + { + return value_[rgb_red]; + } + + unsigned char& green() + { + return value_[rgb_green]; + } + + const unsigned char green() const + { + return value_[rgb_green]; + } + + unsigned char& blue() + { + return value_[rgb_blue]; + } + + const unsigned char blue() const + { + return value_[rgb_blue]; + } + + private: + + unsigned char value_[3]; + }; + + +} // end of namespace ntg + + + +namespace mlc { + + template <> + struct traits < ntg::rgb_8 > + { + typedef unsigned char* encoding_type; + }; + +} // end of namespace mlc + + + +#endif // ! INTEGRE_COLOR_RGB_8_HH