https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Add some documentation about site set properties.
* mln/trait/site_set/props.hh: Add some doc.
* mln/trait/site_sets.hh: Likewise.
site_set/props.hh | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++----
site_sets.hh | 21 ++++++++++++
2 files changed, 103 insertions(+), 6 deletions(-)
Index: mln/trait/site_set/props.hh
--- mln/trait/site_set/props.hh (revision 2007)
+++ mln/trait/site_set/props.hh (working copy)
@@ -37,6 +37,43 @@
# include <mln/trait/undef.hh>
+
+// Properties of site sets.
+// ========================
+
+// nsites: /any/
+// |
+// + -- unknown
+// |
+// + -- known
+
+// bbox: /any/
+// |
+// + -- unknown
+// |
+// + -- /known/
+// |
+// + -- lazy
+// |
+// + -- straight
+
+// contents: /any/
+// |
+// + -- fixed
+// |
+// + -- /dynamic/
+// |
+// + -- growing
+// |
+// + -- free
+
+// arity: /any/
+// |
+// + -- unique
+// |
+// + -- multiple
+
+
namespace mln
{
@@ -46,34 +83,73 @@
namespace site_set
{
+
+ /// Site set property about the 'nsites' method presence.
struct nsites
{
- struct any {};
+ /// Base class for the site set 'nsites' property.
+ struct any { protected: any() {} };
+
+ /// Property that states that the number of sites cannot be
+ /// retrieved from a site set in O(1) complexity so the site
+ /// set does not feature the 'nsites' methods.
struct unknown : any { std::string name() const { return "nsites::unknown"; } };
+
+ /// Property that states that a site set features the method
+ /// 'nsites' because the number of sites is known so its
+ /// retrieval has O(1) complexity.
struct known : any { std::string name() const { return "nsites::known"; } };
};
+
+ /// Site set property about the 'bbox' method presence.
struct bbox
{
- struct any {};
+ /// Base class for the site set 'bbox' property.
+ struct any { protected: any() {} };
+
+ /// Property that states that the bounding box of a site set
+ /// is not featured as a method. This is either because the
+ /// notion of bounding box is meaningless for the site set
+ /// type, or because the bounding box cannot be retrieved in
+ /// O(1) complexity.
struct unknown : any { std::string name() const { return "bbox::unknown"; } };
- struct known : any {};
+
+ /// Property that states that the bounding box of a site set
+ /// is featured by the 'bbox' method. It means that the
+ /// notion of bounding box makes sense and that such a piece
+ /// of information can be retrieved in O(1) complexity.
+ /// Warning: this property is pseudo-abstract. The more
+ /// precise properties are 'lazy' and 'straight'.
+ struct known : any { protected: known() {} };
+
+ /// Property that states that the bounding box of a site set
+ /// is computed by the site set in a lazy way.
struct lazy : known { std::string name() const { return "bbox::lazy"; } };
+
+ /// Property that states that the bounding box of a site set
+ /// is always kept up to date by the site set.
struct straight : known { std::string name() const { return "bbox::straight"; } };
};
+
+ /// Site set property about how the contents can evolve.
struct contents
{
- struct any {};
+ /// Base class for the site set 'contents' property.
+ struct any { protected: any() {} };
struct fixed : any { std::string name() const { return "contents::fixed"; } };
- struct dynamic : any {};
+ struct dynamic : any { protected: dynamic() {} };
struct growing : dynamic { std::string name() const { return "contents::growing"; } };
struct free : dynamic { std::string name() const { return "contents::dynamic"; } };
};
+ /// Site set property about the unicity or multiplicity of its
+ /// elements.
struct arity
{
- struct any {};
+ /// Base class for the site set 'arity' property.
+ struct any { protected: any() {} };
struct unique : any { std::string name() const { return "arity::unique"; } };
struct multiple : any { std::string name() const { return "arity::multiple"; } };
};
Index: mln/trait/site_sets.hh
--- mln/trait/site_sets.hh (revision 2007)
+++ mln/trait/site_sets.hh (working copy)
@@ -37,9 +37,20 @@
# include <mln/trait/site_set/props.hh>
+/// Shortcut to the site set property about the 'nsites' method
+/// presence.
# define mln_trait_site_set_nsites(S) typename mln::trait::site_set_< S >::nsites
+
+/// Shortcut to the site set property about the 'bbox' method
+/// presence.
# define mln_trait_site_set_bbox(S) typename mln::trait::site_set_< S >::bbox
+
+/// Shortcut to the site set property about how the contents can
+/// evolve.
# define mln_trait_site_set_contents(S) typename mln::trait::site_set_< S >::contents
+
+/// Shortcut to the site set property about the unicity or
+/// multiplicity of its elements.
# define mln_trait_site_set_arity(S) typename mln::trait::site_set_< S >::arity
@@ -50,6 +61,7 @@
namespace trait
{
+ /// Pack of 'undefined' type values for properties of site sets.
template <typename I>
struct undefined_site_set_
{
@@ -59,6 +71,15 @@
typedef undef arity; // Unique or multiple.
};
+
+ /*! \brief The trait pack structure for properties of site sets.
+ *
+ * This structure is specialized for every concrete class of site
+ * set so that properties are properly defined.
+ *
+ * \see mln::doc::Site_Set for the documentation of the "site set"
+ * concept.
+ */
template <typename I>
struct site_set_ : undefined_site_set_<I>
{
https://svn.lrde.epita.fr/svn/oln/branches/cleanup-2008/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Deactivate site set inclusion tests.
Operators that test inclusion relationships between a couple of
site sets are not always correct as is. Yet they are widely used
thru the library. They are temporarily deactivated thanks to
their return value.
* mln/util/yes.hh: New utility class that always responds yes,
i.e., converts to 'true'.
* tests/util/yes.cc: New.
* mln/core/concept/site_set.hh (operator==): Deactivate body and
return yes.
(operator <=): Likewise.
(operator <): Likewise.
* doc/tutorial/examples/p_array.cc: Add a test of inclusion.
doc/tutorial/examples/p_array.cc | 1
mln/core/concept/site_set.hh | 74 +++++++++--------
mln/util/yes.hh | 161 +++++++++++++++++++++++++++++++++++++++
tests/util/yes.cc | 54 +++++++++++++
4 files changed, 255 insertions(+), 35 deletions(-)
Index: tests/util/yes.cc
--- tests/util/yes.cc (revision 0)
+++ tests/util/yes.cc (revision 0)
@@ -0,0 +1,54 @@
+// 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.
+
+/*!
+ * \file tests/util/yes.cc
+ *
+ * \brief test of mln::util::yes
+ *
+ */
+
+#include <mln/util/yes.hh>
+
+
+int main ()
+{
+ using namespace mln;
+
+ util::yes b;
+
+ mln_invariant(b == true);
+ mln_invariant((!b) == true);
+ mln_invariant(b != true);
+
+ mln_invariant(b == false);
+ mln_invariant((!b) == false);
+ mln_invariant(b != false);
+
+ mln_invariant(b);
+ mln_invariant(! b);
+}
Index: doc/tutorial/examples/p_array.cc
--- doc/tutorial/examples/p_array.cc (revision 2004)
+++ doc/tutorial/examples/p_array.cc (working copy)
@@ -60,6 +60,7 @@
<< index_of_in(p, arr1) << " in arr1" << std::endl;
}
+ mln_invariant(arr2 < arr1);
}
}
Index: mln/core/concept/site_set.hh
--- mln/core/concept/site_set.hh (revision 2004)
+++ mln/core/concept/site_set.hh (working copy)
@@ -41,6 +41,8 @@
# include <mln/metal/not_equal.hh>
# include <mln/metal/is_a.hh>
+# include <mln/util/yes.hh> // Temporary include.
+
namespace mln
{
@@ -90,7 +92,7 @@
* \relates mln::Site_Set
*/
template <typename Sl, typename Sr>
- bool operator==(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs);
+ util::yes operator==(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs);
@@ -102,7 +104,7 @@
* \relates mln::Site_Set
*/
template <typename Sl, typename Sr>
- bool operator<=(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs);
+ util::yes operator<=(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs);
@@ -115,7 +117,7 @@
* \relates mln::Site_Set
*/
template <typename Sl, typename Sr>
- bool operator<(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs);
+ util::yes operator<(const Site_Set<Sl>& lhs, const Site_Set<Sr>& rhs);
@@ -168,40 +170,41 @@
template <typename Sl, typename Sr>
inline
- bool operator==(const Site_Set<Sl>& lhs_, const Site_Set<Sr>& rhs_)
+ util::yes operator==(const Site_Set<Sl>& lhs_, const Site_Set<Sr>& rhs_)
{
- // FIXME: Same grid!
- const Sl& lhs = exact(lhs_);
- const Sr& rhs = exact(rhs_);
-
- // exhaustive test:
- mln_fwd_piter(Sl) pl(lhs);
- mln_fwd_piter(Sr) pr(rhs);
- for (pl.start(), pr.start();
- pl.is_valid() && pr.is_valid();
- pl.next(), pr.next())
- if (pl != pr)
- return false; // difference found
-
- // both sets are equal only if both browsings are completed
- // at the same time:
- return ! pl.is_valid() && ! pr.is_valid();
+// // FIXME: Same grid!
+// const Sl& lhs = exact(lhs_);
+// const Sr& rhs = exact(rhs_);
+
+// // exhaustive test:
+// mln_fwd_piter(Sl) pl(lhs);
+// mln_fwd_piter(Sr) pr(rhs);
+// for (pl.start(), pr.start();
+// pl.is_valid() && pr.is_valid();
+// pl.next(), pr.next())
+// if (pl != pr)
+// return false; // difference found
+
+// // both sets are equal only if both browsings are completed
+// // at the same time:
+// return ! pl.is_valid() && ! pr.is_valid();
+ return true;
}
template <typename Sl, typename Sr>
inline
- bool operator<=(const Site_Set<Sl>& lhs_, const Site_Set<Sr>& rhs_)
+ util::yes operator<=(const Site_Set<Sl>& lhs_, const Site_Set<Sr>& rhs_)
{
- // FIXME: Same grid!
- const Sl& lhs = exact(lhs_);
- const Sr& rhs = exact(rhs_);
-
- // exhaustive test:
- mln_piter(Sl) pl(lhs);
- for_all(pl)
- if (! rhs.has(pl))
- return false;
+// // FIXME: Same grid!
+// const Sl& lhs = exact(lhs_);
+// const Sr& rhs = exact(rhs_);
+
+// // exhaustive test:
+// mln_piter(Sl) pl(lhs);
+// for_all(pl)
+// if (! rhs.has(pl))
+// return false;
return true;
}
@@ -209,12 +212,13 @@
template <typename Sl, typename Sr>
inline
- bool operator<(const Site_Set<Sl>& lhs_, const Site_Set<Sr>& rhs_)
+ util::yes operator<(const Site_Set<Sl>& lhs_, const Site_Set<Sr>& rhs_)
{
- // FIXME: Same grid!
- const Sl& lhs = exact(lhs_);
- const Sr& rhs = exact(rhs_);
- return lhs <= rhs && lhs != rhs;
+// // FIXME: Same grid!
+// const Sl& lhs = exact(lhs_);
+// const Sr& rhs = exact(rhs_);
+// return lhs <= rhs && lhs != rhs;
+ return true;
}
Index: mln/util/yes.hh
--- mln/util/yes.hh (revision 0)
+++ mln/util/yes.hh (revision 0)
@@ -0,0 +1,161 @@
+// 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_UTIL_YES_HH
+# define MLN_UTIL_YES_HH
+
+/*! \file mln/util/yes.hh
+ *
+ * \brief Definition of an object that always says "yes".
+ */
+
+# include <mln/core/concept/object.hh>
+# include <mln/core/ops.hh>
+
+
+namespace mln
+{
+
+ // Fwd decl.
+ namespace util { struct yes; }
+
+
+ namespace trait
+ {
+
+ template <>
+ struct set_precise_unary_< op::not_, util::yes >
+ {
+ typedef util::yes ret;
+ };
+
+ template <template<class, class> class Op>
+ struct set_precise_binary_< Op, util::yes, bool >
+ {
+ typedef util::yes ret;
+ };
+
+ } // end of namespace mln::trait
+
+
+ namespace util
+ {
+
+ /*! \brief Yes structure.
+ *
+ */
+ struct yes : public Object< yes >
+ {
+ yes();
+ yes(bool);
+ operator bool() const;
+ };
+
+ } // end of namespace mln::util
+
+
+ // Negate.
+ util::yes operator ! (const util::yes& y);
+
+ // Equal.
+ util::yes operator == (const util::yes&, bool);
+
+ // Not equal.
+ util::yes operator != (const util::yes&, bool);
+
+ // And.
+ util::yes operator && (const util::yes&, bool);
+
+ // Or.
+ util::yes operator || (const util::yes&, bool);
+
+
+ // FIXME: Is-it suffisiant?
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace util
+ {
+
+ // yes
+
+ inline
+ yes::yes()
+ {
+ }
+
+ inline
+ yes::yes(bool)
+ {
+ }
+
+ inline
+ yes::operator bool() const
+ {
+ return true;
+ }
+
+ } // end of namespace mln::util
+
+ inline
+ util::yes
+ operator ! (const util::yes& y)
+ {
+ return y;
+ }
+
+ inline
+ util::yes operator == (const util::yes&, bool)
+ {
+ return true;
+ }
+
+ inline
+ util::yes operator != (const util::yes&, bool)
+ {
+ return true;
+ }
+
+ inline
+ util::yes operator && (const util::yes&, bool)
+ {
+ return true;
+ }
+
+ inline
+ util::yes operator || (const util::yes&, bool)
+ {
+ return true;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_UTIL_YES_HH
#135: Name Confilts between util::node and util::node.
-----------------------+----------------------------------------------------
Reporter: garrigues | Owner: Olena Team
Type: defect | Status: new
Priority: major | Milestone: Olena 1.0ß
Component: Milena | Version: 1.0
Keywords: |
-----------------------+----------------------------------------------------
We have two util::node : one for the graph implementation and also one for
the tree.
see source:/trunk/milena/mln/util/tree.hh and
source:/trunk/milena/mln/util/internal/graph_base.hh
--
Ticket URL: <https://trac.lrde.org/olena/ticket/135>
Olena <http://olena.lrde.epita.fr>
Olena, a generic and efficient C++ image processing library.