aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-04-12 15:37:03 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-04-20 16:42:28 +0100
commit360d337e8a866cf108498a67f089119cd2789d2c (patch)
tree63318f830c75a642c97b8b2ebfc695c269b158bc
parent064fc2f78d42e9239db56d58ade15098b89fce75 (diff)
downloadpaludis-360d337e8a866cf108498a67f089119cd2789d2c.tar.gz
paludis-360d337e8a866cf108498a67f089119cd2789d2c.tar.xz
Let graphs have nodes with sptrs
-rw-r--r--paludis/util/graph-impl.hh16
-rw-r--r--paludis/util/graph.hh8
2 files changed, 21 insertions, 3 deletions
diff --git a/paludis/util/graph-impl.hh b/paludis/util/graph-impl.hh
index 5d682a7..62fd772 100644
--- a/paludis/util/graph-impl.hh
+++ b/paludis/util/graph-impl.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -360,6 +360,18 @@ namespace paludis
++m;
}
+ template <typename T_>
+ static const T_ & depointer(const T_ & t)
+ {
+ return t;
+ }
+
+ template <typename T_>
+ static const T_ & depointer(const std::tr1::shared_ptr<T_> & t)
+ {
+ return *t;
+ }
+
void sort(OutputConstIterator_ & i)
{
unsigned c(0);
@@ -375,7 +387,7 @@ namespace paludis
new NoGraphTopologicalOrderExistsError::RemainingNodes);
for (typename DirectedGraph<Node_, Edge_, Comparator_>::NodeConstIterator n(g.begin_nodes()), n_end(g.end_nodes()) ; n != n_end ; ++n)
if (done.end() == done.find(*n))
- r->add(stringify(*n));
+ r->add(stringify(depointer(*n)));
throw NoGraphTopologicalOrderExistsError(r);
}
diff --git a/paludis/util/graph.hh b/paludis/util/graph.hh
index f6bc7cd..ebe5734 100644
--- a/paludis/util/graph.hh
+++ b/paludis/util/graph.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -77,6 +77,12 @@ namespace paludis
{
}
+ template <typename Node_>
+ NoSuchGraphNodeError(const std::tr1::shared_ptr<Node_> & node) throw () :
+ GraphError("Node '" + stringify(*node) + "' does not exist")
+ {
+ }
+
///\}
};