olena: olena-2.0-566-g0da19ec Fix mutual dependencies between value::int_u and value::qt::rgb32.

* mln/value/int_u.hh: Move definitions... * mln/value/int_u.hxx: ...here (new file). * mln/value/qt/rgb32.hh: Adjust. * headers.mk (nobase_include_HEADERS): Regen. --- milena/ChangeLog | 9 ++ milena/headers.mk | 1 + milena/mln/value/int_u.hh | 161 ++-------------------------------- milena/mln/value/int_u.hxx | 198 ++++++++++++++++++++++++++++++++++++++++++ milena/mln/value/qt/rgb32.hh | 30 ++++++- 5 files changed, 242 insertions(+), 157 deletions(-) create mode 100644 milena/mln/value/int_u.hxx diff --git a/milena/ChangeLog b/milena/ChangeLog index 9a326e6..e48a450 100644 --- a/milena/ChangeLog +++ b/milena/ChangeLog @@ -1,3 +1,12 @@ +2013-06-20 Roland Levillain <roland@lrde.epita.fr> + + Fix mutual dependencies between value::int_u and value::qt::rgb32. + + * mln/value/int_u.hh: Move definitions... + * mln/value/int_u.hxx: ...here (new file). + * mln/value/qt/rgb32.hh: Adjust. + * headers.mk (nobase_include_HEADERS): Regen. + 2013-06-19 Roland Levillain <roland@lrde.epita.fr> * doc/Doxyfile.in: Help Emacs fontify this file. diff --git a/milena/headers.mk b/milena/headers.mk index 95778bd..87f20e8 100644 --- a/milena/headers.mk +++ b/milena/headers.mk @@ -1241,6 +1241,7 @@ mln/value/int_s24.hh \ mln/value/int_s32.hh \ mln/value/int_s8.hh \ mln/value/int_u.hh \ +mln/value/int_u.hxx \ mln/value/int_u12.hh \ mln/value/int_u16.hh \ mln/value/int_u24.hh \ diff --git a/milena/mln/value/int_u.hh b/milena/mln/value/int_u.hh index 8e1e0ec..7744b96 100644 --- a/milena/mln/value/int_u.hh +++ b/milena/mln/value/int_u.hh @@ -29,7 +29,8 @@ /// \file /// -/// Define a generic class for unsigned integers. +/// Declaration of mln::value::int_u, a generic class for unsigned +/// integers. # include <mln/value/ops.hh> @@ -38,7 +39,6 @@ # include <mln/value/internal/encoding.hh> # include <mln/value/concept/integer.hh> # include <mln/trait/value_.hh> -# include <mln/debug/format.hh> # include <mln/value/internal/make_generic_name.hh> @@ -218,163 +218,18 @@ namespace mln } // end of namespace mln::value -# ifndef MLN_INCLUDE_ONLY - - namespace value - { - - template <unsigned n> - inline - int_u<n>::int_u() - { - } - - template <unsigned n> - inline - int_u<n>::int_u(int i) - { - mln_precondition(i >= 0); - mln_precondition(unsigned(i) <= mln_max(enc_)); - this->v_ = static_cast<enc_>(i); - } - - template <unsigned n> - inline - int_u<n>::int_u(const mln::literal::zero_t&) - { - this->v_ = 0; - } - - template <unsigned n> - inline - int_u<n>& - int_u<n>::operator=(const mln::literal::zero_t&) - { - this->v_ = 0; - return *this; - } - - template <unsigned n> - inline - int_u<n>::int_u(const mln::literal::one_t&) - { - this->v_ = 1; - } - - template <unsigned n> - inline - int_u<n>& - int_u<n>::operator=(const mln::literal::one_t&) - { - this->v_ = 1; - return *this; - } - - template <unsigned n> - inline - int_u<n>::operator unsigned() const - { - return this->v_; - } - - template <unsigned n> - inline - int - int_u<n>::operator-() const - { - return - int(this->v_); - } - - template <unsigned n> - inline - int_u<n>& - int_u<n>::operator=(int i) - { - mln_precondition(i >= 0); - mln_precondition(unsigned(i) <= mln_max(enc_)); - this->v_ = static_cast<enc_>(i); - return *this; - } - - template <unsigned n> - inline - int_u<n> - int_u<n>::next() const - { - return this->v_ + 1; - } - - template <unsigned n> - inline - std::ostream& operator<<(std::ostream& ostr, const int_u<n>& i) - { - // FIXME: This code could be factored for almost every Value<*>... - return ostr << debug::format(i.to_equiv()); // FIXME: is to_equiv OK? - } - - template <unsigned n> - inline - std::istream& operator>>(std::istream& istr, int_u<n>& i) - { - return istr >> i.handle_(); - } - - - // Conversions - - template <unsigned n> - inline - void - from_to_(const int_u<n>& from, unsigned& to_) - { - to_ = from; - } - - template <unsigned n> - inline - void - from_to_(const int_u<n>& from, bool& to_) - { - to_ = (from != 0u); - } - - template <unsigned n> - inline - void - from_to_(const int_u<n>& from, float& to_) - { - to_ = static_cast<float>(from); - } - - template <unsigned n> - inline - void - from_to_(const int_u<n>& from, double& to_) - { - to_ = static_cast<double>(from); - } +} // end of namespace mln - template <unsigned m> - void - from_to_(const int_u<m>& from, qt::rgb32& to) - { - mlc_bool(m <= 8)::check(); - to = qt::rgb32(from, from, from); - } - template <unsigned m> - void - from_to_(const int_u<m>& from, rgb<m>& to) - { - to = rgb<m>(from, from, from); - } +// Required by mln::values::int_u's from_to_ routines. +# include <mln/value/rgb.hh> +# include <mln/value/qt/rgb32.hh> - } // end of namespace mln::value +# ifndef MLN_INCLUDE_ONLY +# include <mln/value/int_u.hxx> # endif // ! MLN_INCLUDE_ONLY -} // end of namespace mln - #endif // ! MLN_VALUE_INT_U_HH diff --git a/milena/mln/value/int_u.hxx b/milena/mln/value/int_u.hxx new file mode 100644 index 0000000..728e310 --- /dev/null +++ b/milena/mln/value/int_u.hxx @@ -0,0 +1,198 @@ +// Copyright (C) 2007, 2008, 2009, 2010, 2012, 2013 EPITA Research and +// Development Laboratory (LRDE) +// +// This file is part of Olena. +// +// Olena is free software: you can redistribute it and/or modify it under +// the terms of the GNU General Public License as published by the Free +// Software Foundation, version 2 of the License. +// +// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>. +// +// As a special exception, you may use this file as part of a free +// software project 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 MLN_VALUE_INT_U_HXX +# define MLN_VALUE_INT_U_HXX + +/// \file +/// +/// Definition of mln::value::int_u, a generic class for unsigned +/// integers. + +# include <mln/value/int_u.hh> + +# include <mln/debug/format.hh> + + +namespace mln +{ + + namespace value + { + + template <unsigned n> + inline + int_u<n>::int_u() + { + } + + template <unsigned n> + inline + int_u<n>::int_u(int i) + { + mln_precondition(i >= 0); + mln_precondition(unsigned(i) <= mln_max(enc_)); + this->v_ = static_cast<enc_>(i); + } + + template <unsigned n> + inline + int_u<n>::int_u(const mln::literal::zero_t&) + { + this->v_ = 0; + } + + template <unsigned n> + inline + int_u<n>& + int_u<n>::operator=(const mln::literal::zero_t&) + { + this->v_ = 0; + return *this; + } + + template <unsigned n> + inline + int_u<n>::int_u(const mln::literal::one_t&) + { + this->v_ = 1; + } + + template <unsigned n> + inline + int_u<n>& + int_u<n>::operator=(const mln::literal::one_t&) + { + this->v_ = 1; + return *this; + } + + template <unsigned n> + inline + int_u<n>::operator unsigned() const + { + return this->v_; + } + + template <unsigned n> + inline + int + int_u<n>::operator-() const + { + return - int(this->v_); + } + + template <unsigned n> + inline + int_u<n>& + int_u<n>::operator=(int i) + { + mln_precondition(i >= 0); + mln_precondition(unsigned(i) <= mln_max(enc_)); + this->v_ = static_cast<enc_>(i); + return *this; + } + + template <unsigned n> + inline + int_u<n> + int_u<n>::next() const + { + return this->v_ + 1; + } + + template <unsigned n> + inline + std::ostream& operator<<(std::ostream& ostr, const int_u<n>& i) + { + // FIXME: This code could be factored for almost every Value<*>... + return ostr << debug::format(i.to_equiv()); // FIXME: is to_equiv OK? + } + + template <unsigned n> + inline + std::istream& operator>>(std::istream& istr, int_u<n>& i) + { + return istr >> i.handle_(); + } + + + // Conversions + + template <unsigned n> + inline + void + from_to_(const int_u<n>& from, unsigned& to_) + { + to_ = from; + } + + template <unsigned n> + inline + void + from_to_(const int_u<n>& from, bool& to_) + { + to_ = (from != 0u); + } + + template <unsigned n> + inline + void + from_to_(const int_u<n>& from, float& to_) + { + to_ = static_cast<float>(from); + } + + template <unsigned n> + inline + void + from_to_(const int_u<n>& from, double& to_) + { + to_ = static_cast<double>(from); + } + + template <unsigned m> + inline + void + from_to_(const int_u<m>& from, qt::rgb32& to) + { + mlc_bool(m <= 8)::check(); + to = qt::rgb32(from, from, from); + } + + template <unsigned m> + inline + void + from_to_(const int_u<m>& from, rgb<m>& to) + { + to = rgb<m>(from, from, from); + } + + } // end of namespace mln::value + +} // end of namespace mln + +#endif // ! MLN_VALUE_INT_U_HXX diff --git a/milena/mln/value/qt/rgb32.hh b/milena/mln/value/qt/rgb32.hh index 96404b8..f26c070 100644 --- a/milena/mln/value/qt/rgb32.hh +++ b/milena/mln/value/qt/rgb32.hh @@ -27,19 +27,35 @@ #ifndef MLN_VALUE_QT_RGB32_HH # define MLN_VALUE_QT_RGB32_HH -# include <cstring> +/// \file +/// +/// Definition of mln::value::qt::rgb32, a Qt-friendly 32-bit RGB +/// color value class. # include <mln/value/ops.hh> # include <mln/value/concept/vectorial.hh> -# include <mln/value/int_u.hh> # include <mln/algebra/vec.hh> -# include <mln/value/rgb8.hh> - # include <mln/literal/zero.hh> # include <mln/literal/black.hh> # include <mln/literal/white.hh> +# include <mln/literal/grays.hh> +# include <mln/literal/colors.hh> + +/* Because of mutual dependencies between the implementations of + mln::value::int_u and mln::value::qt::rgb32, we have to ensure that + only the interfaces of the required classes are included here. + Implementations are included later, at the bottom of this file. */ + +# ifdef MLN_INCLUDE_ONLY +# include <mln/value/int_u.hh> +# else +# define MLN_INCLUDE_ONLY +# include <mln/value/int_u.hh> +# undef MLN_INCLUDE_ONLY +# endif + namespace mln { @@ -763,4 +779,10 @@ namespace mln # endif // ! MLN_INCLUDE_ONLY +// Delayed inclusion of mln::value::int_u_'s implementation. +# ifndef MLN_INCLUDE_ONLY +# include <mln/value/int_u.hxx> +# endif // ! MLN_INCLUDE_ONLY + + #endif // ! MLN_VALUE_QT_RGB32_HH -- 1.7.10.4
participants (1)
-
Roland Levillain