Index: ChangeLog
from Damien Thivolle <damien(a)lrde.epita.fr>
* ntg/real/int_u8.hh: Fix operator==.
* ntg/real/integer.hh: Likewise.
* ntg/enum/enum.hh: Likewise.
* ntg/enum/bin.hh: Likewise.
* ntg/all.hh: New.
* ntg/core/macros.hh: Fix operator==.
* ntg/color/rgb_8.hh: Likewise.
* ntg/color/color.hh: Likewise.
all.hh | 36 ++++++++++++++++++++++++++++++++++
color/color.hh | 12 ++++++-----
color/rgb_8.hh | 58 +++++++++-----------------------------------------------
core/macros.hh | 2 -
enum/bin.hh | 10 ++++-----
enum/enum.hh | 20 ++++++++++++-------
real/int_u8.hh | 14 ++++++++-----
real/integer.hh | 11 +++++++---
8 files changed, 89 insertions(+), 74 deletions(-)
Index: ntg/real/int_u8.hh
--- ntg/real/int_u8.hh (revision 53)
+++ ntg/real/int_u8.hh (working copy)
@@ -83,16 +83,20 @@
return value_;
}
- template <typename V>
- bool impl_eq(const V& rhs) const
+// template <typename V>
+// bool impl_eq(const V& rhs) const
+// {
+// return this->value_ == rhs;
+// }
+
+ bool impl_eq(int rhs) const
{
return this->value_ == rhs;
}
- template <typename V>
- bool impl_not_eq(const V& rhs) const
+ bool impl_eq(const int_u8& rhs) const
{
- return this->value_ != rhs;
+ return this->value_ == (unsigned char)rhs;
}
template <typename V>
Index: ntg/real/integer.hh
--- ntg/real/integer.hh (revision 53)
+++ ntg/real/integer.hh (working copy)
@@ -62,16 +62,21 @@
return this->exact().impl_assign(rhs);
}
- template <typename V>
- bool operator==(const V& rhs) const
+ bool operator==(int rhs) const
{
return this->exact().impl_eq(rhs);
}
+ template <typename I>
+ bool operator==(const integer<I>& rhs) const
+ {
+ return this->exact().impl_eq(rhs.exact());
+ }
+
template <typename V>
bool operator!=(const V& rhs) const
{
- return this->exact().impl_not_eq(rhs);
+ return ! this->operator==(rhs);
}
template <typename V>
Index: ntg/enum/enum.hh
--- ntg/enum/enum.hh (revision 53)
+++ ntg/enum/enum.hh (working copy)
@@ -44,6 +44,7 @@
struct default_props < cat::enum_value >
{
enum { max_val = 0 };
+ enum { depth = 1 };
typedef mlc::no_type io_type;
protected:
@@ -55,25 +56,30 @@
{
typedef E exact_type;
- template <typename V>
- exact_type& operator=(const V& rhs)
+ bool operator==(int rhs) const
{
- return this->exact().impl_assign(rhs);
+ return this->exact().impl_eq(rhs);
}
- template <typename V>
- bool operator==(const V& rhs) const
+ template <typename I>
+ bool operator==(const enum_value<I>& rhs) const
{
- return this->exact().impl_eq(rhs);
+ return this->exact().impl_eq(rhs.exact());
}
template <typename V>
bool operator!=(const V& rhs) const
{
- return this->exact().impl_not_eq(rhs);
+ return ! this->operator==(rhs);
}
template <typename V>
+ exact_type& operator=(const V& rhs)
+ {
+ return this->exact().impl_assign(rhs);
+ }
+
+ template <typename V>
exact_type& operator+(const V& rhs) const
{
return this->exact().impl_add(rhs);
Index: ntg/enum/bin.hh
--- ntg/enum/bin.hh (revision 53)
+++ ntg/enum/bin.hh (working copy)
@@ -69,7 +69,7 @@
template <typename V>
bin& impl_assign(const V& rhs)
{
- this->value_ = rhs % 2;
+ this->value_ = (int)rhs % 2;
return *this;
}
@@ -78,18 +78,18 @@
return value_;
}
- template <typename V>
- bool impl_eq(const V& rhs) const
+ bool impl_eq(const unsigned char& rhs) const
{
return this->value_ == rhs;
}
template <typename V>
- bool impl_not_eq(const V& rhs) const
+ bool impl_eq(const V& rhs) const
{
- return this->value_ != rhs;
+ return this->value_ == (unsigned char)rhs;
}
+
template <typename V>
bin impl_add(const V& rhs) const
{
Index: ntg/all.hh
--- ntg/all.hh (revision 0)
+++ ntg/all.hh (revision 0)
@@ -0,0 +1,36 @@
+// Copyright (C) 2005 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, 59 Temple Place - Suite 330, 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 NTG_ALL_HH
+# define NTG_ALL_HH
+
+# include <ntg/core/macros.hh>
+# include <ntg/color/rgb_8.hh>
+# include <ntg/real/int_u8.hh>
+# include <ntg/enum/bin.hh>
+
+#endif // ! NTG_ALL_HH
Index: ntg/core/macros.hh
--- ntg/core/macros.hh (revision 53)
+++ ntg/core/macros.hh (working copy)
@@ -30,7 +30,7 @@
# define ntg_max_val(T) ntg::props<ntg_category_type(T),T>::max_val
-# define ntg_nb_comp(T) ntg::props<ntg_category_type(T),T>::nb_comp
+# define ntg_depth(T) ntg::props<ntg_category_type(T),T>::depth
# define ntg_comp_type(T) typename ntg::props<ntg_category_type(T),T>::comp_type
Index: ntg/color/rgb_8.hh
--- ntg/color/rgb_8.hh (revision 53)
+++ ntg/color/rgb_8.hh (working copy)
@@ -45,7 +45,7 @@
struct props<cat::color, rgb_8> : default_props<cat::color>
{
enum { max_val = 255 };
- enum { nb_comp = 3 };
+ enum { depth = 3 };
typedef char io_type;
typedef unsigned char comp_type;
@@ -84,33 +84,26 @@
rgb_8(const rgb_8& rhs)
{
- this->value_[rgb_red] = rhs.red();
- this->value_[rgb_green] = rhs.green();
- this->value_[rgb_blue] = rhs.blue();
+ this->value_[rgb_red] = rhs[rgb_red];
+ this->value_[rgb_green] = rhs[rgb_green];
+ this->value_[rgb_blue] = rhs[rgb_blue];
}
rgb_8& impl_assign(const rgb_8& rhs)
{
- this->value_[rgb_red] = rhs.red();
- this->value_[rgb_green] = rhs.green();
- this->value_[rgb_blue] = rhs.blue();
+ this->value_[rgb_red] = rhs[rgb_red];
+ this->value_[rgb_green] = rhs[rgb_green];
+ this->value_[rgb_blue] = rhs[rgb_blue];
return *this;
}
bool impl_eq(const rgb_8& rhs) const
{
- return this->value_[rgb_red] == rhs.red() &&
- this->value_[rgb_green] == rhs.green() &&
- this->value_[rgb_blue] == rhs.blue();
+ return this->value_[rgb_red] == rhs[rgb_red] &&
+ this->value_[rgb_green] == rhs[rgb_green] &&
+ this->value_[rgb_blue] == rhs[rgb_blue];
}
- bool impl_not_eq(const rgb_8& rhs) const
- {
- return this->value_[rgb_red] != rhs.red() ||
- this->value_[rgb_green] != rhs.green() ||
- this->value_[rgb_blue] != rhs.blue();
- }
-
unsigned char& impl_op_sqbr(unsigned int i)
{
assert(i < 3);
@@ -123,37 +116,6 @@
return value_[i];
}
-
- 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];
Index: ntg/color/color.hh
--- ntg/color/color.hh (revision 53)
+++ ntg/color/color.hh (working copy)
@@ -47,7 +47,7 @@
struct default_props < cat::color >
{
enum { max_val = 0 };
- enum { nb_comp = 0 };
+ enum { depth = 0 };
typedef mlc::undefined_type comp_type;
typedef mlc::undefined_type io_type;
@@ -67,14 +67,16 @@
return this->exact.impl_assign(rhs);
}
- bool operator==(const exact_type& rhs) const
+ template <typename I>
+ bool operator==(const color<I>& rhs) const
{
- return this->exact().impl_eq(rhs);
+ return this->exact().impl_eq(rhs.exact());
}
- bool operator!=(const exact_type& rhs) const
+ template <typename V>
+ bool operator!=(const V& rhs) const
{
- return this->exact().impl_not_eq(rhs);
+ return ! this->operator==(rhs);
}
comp_type& operator [](const unsigned int &i)