aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-10 22:17:27 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-11-10 22:17:27 +0000
commit67bf731933fe0f9cc8353d8f3bbdfcd9a1bcb906 (patch)
tree20c0384e476a706bca18384ca9d1416ebb6629bd
parent0b6f59ee9cfe6fb1a369905af020cac4d3832ee6 (diff)
downloadpaludis-67bf731933fe0f9cc8353d8f3bbdfcd9a1bcb906.tar.gz
paludis-67bf731933fe0f9cc8353d8f3bbdfcd9a1bcb906.tar.xz
Refactor a bit
-rw-r--r--paludis/resolver/decider.cc33
-rw-r--r--paludis/resolver/decider.hh5
-rw-r--r--paludis/resolver/orderer.cc30
-rw-r--r--paludis/resolver/orderer.hh5
-rw-r--r--paludis/resolver/resolver.cc10
-rw-r--r--paludis/resolver/resolver.hh2
6 files changed, 32 insertions, 53 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 2f02dc1..4597717 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -68,26 +68,21 @@ namespace paludis
ResolutionsByResolventMap resolutions_by_resolvent;
- const std::tr1::shared_ptr<Resolutions> all_resolutions;
- const std::tr1::shared_ptr<Resolutions> untaken_resolutions;
- const std::tr1::shared_ptr<Resolutions> error_resolutions;
- const std::tr1::shared_ptr<Resolutions> unordered_resolutions;
+ const std::tr1::shared_ptr<ResolverLists> lists;
Implementation(const Environment * const e, const ResolverFunctions & f,
- const ResolverLists & l) :
+ const std::tr1::shared_ptr<ResolverLists> & l) :
env(e),
fns(f),
rewriter(env),
- all_resolutions(l.all()),
- untaken_resolutions(l.untaken()),
- error_resolutions(l.errors()),
- unordered_resolutions(new Resolutions)
+ lists(l)
{
}
};
}
-Decider::Decider(const Environment * const e, const ResolverFunctions & f, const ResolverLists & l) :
+Decider::Decider(const Environment * const e, const ResolverFunctions & f,
+ const std::tr1::shared_ptr<ResolverLists> & l) :
PrivateImplementationPattern<Decider>(new Implementation<Decider>(e, f, l))
{
}
@@ -294,7 +289,7 @@ Decider::_resolution_for_resolvent(const Resolvent & r, const bool create)
{
std::tr1::shared_ptr<Resolution> resolution(_create_resolution_for_resolvent(r));
i = _imp->resolutions_by_resolvent.insert(std::make_pair(r, resolution)).first;
- _imp->all_resolutions->append(resolution);
+ _imp->lists->all()->append(resolution);
}
else
throw InternalError(PALUDIS_HERE, "resolver bug: expected resolution for "
@@ -1317,12 +1312,6 @@ Decider::add_target_with_reason(const PackageDepSpec & spec, const std::tr1::sha
}
}
-const std::tr1::shared_ptr<const Resolutions>
-Decider::unordered_resolutions() const
-{
- return _imp->unordered_resolutions;
-}
-
void
Decider::resolve()
{
@@ -1386,16 +1375,16 @@ namespace
void
Decider::_resolve_unordered()
{
- for (Resolutions::ConstIterator i(_imp->all_resolutions->begin()),
- i_end(_imp->all_resolutions->end()) ;
+ for (Resolutions::ConstIterator i(_imp->lists->all()->begin()),
+ i_end(_imp->lists->all()->end()) ;
i != i_end ; ++i)
{
(*i)->decision()->accept(ResolveOrderVisitor(
std::tr1::bind(&NamedValue<n::already_ordered, bool>::operator=,
&(*i)->already_ordered, value_for<n::already_ordered>(true)),
- std::tr1::bind(&Resolutions::append, _imp->error_resolutions, *i),
- std::tr1::bind(&Resolutions::append, _imp->unordered_resolutions, *i),
- std::tr1::bind(&Resolutions::append, _imp->untaken_resolutions, *i)
+ std::tr1::bind(&Resolutions::append, _imp->lists->errors(), *i),
+ std::tr1::bind(&Resolutions::append, _imp->lists->unordered(), *i),
+ std::tr1::bind(&Resolutions::append, _imp->lists->untaken(), *i)
));
}
}
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 1350985..fc6931e 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -172,7 +172,7 @@ namespace paludis
public:
Decider(const Environment * const,
const ResolverFunctions &,
- const ResolverLists &);
+ const std::tr1::shared_ptr<ResolverLists> &);
~Decider();
void resolve();
@@ -184,9 +184,6 @@ namespace paludis
const std::tr1::shared_ptr<const RewrittenSpec> rewrite_if_special(const PackageOrBlockDepSpec &,
const std::tr1::shared_ptr<const Resolvent> & maybe_from) const;
- const std::tr1::shared_ptr<const Resolutions> unordered_resolutions() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
-
const std::tr1::shared_ptr<Resolution> resolution_for_resolvent(const Resolvent &) const;
};
}
diff --git a/paludis/resolver/orderer.cc b/paludis/resolver/orderer.cc
index 4bd84d8..a362abf 100644
--- a/paludis/resolver/orderer.cc
+++ b/paludis/resolver/orderer.cc
@@ -58,23 +58,21 @@ namespace paludis
const Environment * const env;
const std::tr1::shared_ptr<const Decider> decider;
- const std::tr1::shared_ptr<Resolutions> all_resolutions;
- const std::tr1::shared_ptr<Resolutions> ordered_resolutions;
+ const std::tr1::shared_ptr<ResolverLists> lists;
Implementation(const Environment * const e,
const std::tr1::shared_ptr<const Decider> & d,
- const ResolverLists & l) :
+ const std::tr1::shared_ptr<ResolverLists> & l) :
env(e),
decider(d),
- all_resolutions(l.all()),
- ordered_resolutions(l.ordered())
+ lists(l)
{
}
};
}
Orderer::Orderer(const Environment * const e, const std::tr1::shared_ptr<const Decider> & d,
- const ResolverLists & l) :
+ const std::tr1::shared_ptr<ResolverLists> & l) :
PrivateImplementationPattern<Orderer>(new Implementation<Orderer>(e, d, l))
{
}
@@ -88,8 +86,8 @@ Orderer::_resolve_arrows()
{
Context context("When creating arrows for order resolution:");
- for (Resolutions::ConstIterator i(_imp->all_resolutions->begin()),
- i_end(_imp->all_resolutions->end()) ;
+ for (Resolutions::ConstIterator i(_imp->lists->all()->begin()),
+ i_end(_imp->lists->all()->end()) ;
i != i_end ; ++i)
for (Constraints::ConstIterator c((*i)->constraints()->begin()),
c_end((*i)->constraints()->end()) ;
@@ -267,8 +265,8 @@ Orderer::_resolve_order()
int ignore_pass(0);
while (true)
{
- for (Resolutions::ConstIterator i(_imp->decider->unordered_resolutions()->begin()),
- i_end(_imp->decider->unordered_resolutions()->end()) ;
+ for (Resolutions::ConstIterator i(_imp->lists->unordered()->begin()),
+ i_end(_imp->lists->unordered()->end()) ;
i != i_end ; ++i)
{
if ((*i)->already_ordered())
@@ -329,7 +327,7 @@ Orderer::_can_order_now(const Resolvent &, const std::tr1::shared_ptr<const Reso
void
Orderer::_do_order(const Resolvent &, const std::tr1::shared_ptr<Resolution> & resolution)
{
- _imp->ordered_resolutions->append(resolution);
+ _imp->lists->ordered()->append(resolution);
resolution->already_ordered() = true;
}
@@ -338,8 +336,8 @@ Orderer::_unable_to_order_more() const
{
std::cout << "Unable to order any of the following:" << std::endl;
- for (Resolutions::ConstIterator i(_imp->decider->unordered_resolutions()->begin()),
- i_end(_imp->decider->unordered_resolutions()->end()) ;
+ for (Resolutions::ConstIterator i(_imp->lists->unordered()->begin()),
+ i_end(_imp->lists->unordered()->end()) ;
i != i_end ; ++i)
{
if ((*i)->already_ordered())
@@ -426,12 +424,6 @@ Orderer::_find_cycle(const Resolvent & start_resolvent, const int ignorable_pass
return result.str();
}
-const std::tr1::shared_ptr<const Resolutions>
-Orderer::ordered_resolutions() const
-{
- return _imp->ordered_resolutions;
-}
-
void
Orderer::resolve()
{
diff --git a/paludis/resolver/orderer.hh b/paludis/resolver/orderer.hh
index d953182..4ac496a 100644
--- a/paludis/resolver/orderer.hh
+++ b/paludis/resolver/orderer.hh
@@ -66,13 +66,10 @@ namespace paludis
Orderer(
const Environment * const,
const std::tr1::shared_ptr<const Decider> &,
- const ResolverLists &);
+ const std::tr1::shared_ptr<ResolverLists> &);
~Orderer();
void resolve();
-
- const std::tr1::shared_ptr<const Resolutions> ordered_resolutions() const
- PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
}
diff --git a/paludis/resolver/resolver.cc b/paludis/resolver/resolver.cc
index 66dba8d..16059f6 100644
--- a/paludis/resolver/resolver.cc
+++ b/paludis/resolver/resolver.cc
@@ -50,7 +50,7 @@ namespace paludis
const std::tr1::shared_ptr<ResolverLists> lists;
const std::tr1::shared_ptr<Decider> decider;
- std::tr1::shared_ptr<Orderer> orderer;
+ const std::tr1::shared_ptr<Orderer> orderer;
Implementation(const Environment * const e, const ResolverFunctions & f) :
env(e),
@@ -59,9 +59,11 @@ namespace paludis
value_for<n::all>(make_shared_ptr(new Resolutions)),
value_for<n::errors>(make_shared_ptr(new Resolutions)),
value_for<n::ordered>(make_shared_ptr(new Resolutions)),
+ value_for<n::unordered>(make_shared_ptr(new Resolutions)),
value_for<n::untaken>(make_shared_ptr(new Resolutions))
))),
- decider(new Decider(e, f, *lists))
+ decider(new Decider(e, f, lists)),
+ orderer(new Orderer(e, decider, lists))
{
}
};
@@ -105,8 +107,6 @@ void
Resolver::resolve()
{
_imp->decider->resolve();
-
- _imp->orderer.reset(new Orderer(_imp->env, _imp->decider, *_imp->lists));
_imp->orderer->resolve();
}
@@ -123,6 +123,7 @@ ResolverLists::serialise(Serialiser & s) const
.member(SerialiserFlags<serialise::might_be_null>(), "all", all())
.member(SerialiserFlags<serialise::might_be_null>(), "errors", errors())
.member(SerialiserFlags<serialise::might_be_null>(), "ordered", ordered())
+ .member(SerialiserFlags<serialise::might_be_null>(), "unordered", unordered())
.member(SerialiserFlags<serialise::might_be_null>(), "untaken", untaken())
;
}
@@ -135,6 +136,7 @@ ResolverLists::deserialise(Deserialisation & d)
value_for<n::all>(v.member<std::tr1::shared_ptr<Resolutions> >("all")),
value_for<n::errors>(v.member<std::tr1::shared_ptr<Resolutions> >("errors")),
value_for<n::ordered>(v.member<std::tr1::shared_ptr<Resolutions> >("ordered")),
+ value_for<n::unordered>(v.member<std::tr1::shared_ptr<Resolutions> >("unordered")),
value_for<n::untaken>(v.member<std::tr1::shared_ptr<Resolutions> >("untaken"))
);
}
diff --git a/paludis/resolver/resolver.hh b/paludis/resolver/resolver.hh
index 1b95696..d6a0241 100644
--- a/paludis/resolver/resolver.hh
+++ b/paludis/resolver/resolver.hh
@@ -45,6 +45,7 @@ namespace paludis
struct all;
struct errors;
struct ordered;
+ struct unordered;
struct untaken;
}
@@ -55,6 +56,7 @@ namespace paludis
NamedValue<n::all, std::tr1::shared_ptr<Resolutions> > all;
NamedValue<n::errors, std::tr1::shared_ptr<Resolutions> > errors;
NamedValue<n::ordered, std::tr1::shared_ptr<Resolutions> > ordered;
+ NamedValue<n::unordered, std::tr1::shared_ptr<Resolutions> > unordered;
NamedValue<n::untaken, std::tr1::shared_ptr<Resolutions> > untaken;
static const ResolverLists deserialise(Deserialisation &) PALUDIS_ATTRIBUTE((warn_unused_result));