* doc/tutorial/tutorial.tex: fix compilation.
* mln/core/internal/neighb_niter_impl.hh: fix ambiguities and add more
doc.
* mln/fun/v2v/rgb_to_hsl.hh: remove duplicate declarations.
* mln/literal/one.hh,
* mln/literal/zero.hh: add 'const' qualification to conversion
operator.
* mln/make/edge_image.hh: update prototype.
* mln/make/rag_and_labeled_wsl.hh: remove useless local variable.
* mln/pw/internal/image_base.hh: add missing include.
* mln/util/vertex.hh: add missing include and forward declaration.
* tests/util/set.cc: update header.
---
milena/ChangeLog | 25 +++++++++++
milena/doc/tutorial/tutorial.tex | 25 +++++++----
milena/mln/core/internal/neighb_niter_impl.hh | 56 ++++++++++++++++++++++---
milena/mln/fun/v2v/rgb_to_hsl.hh | 56 -------------------------
milena/mln/literal/one.hh | 14 +++---
milena/mln/literal/zero.hh | 6 +-
milena/mln/make/edge_image.hh | 9 ++--
milena/mln/make/rag_and_labeled_wsl.hh | 2 -
milena/mln/pw/internal/image_base.hh | 1 +
milena/mln/util/vertex.hh | 2 +
milena/tests/util/set.cc | 1 +
11 files changed, 108 insertions(+), 89 deletions(-)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index a5e7011..d68a7e9 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,28 @@
+2009-05-06 Guillaume Lazzara <lazzara(a)lrde.epita.fr>
+
+ Small fixes.
+
+ * doc/tutorial/tutorial.tex: fix compilation.
+
+ * mln/core/internal/neighb_niter_impl.hh: fix ambiguities and add more
+ doc.
+
+ * mln/fun/v2v/rgb_to_hsl.hh: remove duplicate declarations.
+
+ * mln/literal/one.hh,
+ * mln/literal/zero.hh: add 'const' qualification to conversion
+ operator.
+
+ * mln/make/edge_image.hh: update prototype.
+
+ * mln/make/rag_and_labeled_wsl.hh: remove useless local variable.
+
+ * mln/pw/internal/image_base.hh: add missing include.
+
+ * mln/util/vertex.hh: add missing include and forward declaration.
+
+ * tests/util/set.cc: update header.
+
2009-05-06 Frederic Bour <bour(a)lrde.epita.fr>
Correct typo errors, rename storage_ to state, update thrubin morpher.
diff --git a/milena/doc/tutorial/tutorial.tex b/milena/doc/tutorial/tutorial.tex
index b07b170..509a002 100644
--- a/milena/doc/tutorial/tutorial.tex
+++ b/milena/doc/tutorial/tutorial.tex
@@ -1118,7 +1118,7 @@ A list of available site sets is available in section \ref{siteset}.
%--------------------------
-\doxysubsection{Creating a site set}
+\doxysubsection{tuto4createsiteset}{Creating a site set}
In this section, we will detail how to create common site sets.
@@ -1126,7 +1126,7 @@ This is actually simple.
%--------------------------
-\doxysubsection{Getting access to sites}
+\doxysubsection{tuto4accesstosites}{Getting access to sites}
@@ -1137,15 +1137,15 @@ In milena, an image is seen as a composition of both a site set and a function
mapping a site to a value.
%--------------------------
-\doxysubsection{Creating an image}
+\doxysubsection{tuto4createimate}{Creating an image}
In this section, we will detail how to create common images.
%--------------------------
-\doxysubsection{Reading an image from a file}
+\doxysubsection{tuto4readimage}{Reading an image from a file}
%--------------------------
-\doxysubsection{Accessing data}
+\doxysubsection{tuto4accessdata}{Accessing data}
@@ -1224,7 +1224,8 @@ Finally, you may want to save the image. Since we use bool as image value, the
PBM format is the best choice. Therefore, we use io::pbm::save.
\doxycode[4]{tuto2_first_image}
-The output image looks like the following:
+The output image looks like the following: \\
+
\doxyfigure{tuto2_first_image}{3cm}
In this first step we used a boolean image. Many other value types are available
@@ -1262,25 +1263,29 @@ Updating a site value is also possible using \code{operator()} or the
\doxycode[3]{tuto3_rw_image}
\doxycode[4]{tuto3_rw_image}
-The corresponding image:
+The corresponding image: \\
+
\doxyfigure[1]{tuto3_rw_image}{3cm}
An image can also be initialized/modified thanks to another image.
Let's load a new image.
\doxycode[5]{tuto3_rw_image}
-\var{lena} looks like:
+\var{lena} looks like: \\
+
\doxyimg{small-enlarged}{3cm}
If we want to initialize \var{ima} with \var{lena}, we can use \code{data::fill}:
\doxycode[6]{tuto3_rw_image}
-Output:
+Output: \\
+
\doxyfigure[2]{tuto3_rw_image}{3cm}
Note that to fill an image with some data, the image domain \must be smaller
or equal to the data.
Likewise, it is possible to paste data from an image to another:
\doxycode[7]{tuto3_rw_image}
-Output:
+Output: \\
+
\doxyfigure[3]{tuto3_rw_image}{3cm}
More details can be found in sections \doxyref{imaaccessmodval}, \doxyref{fillop} and \doxyref{pasteop} in
diff --git a/milena/mln/core/internal/neighb_niter_impl.hh b/milena/mln/core/internal/neighb_niter_impl.hh
index a21f690..060f574 100644
--- a/milena/mln/core/internal/neighb_niter_impl.hh
+++ b/milena/mln/core/internal/neighb_niter_impl.hh
@@ -44,6 +44,11 @@ namespace mln
template <typename G, typename F> class graph_elt_window;
template <typename G, typename F, typename I> class graph_elt_window_if;
template <typename G, typename F> class line_graph_elt_window;
+ namespace util
+ {
+ template <typename G> class vertex;
+ template <typename G> class edge;
+ }
namespace internal
@@ -56,11 +61,54 @@ namespace mln
};
+ /// Add more implementation for neighborhoods made from
+ /// graph_window_base windows.
+ ///
+ /// FIXME: we need to redeclare the graph element interface.
+ /// Here, a neighb niter iterator encapsulates a window qiter iterator.
+ /// A window qiter iterator is a Proxy on a site P and can convert towards
+ /// a graph element through its member element().
+ ///
+ /// The window qiter iterator cannot have an automatic conversion towards
+ /// a graph element since there would be an ambiguity between this
+ /// conversion and the conversion to a psite P, if P is also a graph
+ /// element.
+ template <typename P, typename E>
+ struct neighb_niter_impl_graph_window
+ {
+ unsigned id() const
+ {
+ return internal::force_exact<E>(*this).compute_p_().id();
+ }
+
+ };
+
+ /// In this case, The site P is a util::vertex which means this iterator
+ /// can automatically converts towards this type.
+ /// There would be an ambiguity between util::vertex members and the one
+ /// declared in neighb_niter_impl_graph_window<P,E> if this
+ /// specialization did not exist.
+ template <typename G, typename E>
+ struct neighb_niter_impl_graph_window< util::vertex<G>, E >
+ {
+ };
+
+ /// In this case, The site P is a util::vertex which means this iterator
+ /// can automatically converts towards this type.
+ /// There would be an ambiguity between util::edge members and the one
+ /// declared in neighb_niter_impl_graph_window<P,E> if this
+ /// specialization did not exist.
+ template <typename G, typename E>
+ struct neighb_niter_impl_graph_window< util::edge<G>, E >
+ {
+ };
+
/// Add more implementation for neighborhoods made from
/// graph_window_base windows.
template <typename P, typename T, typename E>
- struct neighb_niter_impl<graph_window_base<P,T>, E>
+ struct neighb_niter_impl< graph_window_base<P, T>, E >
+ : neighb_niter_impl_graph_window<P,E>
{
typedef typename T::target S;
@@ -69,14 +117,10 @@ namespace mln
return internal::force_exact<E>(*this).compute_p_().element();
}
- unsigned id() const
- {
- return internal::force_exact<E>(*this).compute_p_().id();
- }
-
};
+
/// Add more implementation for neighborhoods made from a
/// graph_window_piter.
template <typename G, typename S, typename E>
diff --git a/milena/mln/fun/v2v/rgb_to_hsl.hh b/milena/mln/fun/v2v/rgb_to_hsl.hh
index a27e80c..7645750 100644
--- a/milena/mln/fun/v2v/rgb_to_hsl.hh
+++ b/milena/mln/fun/v2v/rgb_to_hsl.hh
@@ -69,31 +69,11 @@ namespace mln
extern f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
- template <typename T_rgb>
- struct f_hsl_to_rgb_ : public Function_v2v< f_hsl_to_rgb_<T_rgb> >
- {
- typedef T_rgb result;
-
- template <typename T_hsl>
- T_rgb operator()(const T_hsl& hsl) const;
-
- };
-
- typedef f_hsl_to_rgb_< value::rgb<8> > f_hsl_to_rgb_3x8_t;
- typedef f_hsl_to_rgb_< value::rgb<16> > f_hsl_to_rgb_3x16_t;
-
- extern f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
- extern f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
-
-
# ifndef MLN_INCLUDE_ONLY
/// Global variables.
/// \{
f_rgb_to_hsl_f_t f_rgb_to_hsl_f;
-
- f_hsl_to_rgb_3x8_t f_hsl_to_rgb_3x8;
- f_hsl_to_rgb_3x16_t f_hsl_to_rgb_3x16;
/// \}
@@ -144,42 +124,6 @@ namespace mln
}
- template <typename T_rgb>
- template <typename T_hsl>
- inline
- T_rgb
- f_hsl_to_rgb_<T_rgb>::operator()(const T_hsl& hsl) const
- {
- typedef typename T_rgb::red_t red_t;
- typedef typename T_rgb::green_t green_t;
- typedef typename T_rgb::blue_t blue_t;
-
- static math::round<red_t> to_r;
- static math::round<green_t> to_g;
- static math::round<blue_t> to_b;
-
- static const float
- sqrt3_3 = std::sqrt(3) / 3,
- inv_sqrt6 = 1 / std::sqrt(6),
- inv_sqrt2 = 1 / std::sqrt(2);
-
- float
- h = hsl.hue() / 180.0 * 3.1415,
- alpha = hsl.sat() * std::cos(h),
- beta = hsl.sat() * std::sin(h);
-
-
- red_t r = to_r(sqrt3_3 * hsl.lum() + 2 * inv_sqrt6 * beta);
- green_t g =
- to_g(sqrt3_3 * hsl.lum() + inv_sqrt2 * alpha - inv_sqrt6 * beta);
- blue_t b =
- to_b(sqrt3_3 * hsl.lum() - inv_sqrt2 * alpha - inv_sqrt6 * beta);
-
- T_rgb rgb(r, g, b);
-
- return rgb;
- }
-
# endif // !MLN_INCLUDE_ONLY
} // end of namespace fun::v2v
diff --git a/milena/mln/literal/one.hh b/milena/mln/literal/one.hh
index 8176ce2..68fde6d 100644
--- a/milena/mln/literal/one.hh
+++ b/milena/mln/literal/one.hh
@@ -1,4 +1,5 @@
-// Copyright (C) 2007 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2009 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 +29,9 @@
#ifndef MLN_LITERAL_ONE_HH
# define MLN_LITERAL_ONE_HH
-/*! \file mln/literal/one.hh
- *
- * \brief Definition of the literal of mln::one.
- */
+/// \file mln/literal/one.hh
+///
+/// Definition of the literal of mln::one.
# include <mln/core/concept/literal.hh>
# include <mln/metal/converts_to.hh>
@@ -49,7 +49,7 @@ namespace mln
// FIXME: Cf. comments in literal/zero.hh.
template <typename T>
- operator T () const;
+ operator const T () const;
};
@@ -61,7 +61,7 @@ namespace mln
template <typename T>
inline
- one_t::operator T () const
+ one_t::operator const T () const
{
mlc_converts_to(int, T)::check();
return 1;
diff --git a/milena/mln/literal/zero.hh b/milena/mln/literal/zero.hh
index b6b4e48..62acfbf 100644
--- a/milena/mln/literal/zero.hh
+++ b/milena/mln/literal/zero.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2007, 2008, 2009 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of the Olena Library. This library is free
@@ -51,7 +51,7 @@ namespace mln
// FIXME: (for the record) Add "friend class Literal<zero_t>;" and a protected ctor.
template <typename T>
- operator T () const;
+ operator const T () const;
};
/// Literal zero.
@@ -61,7 +61,7 @@ namespace mln
template <typename T>
inline
- zero_t::operator T () const
+ zero_t::operator const T () const
{
mlc_converts_to(int, T)::check();
return 0;
diff --git a/milena/mln/make/edge_image.hh b/milena/mln/make/edge_image.hh
index d4510c1..bd03162 100644
--- a/milena/mln/make/edge_image.hh
+++ b/milena/mln/make/edge_image.hh
@@ -94,16 +94,15 @@ namespace mln
/// Construct an edge image.
///
/// \param[in] v_ima_ A vertex image.
- /// \param[in] pe A p_edges mapping graph element to themselves.
/// \param[in] fv A function mapping two vertex ids to a value.
/// The result is associated to the corresponding edge.
///
- /// \return an edge image.
+ /// \return an edge image without localization information mapped to
+ /// graph elements.
//
template <typename P, typename V, typename G, typename FV>
mln::edge_image<void,mln_result(FV),G>
edge_image(const vertex_image<P,V,G>& v_ima_,
- const p_edges<G,util::internal::id2element<G,util::edge<G> > > pe,
const Function_vv2v<FV>& fv_);
@@ -174,7 +173,6 @@ namespace mln
template <typename P, typename V, typename G, typename FV>
mln::edge_image<void,mln_result(FV),G>
edge_image(const vertex_image<P,V,G>& v_ima_,
- const p_edges<G,util::internal::id2element<G,util::edge<G> > > pe,
const Function_vv2v<FV>& fv_)
{
trace::entering("make::edge_image");
@@ -183,12 +181,13 @@ namespace mln
const vertex_image<P,V,G>& v_ima = exact(v_ima_);
mln_precondition(v_ima.is_valid());
+ p_edges<G> pe(v_ima.graph());
typedef mln::edge_image<void,mln_result(FV),G> edge_ima_t;
edge_ima_t ima_e(pe);
mln_piter(edge_ima_t) e(ima_e.domain());
for_all(e)
- ima_e(e) = fv(e.element().v1(), e.element().v2());
+ ima_e(e) = fv(v_ima(e.element().v1()), v_ima(e.element().v2()));
trace::exiting("make::edge_image");
return ima_e;
diff --git a/milena/mln/make/rag_and_labeled_wsl.hh b/milena/mln/make/rag_and_labeled_wsl.hh
index 774c78a..60f2824 100644
--- a/milena/mln/make/rag_and_labeled_wsl.hh
+++ b/milena/mln/make/rag_and_labeled_wsl.hh
@@ -140,8 +140,6 @@ namespace mln
const N& nbh = exact(nbh_);
typedef mln_value(I) L;
- mln::image2d<bool> adj(mln::box2d(nbasins.next(), nbasins.next()));
- data::fill(adj, false);
extension::adjust_fill(wshd, nbh, 0u);
mln_concrete(I) output(wshd.domain());
diff --git a/milena/mln/pw/internal/image_base.hh b/milena/mln/pw/internal/image_base.hh
index b6571b9..d1dd608 100644
--- a/milena/mln/pw/internal/image_base.hh
+++ b/milena/mln/pw/internal/image_base.hh
@@ -33,6 +33,7 @@
/// Definition of the common base class for all point-wise images.
# include <mln/core/internal/image_primary.hh>
+# include <mln/core/routine/init.hh>
# include <mln/metal/unqualif.hh>
# include <mln/metal/not_equal.hh>
# include <mln/value/set.hh>
diff --git a/milena/mln/util/vertex.hh b/milena/mln/util/vertex.hh
index 0cde7a1..4f0c5ad 100644
--- a/milena/mln/util/vertex.hh
+++ b/milena/mln/util/vertex.hh
@@ -35,6 +35,7 @@
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/site.hh>
# include <mln/util/graph_ids.hh>
+# include <mln/util/edge.hh>
/// \file mln/util/vertex.hh
///
@@ -47,6 +48,7 @@ namespace mln
// Forward declaration.
namespace util { template<typename G> class vertex; }
+ namespace util { template<typename G> class edge; }
/// Vertex category flag type.
template <typename E>
diff --git a/milena/tests/util/set.cc b/milena/tests/util/set.cc
index f97449f..988a397 100644
--- a/milena/tests/util/set.cc
+++ b/milena/tests/util/set.cc
@@ -1,4 +1,5 @@
// Copyright (C) 2008, 2009 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
--
1.5.6.5
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-05 Fabien Freling <fabien.freling(a)lrde.epita.fr>
Update inter_pixel files to match coding style.
* mln/world/inter_pixel/full.hh: Move this...
* mln/world/inter_pixel/full2image.hh: ...here...
* mln/world/inter_pixel/image2full.hh: ...and here.
* mln/world/inter_pixel/neighb2d.hh: Update to match coding style.
---
full2image.hh | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
image2full.hh | 74 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
neighb2d.hh | 9 ++++++
3 files changed, 158 insertions(+)
Index: trunk/milena/mln/world/inter_pixel/full.hh (deleted)
===================================================================
Index: trunk/milena/mln/world/inter_pixel/neighb2d.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 3755)
+++ trunk/milena/mln/world/inter_pixel/neighb2d.hh (revision 3756)
@@ -47,6 +47,12 @@
typedef neighb< win::multiple<window2d, dim2::is_row_odd> > dbl_neighb2d;
+ const dbl_neighb2d& e2c();
+ const dbl_neighb2d& e2e();
+
+
+# ifndef MLN_INCLUDE_ONLY
+
const dbl_neighb2d& e2c()
{
static bool e2c_h[] = { 0, 1, 0,
@@ -75,6 +81,9 @@
return nbh;
}
+# endif // ! MLN_INCLUDE_ONLY
+
+
} // end of namespace mln::world::inter_pixel
} // end of namespace mln::world
Index: trunk/milena/mln/world/inter_pixel/full2image.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/full2image.hh (revision 0)
+++ trunk/milena/mln/world/inter_pixel/full2image.hh (revision 3756)
@@ -0,0 +1,75 @@
+// Copyright (C) 2009 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_WORLD_INTER_PIXEL_FULL_HH
+# define MLN_WORLD_INTER_PIXEL_FULL_HH
+
+/// \file mln/world/inter_pixel/full.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/image/image2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ template <typename T>
+ image2d<T>
+ full2image(const image2d<T>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ image2d<T>
+ full2image(const image2d<T>& input)
+ {
+ image2d<T> output((input.nrows() + 1) / 2,
+ (input.ncols() + 1) / 2);
+ for (int row = 0; row < input.nrows(); row += 2)
+ for (int col = 0; col < input.ncols(); col += 2)
+ opt::at(output, row / 2, col / 2) =
+ opt::at(input, row, col);
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_FULL
Index: trunk/milena/mln/world/inter_pixel/image2full.hh
===================================================================
--- trunk/milena/mln/world/inter_pixel/image2full.hh (revision 0)
+++ trunk/milena/mln/world/inter_pixel/image2full.hh (revision 3756)
@@ -0,0 +1,74 @@
+// Copyright (C) 2009 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_WORLD_INTER_PIXEL_FULL_HH
+# define MLN_WORLD_INTER_PIXEL_FULL_HH
+
+/// \file mln/world/inter_pixel/full.hh
+///
+/// FIXME: insert comment.
+
+# include <mln/core/image/image2d.hh>
+
+namespace mln
+{
+
+ namespace world
+ {
+
+ namespace inter_pixel
+ {
+
+ template <typename T>
+ image2d<T>
+ image2full(const image2d<T>& input);
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ template <typename T>
+ image2d<T>
+ image2full(const image2d<T>& input)
+ {
+ image2d<T> output(2 * input.nrows() - 1,
+ 2 * input.ncols() - 1);
+ for (int row = 0; row < input.nrows(); ++row)
+ for (int col = 0; col < input.ncols(); ++col)
+ opt::at(output, 2 * row, 2 * col) = opt::at(input, row, col);
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+
+ } // end of namespace mln::world::inter_pixel
+
+ } // end of namespace mln::world
+
+} // end of namespace mln
+
+#endif // ! MLN_WORLD_INTER_PIXEL_FULL
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2009-05-05 Frederic Bour <bour(a)lrde.epita.fr>
Tidy source code of new functions, renamed trait::fun to trait::function.
* mln/core/image/thru_morpher.hh,
* mln/core/image/thrubin_morpher.hh,
* mln/fun/accu_result.hh,
* mln/fun/binary.hh: tidied.
* mln/fun/component/comp.hh: Splitted into multiples files:
* mln/fun/component/comp_count.hh: New,
* mln/fun/component/ithcomp.hh: New,
* mln/fun/component/scomp.hh: New. Static i'th component extraction.
* mln/fun/math/cos.hh,
* mln/fun/math/inf.hh,
* mln/fun/math/sup.hh,
* mln/fun/point/col.hh,
* mln/fun/point/row.hh,
* mln/fun/point/sli.hh,
* mln/fun/spe/binary.hh,
* mln/fun/spe/unary.hh,
* mln/fun/unary.hh: tidied.
* mln/trait/fun.hh: Removed. Renamed to:
* mln/trait/functions.hh: New.
* sandbox/fred/tests/fun.cc: Small update.
---
mln/core/image/thru_morpher.hh | 4
mln/core/image/thrubin_morpher.hh | 2
mln/fun/accu_result.hh | 18 +-
mln/fun/binary.hh | 4
mln/fun/component/comp.hh | 75 -----------
mln/fun/component/comp_count.hh | 99 ++++++++++++++
mln/fun/component/ithcomp.hh | 83 ++++++++++++
mln/fun/component/scomp.hh | 90 +++++++++++++
mln/fun/math/cos.hh | 6
mln/fun/math/inf.hh | 6
mln/fun/math/sup.hh | 6
mln/fun/point/col.hh | 8 -
mln/fun/point/row.hh | 4
mln/fun/spe/binary.hh | 4
mln/fun/spe/unary.hh | 4
mln/fun/unary.hh | 2
mln/trait/functions.hh | 253 ++++++++++++++++++++++++++++++++++++++
sandbox/fred/tests/fun.cc | 17 +-
18 files changed, 578 insertions(+), 107 deletions(-)
Index: trunk/milena/mln/trait/fun.hh (deleted)
===================================================================
Index: trunk/milena/mln/trait/functions.hh
===================================================================
--- trunk/milena/mln/trait/functions.hh (revision 0)
+++ trunk/milena/mln/trait/functions.hh (revision 3754)
@@ -0,0 +1,253 @@
+// 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
+// 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 F 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_TRAIT_FUNCTIONS_HH
+# define MLN_TRAIT_FUNCTIONS_HH
+
+# include <mln/metal/bexpr.hh>
+# include <mln/metal/if.hh>
+# include <mln/fun/param.hh>
+# include <mln/trait/next/solve.hh>
+
+# define mln_trait_fun_is_assignable(Fun) typename mln::trait::function::is_assignable< Fun >::ret
+# define mln_trait_fun_is_assignable_(Fun) mln::trait::function::is_assignable< Fun >::ret
+# define mln_trait_fun_is_assignable__1comma(A, B) typename mln::trait::function::is_assignable< A, B >::ret
+# define mln_trait_fun_is_assignable__1comma_(A, B) mln::trait::function::is_assignable< A, B >::ret
+
+# define mln_trait_fun_is_parametrable(Fun) typename mln::trait::function::is_parametrable< Fun >::ret
+# define mln_trait_fun_is_parametrable_(Fun) mln::trait::function::is_parametrable< Fun >::ret
+
+# define mln_trait_fun_lvalue(Fun) typename mln::trait::function::get_lvalue< Fun >::ret
+# define mln_trait_fun_param(Fun) typename mln::trait::function::get_param< Fun >::ret
+# define mln_trait_fun_storage(Fun) typename mln::trait::function::get_storage< Fun >::ret
+
+namespace mln
+{
+
+ namespace trait
+ {
+
+ namespace function
+ {
+
+ namespace internal
+ {
+
+ namespace introspect
+ {
+
+ template <typename T>
+ struct except_void_t
+ {
+ typedef void ret;
+ };
+
+ template <>
+ struct except_void_t<void>;
+
+ // Lvalue solver
+
+ template <typename T, typename V>
+ struct has_lvalue_t
+ {
+ typedef metal::false_ ret;
+ typedef void type;
+ };
+
+ template <typename T>
+ struct has_lvalue_t<T, typename except_void_t<typename T::lvalue>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename T::lvalue type;
+ };
+
+ // Parameter solver
+ template <typename T, typename V>
+ struct param_solver;
+
+ template <typename T, typename V>
+ struct param_flag_solver
+ {
+ typedef typename mln::fun::parameter<T> ret;
+ };
+
+ template <typename T>
+ struct param_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::param>::ret>
+ {
+ typedef mln::fun::parameter<typename T::flag> ret;
+ };
+
+ template <typename T, typename V>
+ struct param_def_solver
+ {
+ typedef typename param_flag_solver<T, V>::ret ret;
+ };
+
+ template <typename T>
+ struct param_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::param>::ret>
+ {
+ typedef mln::fun::parameter<typename T::def> ret;
+ };
+
+ template <typename T, typename V>
+ struct param_solver : param_def_solver<T, V>
+ {
+ };
+
+ template <typename T>
+ struct param_solver<T, typename except_void_t<typename T::param>::ret>
+ {
+ typedef T ret;
+ };
+
+ template <typename T, typename V>
+ struct has_param_t
+ {
+ typedef metal::false_ ret;
+ typedef void type;
+ };
+
+ template <typename T>
+ struct has_param_t<T, typename except_void_t<typename param_solver<T,void>::ret::param>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename param_solver<T,void>::ret::param type;
+ };
+
+ template <typename T, typename V>
+ struct storage_solver;
+
+ template <typename T, typename V>
+ struct storage_flag_solver
+ {
+ typedef typename mln::fun::parameter<T> ret;
+ };
+
+ template <typename T>
+ struct storage_flag_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::flag>::storage>::ret>
+ {
+ typedef mln::fun::parameter<typename T::flag> ret;
+ };
+
+ template <typename T, typename V>
+ struct storage_def_solver
+ {
+ typedef typename storage_flag_solver<T, V>::ret ret;
+ };
+
+ template <typename T>
+ struct storage_def_solver<T, typename except_void_t<typename mln::fun::parameter<typename T::def>::storage>::ret>
+ {
+ typedef mln::fun::parameter<typename T::def> ret;
+ };
+
+ template <typename T, typename V>
+ struct storage_solver : storage_def_solver<T, V>
+ {
+ };
+
+ template <typename T>
+ struct storage_solver<T, typename except_void_t<typename T::storage>::ret>
+ {
+ typedef T ret;
+ };
+
+ template <typename T, typename V>
+ struct has_storage_t
+ {
+ typedef has_param_t<T, V> has_param;
+
+ typedef metal::false_ ret;
+ typedef typename has_param::type type;
+
+ template <typename U>
+ static inline
+ const U& compute(const U& t)
+ {
+ return t;
+ }
+
+ };
+
+ template <typename T>
+ struct has_storage_t<T, typename except_void_t<typename param_solver<T,void>::ret::storage>::ret>
+ {
+ typedef metal::true_ ret;
+ typedef typename param_solver<T,void>::ret def;
+
+ typedef typename def::storage type;
+
+ template <typename U>
+ static inline
+ type compute(const U& p)
+ {
+ return def::compute(p);
+ };
+
+ };
+
+ } // end of namespace mln::trait::fun::internal::introspect
+
+ } // end of namespace mln::trait::fun::internal
+
+ template <typename F>
+ struct is_assignable
+ {
+ typedef typename internal::introspect::has_lvalue_t<F, void>::ret ret;
+ };
+
+ template <typename F>
+ struct is_parametrable
+ {
+ typedef typename internal::introspect::has_param_t<F, void>::ret ret;
+ };
+
+ template <typename F>
+ struct get_lvalue
+ {
+ typedef typename internal::introspect::has_lvalue_t<F, void>::type ret;
+ };
+
+ template <typename F>
+ struct get_param
+ {
+ typedef typename internal::introspect::has_param_t<F, void>::type ret;
+ };
+
+ template <typename F>
+ struct get_storage
+ {
+ typedef typename internal::introspect::has_storage_t<F, void>::type ret;
+ };
+
+ } // end of namespace mln::trait::fun
+
+ } // end of namespace mln::trait
+
+} // end of namespace mln
+
+#endif // ! MLN_TRAIT_FUN_HH
Index: trunk/milena/mln/core/image/thru_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thru_morpher.hh (revision 3753)
+++ trunk/milena/mln/core/image/thru_morpher.hh (revision 3754)
@@ -32,7 +32,7 @@
# include <mln/core/internal/image_value_morpher.hh>
# include <mln/core/concept/meta_function.hh>
# include <mln/metal/bexpr.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
///
/// \file mln/core/image/thru_morpher.hh
@@ -58,7 +58,7 @@
{
typedef thru_image_write<I, F> write;
typedef thru_image_read<I, F> read;
- typedef mlc_if(mlc_and(typename trait::fun::is_assignable<F>::ret,
+ typedef mlc_if(mlc_and(mln_trait_fun_is_assignable(F),
mlc_and(mlc_not(mlc_is_const(I)),
mlc_equal(mln_trait_image_pw_io(I),
trait::image::pw_io::read_write))),
Index: trunk/milena/mln/core/image/thrubin_morpher.hh
===================================================================
--- trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3753)
+++ trunk/milena/mln/core/image/thrubin_morpher.hh (revision 3754)
@@ -32,7 +32,7 @@
# include <mln/core/internal/image_value_morpher.hh>
# include <mln/core/concept/meta_function.hh>
# include <mln/metal/bexpr.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
/// \file mln/core/image/thrubin_morpher.hh
///
Index: trunk/milena/mln/fun/spe/binary.hh
===================================================================
--- trunk/milena/mln/fun/spe/binary.hh (revision 3753)
+++ trunk/milena/mln/fun/spe/binary.hh (revision 3754)
@@ -30,7 +30,7 @@
# include <mln/core/concept/function.hh>
# include <mln/trait/next/solve.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
/// \todo Implements parameter support
@@ -99,7 +99,7 @@
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value);
+ storage_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
}
protected:
Index: trunk/milena/mln/fun/spe/unary.hh
===================================================================
--- trunk/milena/mln/fun/spe/unary.hh (revision 3753)
+++ trunk/milena/mln/fun/spe/unary.hh (revision 3754)
@@ -30,7 +30,7 @@
# include <mln/core/concept/function.hh>
# include <mln/trait/next/solve.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
namespace mln
{
@@ -239,7 +239,7 @@
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::fun::internal::introspect::has_storage_t<def, void>::compute(value);
+ storage_ = mln::trait::function::internal::introspect::has_storage_t<def, void>::compute(value);
};
protected:
Index: trunk/milena/mln/fun/point/row.hh
===================================================================
--- trunk/milena/mln/fun/point/row.hh (revision 3753)
+++ trunk/milena/mln/fun/point/row.hh (revision 3754)
@@ -55,10 +55,10 @@
{
template <typename G, typename C>
- struct set_precise_unary_<mln::fun::row, mln::point<G,C> >
+ struct set_precise_unary_<fun::row, point<G,C> >
{
typedef set_precise_unary_ ret;
- typedef mln::point<G,C> argument;
+ typedef point<G,C> argument;
typedef typename argument::coord result;
typedef argument& lvalue;
Index: trunk/milena/mln/fun/point/col.hh
===================================================================
--- trunk/milena/mln/fun/point/col.hh (revision 3753)
+++ trunk/milena/mln/fun/point/col.hh (revision 3754)
@@ -42,7 +42,9 @@
namespace fun
{
- struct col : unary<col> {};
+ struct col : unary<col>
+ {
+ };
} // end of namespace mln::fun
@@ -55,10 +57,10 @@
{
template <typename G, typename C>
- struct set_precise_unary_<mln::fun::col, mln::point<G, C> >
+ struct set_precise_unary_<fun::col, point<G, C> >
{
typedef set_precise_unary_ ret;
- typedef mln::point<G,C> argument;
+ typedef point<G,C> argument;
typedef typename argument::coord result;
typedef argument& lvalue;
Index: trunk/milena/mln/fun/math/cos.hh
===================================================================
--- trunk/milena/mln/fun/math/cos.hh (revision 3753)
+++ trunk/milena/mln/fun/math/cos.hh (revision 3754)
@@ -82,10 +82,10 @@
};
- }
+ } // end of namespace mln::trait::next
- }
+ } // end of namespace mln
-}
+} // end of namespace mln
#endif /* ! MLN_FUN_MATH_COS_HH */
\ No newline at end of file
Index: trunk/milena/mln/fun/math/sup.hh
===================================================================
--- trunk/milena/mln/fun/math/sup.hh (revision 3753)
+++ trunk/milena/mln/fun/math/sup.hh (revision 3754)
@@ -60,11 +60,11 @@
}
};
- }
+ } // end of namespace mln::trait::next
- }
+ } // end of namespace mln::trait
-}
+} // end of namespace mln
#endif /* ! MLN_FUN_MATH_SUP_HH */
Index: trunk/milena/mln/fun/math/inf.hh
===================================================================
--- trunk/milena/mln/fun/math/inf.hh (revision 3753)
+++ trunk/milena/mln/fun/math/inf.hh (revision 3754)
@@ -60,11 +60,11 @@
}
};
- }
+ } // end of namespace mln::trait::next
- }
+ } // end of namespace mln::trait
-}
+} // end of namespace mln
#endif /* ! MLN_FUN_MATH_INF_HH */
Index: trunk/milena/mln/fun/unary.hh
===================================================================
--- trunk/milena/mln/fun/unary.hh (revision 3753)
+++ trunk/milena/mln/fun/unary.hh (revision 3754)
@@ -83,7 +83,7 @@
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value);
+ storage_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value);
};
unary()
Index: trunk/milena/mln/fun/binary.hh
===================================================================
--- trunk/milena/mln/fun/binary.hh (revision 3753)
+++ trunk/milena/mln/fun/binary.hh (revision 3754)
@@ -31,7 +31,7 @@
# include <mln/core/concept/meta_function.hh>
# include <mln/fun/spe/binary.hh>
# include <mln/trait/next/solve.hh>
-# include <mln/trait/fun.hh>
+# include <mln/trait/functions.hh>
namespace mln
{
@@ -60,7 +60,7 @@
template <typename U>
void init(const U& value)
{
- storage_ = mln::trait::fun::internal::introspect::has_storage_t<flag, void>::compute(value);
+ storage_ = mln::trait::function::internal::introspect::has_storage_t<flag, void>::compute(value);
};
binary()
Index: trunk/milena/mln/fun/component/scomp.hh
===================================================================
--- trunk/milena/mln/fun/component/scomp.hh (revision 0)
+++ trunk/milena/mln/fun/component/scomp.hh (revision 3754)
@@ -0,0 +1,90 @@
+// Copyright (C) 2007, 2008, 2009 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_COMPONENT_SCOMP_HH
+# define MLN_FUN_COMPONENT_SCOMP_HH
+
+/// \file mln/fun/component/scomp.hh
+///
+/// Meta function to retrieve/modify the i'th component, where i is
+/// statically defined.
+
+# include <mln/fun/unary.hh>
+# include <mln/fun/component/comp.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ template <unsigned ith>
+ struct scomp : unary< scomp<ith> >
+ {
+ };
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned ith, typename T>
+ struct set_unary_<fun::scomp<ith>, mln::Object, T>
+ {
+ typedef set_unary_ ret;
+ typedef mln_trait_nunary(fun::comp, T) comp_t;
+
+ typedef T argument;
+ typedef mln_result(comp_t) result;
+ typedef mln_lvalue(comp_t) lvalue;
+
+ static result read(const argument& v)
+ {
+ return comp_t::read(ith, v);
+ }
+
+ static void write(lvalue l, const result& r)
+ {
+ comp_t::write(ith, l, r);
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_COMP_HH
Index: trunk/milena/mln/fun/component/ithcomp.hh
===================================================================
--- trunk/milena/mln/fun/component/ithcomp.hh (revision 0)
+++ trunk/milena/mln/fun/component/ithcomp.hh (revision 3754)
@@ -0,0 +1,83 @@
+// Copyright (C) 2007, 2008, 2009 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_COMPONENT_ITHCOMP_HH
+# define MLN_FUN_COMPONENT_ITHCOMP_HH
+
+/// \file mln/fun/component/ithcomp.hh
+///
+/// Meta function to retrieve/modify the i'th component with a binary
+/// function f(i, vec).
+
+# include <mln/fun/binary.hh>
+# include <mln/fun/component/comp.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct ithcomp : binary<ithcomp>
+ {
+ };
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <typename I, typename T>
+ struct set_binary_<mln::fun::ithcomp, mln::value::Integer, I, mln::Object, T>
+ {
+ typedef set_binary_ ret;
+ typedef I argument1;
+ typedef T argument2;
+ typedef mln_trait_nunary(mln::fun::comp, T) comp_t;
+ typedef mln_result(comp_t) result;
+
+ static result read(const argument1& i, const argument2& v)
+ {
+ return comp_t::read(i, v);
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_ITHCOMP_HH
Index: trunk/milena/mln/fun/component/comp_count.hh
===================================================================
--- trunk/milena/mln/fun/component/comp_count.hh (revision 0)
+++ trunk/milena/mln/fun/component/comp_count.hh (revision 3754)
@@ -0,0 +1,99 @@
+// Copyright (C) 2007, 2008, 2009 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_COMPONENT_COMP_COUNT_HH
+# define MLN_FUN_COMPONENT_COMP_COUNT_HH
+
+/// \file mln/fun/component/comp_count.hh
+///
+/// Meta function to retrieve the number of components a vector has.
+
+# include <mln/fun/unary.hh>
+# include <mln/value/rgb.hh>
+# include <mln/value/int_u.hh>
+# include <mln/algebra/vec.hh>
+
+namespace mln
+{
+
+ namespace fun
+ {
+
+ struct comp_count : unary<comp_count>
+ {
+ };
+
+ } // end of namespace mln::fun
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace trait
+ {
+
+ namespace next
+ {
+
+ template <unsigned n>
+ struct set_precise_unary_<mln::fun::comp_count, mln::value::rgb<n> >
+ {
+ typedef set_precise_unary_ ret;
+
+ typedef mln::value::rgb<n> argument;
+ typedef unsigned result;
+ typedef argument& lvalue;
+
+ static result read(const argument&)
+ {
+ return 3;
+ }
+ };
+
+ template <unsigned n, typename T>
+ struct set_precise_unary_<mln::fun::comp_count, mln::algebra::vec<n,T> >
+ {
+ typedef set_precise_unary_ ret;
+
+ typedef mln::algebra::vec<n,T> argument;
+ typedef unsigned result;
+ typedef argument& lvalue;
+
+ static result read(const argument&)
+ {
+ return n;
+ }
+ };
+
+ } // end of namespace mln::trait::next
+
+ } // end of namespace mln::trait
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+#endif // MLN_FUN_COMPONENT_COMP_COUNT_HH
Index: trunk/milena/mln/fun/component/comp.hh
===================================================================
--- trunk/milena/mln/fun/component/comp.hh (revision 3753)
+++ trunk/milena/mln/fun/component/comp.hh (revision 3754)
@@ -33,10 +33,7 @@
///
/// Meta function to retrieve/modify a component.
-# include <mln/fun/unary.hh>
-# include <mln/fun/binary.hh>
-# include <mln/fun/param.hh>
-# include <mln/trait/next/solve.hh>
+# include <mln/fun/unary_param.hh>
# include <mln/value/rgb.hh>
# include <mln/value/int_u.hh>
# include <mln/algebra/vec.hh>
@@ -47,24 +44,12 @@
namespace fun
{
- struct comp : binary<comp> {};
-
- struct pcomp;
-
- template <>
- struct parameter<pcomp>
- {
- typedef unsigned param;
- };
-
- struct pcomp : unary<pcomp>
+ struct comp : unary_param<comp,unsigned>
{
- pcomp() : unary<pcomp>(0) {};
- pcomp(unsigned i = 0) : unary<pcomp>(i) {};
+ comp() : unary_param<comp,unsigned>(0) {};
+ comp(unsigned i) : unary_param<comp,unsigned>(i) {};
};
- struct comp_count : unary<comp_count> {};
-
} // end of namespace mln::fun
# ifndef MLN_INCLUDE_ONLY
@@ -75,57 +60,10 @@
namespace next
{
- template <typename E, typename T>
- struct set_binary_<mln::fun::comp, mln::value::Integer, E, mln::Object, T>
- {
- typedef set_binary_ ret;
- typedef E argument1;
- typedef T argument2;
- typedef mln_trait_nunary(mln::fun::pcomp, T) pcomp_t;
- typedef mln_result(pcomp_t) result;
-
- static result read(const argument1& i, const argument2& v)
- {
- pcomp_t c;
- return c.read(i, v);
- }
- };
-
- template <unsigned n>
- struct set_precise_unary_<mln::fun::comp_count, mln::value::rgb<n> >
- {
- typedef set_precise_unary_ ret;
-
- typedef mln::value::rgb<n> argument;
- typedef unsigned result;
- typedef argument& lvalue;
-
- static result read(const argument&)
- {
- return n;
- }
- };
-
- template <unsigned n, typename T>
- struct set_precise_unary_<mln::fun::comp_count, mln::algebra::vec<n,T> >
- {
- typedef set_precise_unary_ ret;
-
- typedef mln::algebra::vec<n,T> argument;
- typedef unsigned result;
- typedef argument& lvalue;
-
- static result read(const argument&)
- {
- return n;
- }
- };
-
template <unsigned n>
- struct set_precise_unary_<mln::fun::pcomp, mln::value::rgb<n> >
+ struct set_precise_unary_<mln::fun::comp, mln::value::rgb<n> >
{
typedef set_precise_unary_ ret;
-// typedef mln::fun::pcomp flag;
typedef mln::value::rgb<n> argument;
typedef mln::value::int_u<n> result;
@@ -143,10 +81,9 @@
};
template <unsigned n, typename T>
- struct set_precise_unary_<mln::fun::pcomp, mln::algebra::vec<n,T> >
+ struct set_precise_unary_<mln::fun::comp, mln::algebra::vec<n,T> >
{
typedef set_precise_unary_ ret;
- typedef mln::fun::pcomp flag;
typedef mln::algebra::vec<n,T> argument;
typedef T result;
Index: trunk/milena/mln/fun/accu_result.hh
===================================================================
--- trunk/milena/mln/fun/accu_result.hh (revision 3753)
+++ trunk/milena/mln/fun/accu_result.hh (revision 3754)
@@ -30,8 +30,6 @@
# include <mln/fun/unary.hh>
# include <mln/core/concept/accumulator.hh>
-# include <mln/math/acos.hh>
-# include <mln/math/cos.hh>
namespace mln
{
@@ -39,8 +37,12 @@
// accu_result: return result of given accumulator.
namespace fun
{
- struct accu_result : unary<accu_result> {};
- }
+
+ struct accu_result : unary<accu_result>
+ {
+ };
+
+ } // end of namespace mln::fun
namespace trait
{
@@ -48,7 +50,7 @@
namespace next
{
template <typename E>
- struct set_unary_<mln::fun::accu_result, mln::Accumulator, E>
+ struct set_unary_<fun::accu_result, Accumulator, E>
{
typedef set_unary_ ret;
typedef typename E::result result;
@@ -60,10 +62,10 @@
}
};
- }
+ } // end of namespace mln::trait::next
- }
+ } // end of namespace mln::trait
-}
+} // end of namespace mln
#endif /* ! MLN_FUN_ACCU_RESULT_HH */
\ No newline at end of file
Index: trunk/milena/sandbox/fred/tests/fun.cc
===================================================================
--- trunk/milena/sandbox/fred/tests/fun.cc (revision 3753)
+++ trunk/milena/sandbox/fred/tests/fun.cc (revision 3754)
@@ -4,19 +4,23 @@
#include <mln/fun/math/norm.hh>
#include <mln/fun/component/red.hh>
#include <mln/fun/component/comp.hh>
+#include <mln/fun/component/ithcomp.hh>
+#include <mln/fun/component/scomp.hh>
#include <mln/value/rgb8.hh>
#include <iostream>
#define dbg_print(val) std::cout << #val << "\n\t -> \t" << (val) << std::endl
+
int main()
{
mln::fun::abs abs;
mln::fun::cos cos;
// mln::fun::inc inc;
mln::fun::red red;
- mln::fun::comp comp;
- mln::fun::pcomp comp1(1);
+ mln::fun::ithcomp ithcomp;
+ mln::fun::comp comp(1);
+ mln::fun::scomp<1> comp1;
mln::fun::norm::l1 l1;
mln::fun::norm::l2 l2;
@@ -86,10 +90,11 @@
dbg_print(red(rgb) = 0);
mln_invariant(red(rgb) == 0);
dbg_print(rgb);
- dbg_print(comp(0, rgb));
- dbg_print(comp(1, rgb));
- dbg_print(comp(2, rgb));
- comp1(rgb) = 2;
+ dbg_print(ithcomp(0, rgb));
+ dbg_print(ithcomp(1, rgb));
+ dbg_print(ithcomp(2, rgb));
+ dbg_print(comp1(rgb) = 2);
+ dbg_print(comp(rgb));
}
// NORM