https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Update unary logical not.
* mln/fun/v2b/lnot.hh: New.
* mln/fun/v2b/all.hh: Update.
* mln/logical/not.hh: Rely on level transform.
fun/v2b/all.hh | 19 ++++++--------
fun/v2b/lnot.hh | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
logical/not.hh | 70 +++++++++++-----------------------------------------
3 files changed, 99 insertions(+), 65 deletions(-)
Index: mln/fun/v2b/all.hh
--- mln/fun/v2b/all.hh (revision 2868)
+++ mln/fun/v2b/all.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,10 +28,9 @@
#ifndef MLN_FUN_V2B_ALL_HH
# define MLN_FUN_V2B_ALL_HH
-/*! \file mln/fun/v2b/all.hh
- *
- * \brief File that includes all functions from point to value.
- */
+/// \file mln/fun/v2b/all.hh
+///
+/// File that includes all functions from value to logic value.
namespace mln
@@ -40,15 +39,15 @@
namespace fun
{
- /// Namespace of functions from point to value.
- namespace v2b
- {
- }
- }
+ /// Namespace of functions from value to logic value.
+ namespace v2b {}
}
+}
+# include <mln/fun/v2b/lnot.hh>
# include <mln/fun/v2b/threshold.hh>
+
#endif // ! MLN_FUN_V2B_ALL_HH
Index: mln/fun/v2b/lnot.hh
--- mln/fun/v2b/lnot.hh (revision 0)
+++ mln/fun/v2b/lnot.hh (revision 0)
@@ -0,0 +1,75 @@
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
+//
+// 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_FUN_V2B_LNOT_HH
+# define MLN_FUN_V2B_LNOT_HH
+
+/// \file mln/fun/v2b/lnot.hh
+///
+/// Functor that computes "logical not" on a value.
+
+# include <mln/core/concept/function.hh>
+
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ namespace v2b
+ {
+
+ /// Functor computing logical-not on a value.
+ template <typename V>
+ struct lnot : public Function_v2b< lnot<V> >
+ {
+ typedef V result;
+ V operator()(const V& v) const;
+ };
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename V>
+ inline
+ V
+ lnot<V>::operator()(const V& v) const
+ {
+ return ! v;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::fun::v2b
+
+ } // end of namespace mln::fun
+
+} // end of namespace mln
+
+
+#endif // ! MLN_FUN_V2B_LNOT_HH
Index: mln/logical/not.hh
--- mln/logical/not.hh (revision 2868)
+++ mln/logical/not.hh (working copy)
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,18 +29,12 @@
#ifndef MLN_LOGICAL_NOT_HH
# define MLN_LOGICAL_NOT_HH
-/*! \file mln/logical/not.hh
- *
- * \brief Point-wise "logical not" of a binary image.
- *
- * \todo Add static assertion and save one iterator in in-place version.
- */
-
-# include <mln/core/concept/image.hh>
+/// \file mln/logical/not.hh
+///
+/// Point-wise "logical not" of a binary image.
-
-// Specializations are in:
-# include <mln/logical/not.spe.hh>
+# include <mln/logical/includes.hh>
+# include <mln/fun/v2b/lnot.hh>
namespace mln
@@ -73,58 +68,21 @@
void not_inplace(Image<I>& input);
-# ifndef MLN_INCLUDE_ONLY
-
- namespace impl
- {
-
- namespace generic
- {
- template <typename I, typename O>
- inline
- void not_(const I& input, O& output)
- {
- trace::entering("logical::impl::generic::not_");
-
- mln_piter(I) p(input.domain());
- for_all(p)
- output(p) = ! input(p);
- trace::exiting("logical::impl::generic::not_");
- }
-
- template <typename I>
- inline
- void not_inplace(I& inout)
- {
- trace::entering("logical::impl::generic::not_");
-
- mln_piter(I) p(inout.domain());
- for_all(p)
- inout(p) = ! inout(p);
-
- trace::exiting("logical::impl::generic::not_");
- }
- }
-
- } // end of namespace mln::logical::impl
-
-
- // Facades.
+# ifndef MLN_INCLUDE_ONLY
template <typename I>
inline
mln_concrete(I) not_(const Image<I>& input)
{
- trace::entering("logical::not");
+ trace::entering("logical::not_");
mln_precondition(exact(input).has_data());
- mln_concrete(I) output;
- initialize(output, input);
- impl::not_(mln_trait_image_speed(I)(), exact(input), output);
+ fun::v2b::lnot<mln_value(I)> f;
+ mln_concrete(I) output = level::transform(input, f);
- trace::exiting("logical::not");
+ trace::exiting("logical::not_");
return output;
}
@@ -135,7 +93,9 @@
trace::entering("logical::not_inplace");
mln_precondition(exact(input).has_data());
- impl::not_inplace(mln_trait_image_speed(I)(), exact(input));
+
+ fun::v2b::lnot<mln_value(I)> f;
+ level::transform_inplace(input, f);
trace::exiting("logical::not_inplace");
}