https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Some changes to help Edwin find a bug.
* mln/core/site_set/p_queue_fast.hh (has): De-activate invariant
to help Edwin debugging.
* mln/core/internal/graph_psite_base.hh
(local_change_graph): New.
(change_target): Call local_change_graph so that the target
changes when site_ and elt_ are the same, i.e., psite is site,
that is, a vertex or an edge.
* mln/morpho/tree/data.hh: Add debugging code.
* mln/util/internal/graph_base.hh (data_hook_): New.
* mln/util/edge.hh (change_target): New; is it really useful?
core/internal/graph_psite_base.hh | 18 +++++++++++++++++-
core/site_set/p_queue_fast.hh | 2 +-
morpho/tree/data.hh | 27 ++++++++++++++++++++++++---
util/edge.hh | 15 +++++++++++++++
util/internal/graph_base.hh | 11 ++++++++++-
5 files changed, 67 insertions(+), 6 deletions(-)
Index: mln/core/site_set/p_queue_fast.hh
--- mln/core/site_set/p_queue_fast.hh (revision 4368)
+++ mln/core/site_set/p_queue_fast.hh (working copy)
@@ -202,7 +202,7 @@
if (p.index() < 0 || unsigned(p.index()) >= nsites())
return false;
// The type of rhs below is mln_site(p_array<P>).
- mln_invariant(p.to_site() == (*this)[p.index()]);
+// mln_invariant(p.to_site() == (*this)[p.index()]);
return true;
}
Index: mln/core/internal/graph_psite_base.hh
--- mln/core/internal/graph_psite_base.hh (revision 4368)
+++ mln/core/internal/graph_psite_base.hh (working copy)
@@ -216,13 +216,29 @@
update_id(id);
}
+ // The lines below are dedicated/local to this file.
+ template <typename E, typename S, typename G>
+ inline
+ void local_change_graph(E& elt_, S& site_, const G& g)
+ {
+ elt_.change_graph(g);
+ }
+ template <typename E, typename G>
+ inline
+ void local_change_graph(E& elt_, E& site_, const G& g)
+ {
+ elt_.change_graph(g);
+ site_.change_graph(g);
+ }
+ // End of local stuff.
+
template <typename S, typename E>
inline
void
graph_psite_base<S,E>::change_target(const S& new_target)
{
s_ = & new_target;
- elt_.change_graph(new_target.graph());
+ local_change_graph(elt_, site_, new_target.graph());
}
template <typename S, typename E>
Index: mln/morpho/tree/data.hh
--- mln/morpho/tree/data.hh (revision 4368)
+++ mln/morpho/tree/data.hh (working copy)
@@ -434,8 +434,19 @@
mln_rvalue_(mln_ch_value(I, mln_psite(I)))
data<I,S>::parent(const mln_psite(I)& p) const
{
- mln_precondition(is_valid());
- mln_precondition(parent_.domain().has(p));
+ // HERE
+
+// mln_precondition(is_valid());
+// mln_rvalue(parent_t) tmp;
+// if (! parent_.domain().has(p))
+// {
+// std::cout << "KO next" << std::endl;
+// std::cout << p << std::endl;
+// std::cout << parent_.domain() << std::endl;
+// }
+// else
+// std::cout << "ok next" << std::endl;
+// mln_precondition(parent_.domain().has(p));
return parent_(p);
}
@@ -647,10 +658,20 @@
return;
mln_invariant(p_.is_valid());
+ std::cout << "children(p).size = " << s_->children(p_).nsites()
<< std::endl;
+ if (s_->children(p_).nsites() != 0)
+ {
+ std::cout << "elt[0] = " <<
s_->children(p_)[0].to_site().graph().data_hook_() << std::endl;
+ std::cout << "elt[0] = " << s_->children(p_)[0] <<
std::endl;
+ }
+
+ std::cout << s_->children(p_) << std::endl;
+
mln_fwd_piter(T::nodes_t) child(s_->children(p_));
for_all(child)
{
- mln_invariant(s_->parent(child) == p_);
+ std::cout << child.to_site().graph().data_hook_() << std::endl;
+ // mln_invariant(s_->parent(child) == p_);
stack_.push_back(child);
}
}
Index: mln/util/internal/graph_base.hh
--- mln/util/internal/graph_base.hh (revision 4368)
+++ mln/util/internal/graph_base.hh (working copy)
@@ -110,7 +110,8 @@
\param[in] ostr The output stream. */
void print_debug(std::ostream& ostr) const;
-
+ /// Hook to data; for debugging purpose.
+ const util::tracked_ptr< mln::internal::data<E> >& data_hook_() const;
protected:
@@ -234,6 +235,14 @@
<< std::endl;
}
+ template<typename E>
+ inline
+ const util::tracked_ptr< mln::internal::data<E> >&
+ graph_base<E>::data_hook_() const
+ {
+ return data_;
+ }
+
} // end of namespace mln::util::internal
} // end of namespace mln::util
Index: mln/util/edge.hh
--- mln/util/edge.hh (revision 4368)
+++ mln/util/edge.hh (working copy)
@@ -35,6 +35,8 @@
# include <mln/util/internal/edge_impl.hh>
# include <mln/core/concept/proxy.hh>
# include <mln/core/concept/site.hh>
+# include <mln/core/internal/pseudo_site_base.hh>
+
namespace mln
{
@@ -134,6 +136,7 @@
edge_id_t ith_nbh_edge(unsigned i) const;
/// \}
+
private:
G g_;
edge_id_t id_;
@@ -156,6 +159,18 @@
+ namespace if_possible
+ {
+ template <typename G>
+ void change_target(mln::util::edge<G>& e, const G& new_target)
+ {
+ std::cout << "YES: specialization change_target(edge, graph)"
<< std::endl;
+ e.change_graph(new_target);
+ }
+
+ } // end of namespace mln::if_possible
+
+
namespace internal
{