https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Conversions from proxies keep the possible reference.
* mln/core/concept/proxy.hxx
(get_proxy_impl::operator): New overload (mutable) conversion
towards the immediate subject.
Keep ref or ptr in conversion return type.
* mln/core/concept/site_proxy.hh (operator site): De-activate
the static check of its presence since "site" can be either a
ref, a const ref, or a plain type.
* mln/core/concept/accumulator.hh (result_): Update.
* mln/core/dpoints_pixter.hh (get_adr): Replace by conversion.
Add a static check about the p_ref argument type.
* mln/core/internal/site_relative_iterator_base.hh: Likewise.
* mln/metal/fix_return.hh: New.
core/concept/accumulator.hh | 5 +-
core/concept/proxy.hxx | 14 +++++
core/concept/site_proxy.hh | 5 +-
core/dpoints_pixter.hh | 6 ++
core/internal/site_relative_iterator_base.hh | 6 +-
metal/fix_return.hh | 64 +++++++++++++++++++++++++++
6 files changed, 90 insertions(+), 10 deletions(-)
Index: mln/core/concept/proxy.hxx
--- mln/core/concept/proxy.hxx (revision 2405)
+++ mln/core/concept/proxy.hxx (working copy)
@@ -37,6 +37,7 @@
# include <mln/metal/unconst.hh>
# include <mln/metal/is_not_ref.hh>
# include <mln/metal/ref.hh>
+# include <mln/metal/fix_return.hh>
namespace mln
@@ -265,7 +266,9 @@
struct get_proxy_impl : helper_get_proxy_impl< Subject, E,
mlc_is_a(Subject, Proxy)::value >
{
- operator mlc_unqualif(Subject) () const;
+ public:
+ operator mlc_fix_return(Subject) ();
+ operator mlc_fix_return(mlc_const_return(Subject)) () const;
};
template <typename Subject, typename E>
@@ -378,7 +381,7 @@
template <typename Subject, typename E>
inline
- get_proxy_impl<Subject, E>::operator mlc_unqualif(Subject) () const
+ get_proxy_impl<Subject, E>::operator mlc_fix_return(mlc_const_return(Subject)) () const
{
return mln::internal::force_exact<const E>(*this).unproxy_();
@@ -391,6 +394,13 @@
// return *adr;
}
+ template <typename Subject, typename E>
+ inline
+ get_proxy_impl<Subject, E>::operator mlc_fix_return(Subject) ()
+ {
+ return mln::internal::force_exact<E>(*this).unproxy_();
+ }
+
// get_adr
Index: mln/core/concept/site_proxy.hh
--- mln/core/concept/site_proxy.hh (revision 2405)
+++ mln/core/concept/site_proxy.hh (working copy)
@@ -86,8 +86,9 @@
const site& (E::*m1)() const = & E::to_site;
m1 = 0;
- site (E::*m2)() const = & E::operator site;
- m2 = 0;
+ // De-activate because sometimes it returns a "const site&"...
+// site (E::*m2)() const = & E::operator site;
+// m2 = 0;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/concept/accumulator.hh
--- mln/core/concept/accumulator.hh (revision 2405)
+++ mln/core/concept/accumulator.hh (working copy)
@@ -34,7 +34,8 @@
*/
# include <mln/core/concept/proxy.hh>
-# include <mln/metal/unqualif.hh>
+# include <mln/metal/fix_return.hh>
+# include <mln/metal/const.hh>
namespace mln
@@ -104,7 +105,7 @@
result (E::*m4)() const = & E::to_result;
m4 = 0;
- typedef mlc_unqualif(result) result_;
+ typedef mlc_fix_return(mlc_const_return(result)) result_;
result_ (E::*m5)() const = & E::operator result_;
m5 = 0;
}
Index: mln/core/dpoints_pixter.hh
--- mln/core/dpoints_pixter.hh (revision 2405)
+++ mln/core/dpoints_pixter.hh (working copy)
@@ -38,6 +38,7 @@
# include <mln/core/concept/pixel_iterator.hh>
# include <mln/core/internal/pixel_impl.hh>
+# include <mln/metal/converts_to.hh>
namespace mln
@@ -225,7 +226,10 @@
: super_(image)
{
mln_precondition(image.has_data());
- internal::get_adr(p_ref_, p_ref);
+
+ mlc_converts_to(Pref, const mln_psite(I)&)::check();
+ p_ref_ = & static_cast< const mln_psite(I)& >(p_ref);
+
value_ref_ = 0;
init_(dps);
}
Index: mln/core/internal/site_relative_iterator_base.hh
--- mln/core/internal/site_relative_iterator_base.hh (revision 2405)
+++ mln/core/internal/site_relative_iterator_base.hh (working copy)
@@ -41,6 +41,7 @@
# include <vector>
# include <mln/core/internal/site_iterator_base.hh>
+# include <mln/metal/converts_to.hh>
namespace mln
@@ -138,9 +139,8 @@
void
site_relative_iterator_base<S,E>::center_at(const P& c)
{
- internal::get_adr(c_, c);
- mln_precondition(c_ != 0);
- // c_ == 0 means that the center c does not have the expected type.
+ mlc_converts_to(P, const mln_psite(S)&)::check();
+ c_ = & static_cast< const mln_psite(S)& >(c);
this->invalidate();
}
Index: mln/metal/fix_return.hh
--- mln/metal/fix_return.hh (revision 0)
+++ mln/metal/fix_return.hh (revision 0)
@@ -0,0 +1,64 @@
+// Copyright (C) 2008 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, 51 Franklin Street, Fifth Floor,
+// 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 MLN_METAL_FIX_RETURN_HH
+# define MLN_METAL_FIX_RETURN_HH
+
+/*!
+ * \file mln/metal/fix_return.hh
+ *
+ * \brief FIXME.
+ */
+
+
+# define mlc_fix_return(T) typename mln::metal::fix_return< T >::ret
+
+
+namespace mln
+{
+
+ namespace metal
+ {
+
+ // No-op.
+ template <typename T> struct fix_return { typedef T ret; };
+ template <typename T> struct fix_return< T& > { typedef T& ret; };
+ template <typename T> struct fix_return< const T& > { typedef const T& ret; };
+ template <typename T> struct fix_return< T* > { typedef T* ret; };
+ template <typename T> struct fix_return< const T* > { typedef const T* ret; };
+
+ // Remove const.
+ template <typename T> struct fix_return< const T > { typedef T ret; };
+ template <typename T> struct fix_return< T* const > { typedef T* ret; };
+ template <typename T> struct fix_return< const T* const > { typedef const T* ret; };
+
+ } // end of namespace mln::metal
+
+} // end of namespace mln
+
+
+#endif // ! MLN_METAL_FIX_RETURN_HH
#166: Revamp util::complex
-------------------------+--------------------------------------------------
Reporter: levill_r | Owner: levill_r
Type: enhancement | Status: new
Priority: major | Milestone: Olena 1.0
Component: Milena | Version: 1.0
Keywords: |
-------------------------+--------------------------------------------------
* As for images, use a `tracked_ptr` to handle the data of the complex,
i.e. split the `complex` classe in two:
* the complex « shell(s) », holding `tracked_ptr` to shared data; and
* the actual complex data (vertices and egdes).
Also, handle complexes directly from `p_complex` instead of using a
`tracked_ptr`, as copying complexes will become cheap (as for images).
* Move complex-related types and routines from `mln/core/` to
`mln/topo/`.
--
Ticket URL: <https://trac.lrde.org/olena/ticket/166>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.