aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-22 15:56:48 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-22 15:56:48 +0100
commit379aec4bf1b6d8b10bbb4481bb19f389991ad2a0 (patch)
tree3cb435d57de69ad33d096a2e82932e350b009c51
parent269e7b76d8405035de7721b72b9b4e717f2ca1ac (diff)
downloadpaludis-379aec4bf1b6d8b10bbb4481bb19f389991ad2a0.tar.gz
paludis-379aec4bf1b6d8b10bbb4481bb19f389991ad2a0.tar.xz
Work out destinations immediately
-rw-r--r--paludis/resolver/decider.cc96
-rw-r--r--paludis/resolver/decider.hh7
-rw-r--r--paludis/resolver/decision.cc8
-rw-r--r--paludis/resolver/decision.hh3
4 files changed, 25 insertions, 89 deletions
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index 0f3c3dd..42f9bc7 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -365,17 +365,6 @@ Decider::_collect_staying(const std::tr1::shared_ptr<const PackageIDSequence> &
}
void
-Decider::_resolve_destinations()
-{
- Context context("When resolving destinations:");
-
- for (ResolutionsByResolvent::ConstIterator i(_imp->resolutions_by_resolvent->begin()),
- i_end(_imp->resolutions_by_resolvent->end()) ;
- i != i_end ; ++i)
- _do_destination_if_necessary(*i);
-}
-
-void
Decider::_resolve_confirmations()
{
Context context("When resolving confirmations:");
@@ -386,64 +375,13 @@ Decider::_resolve_confirmations()
_confirm(*i);
}
-namespace
-{
- struct DoDestinationIfNecessaryVisitor
- {
- typedef std::tr1::function<const std::tr1::shared_ptr<const Destination> (
- const ChangesToMakeDecision &)> MakeDestinationFunc;
- typedef std::tr1::function<ChangeType (
- const ChangesToMakeDecision &)> MakeChangeTypeForFunc;
-
- MakeDestinationFunc make_destination_for;
- MakeChangeTypeForFunc make_change_type_for;
-
- DoDestinationIfNecessaryVisitor(const MakeDestinationFunc & f, const MakeChangeTypeForFunc & c) :
- make_destination_for(f),
- make_change_type_for(c)
- {
- }
-
- void visit(RemoveDecision &)
- {
- }
-
- void visit(ExistingNoChangeDecision &)
- {
- }
-
- void visit(NothingNoChangeDecision &)
- {
- }
-
- void visit(UnableToMakeDecision &)
- {
- }
-
- void visit(BreakDecision &)
- {
- }
-
- void visit(ChangesToMakeDecision & decision)
- {
- if (! decision.destination())
- {
- decision.set_destination(make_destination_for(decision));
- decision.set_change_type(make_change_type_for(decision));
- }
- }
- };
-}
-
void
-Decider::_do_destination_if_necessary(
- const std::tr1::shared_ptr<Resolution> & resolution)
+Decider::_fixup_changes_to_make_decision(
+ const std::tr1::shared_ptr<const Resolution> & resolution,
+ ChangesToMakeDecision & decision) const
{
- DoDestinationIfNecessaryVisitor v(
- std::tr1::bind(&Decider::_make_destination_for, this, resolution, std::tr1::placeholders::_1),
- std::tr1::bind(&Decider::_make_change_type_for, this, resolution, std::tr1::placeholders::_1)
- );
- resolution->decision()->accept(v);
+ decision.set_destination(_make_destination_for(resolution, decision));
+ decision.set_change_type(_make_change_type_for(resolution, decision));
}
const std::tr1::shared_ptr<Destination>
@@ -1359,15 +1297,15 @@ Decider::_try_to_find_decision_for(
if (installable_id && ! existing_id)
{
- /* there's nothing suitable existing. we fix the last_ct when we do
- * destinations. */
+ /* there's nothing suitable existing. */
return make_shared_ptr(new ChangesToMakeDecision(
resolution->resolvent(),
installable_id,
best,
last_ct,
! resolution->constraints()->all_untaken(),
- make_null_shared_ptr()
+ make_null_shared_ptr(),
+ std::tr1::bind(&Decider::_fixup_changes_to_make_decision, this, resolution, std::tr1::placeholders::_1)
));
}
else if (existing_id && ! installable_id)
@@ -1491,21 +1429,15 @@ Decider::_try_to_find_decision_for(
best,
last_ct,
! resolution->constraints()->all_untaken(),
- make_null_shared_ptr()
+ make_null_shared_ptr(),
+ std::tr1::bind(&Decider::_fixup_changes_to_make_decision, this, resolution, std::tr1::placeholders::_1)
));
switch (resolution->constraints()->strictest_use_existing())
{
case ue_only_if_transient:
case ue_never:
- return make_shared_ptr(new ChangesToMakeDecision(
- resolution->resolvent(),
- installable_id,
- best,
- last_ct,
- ! resolution->constraints()->all_untaken(),
- make_null_shared_ptr()
- ));
+ return changes_to_make;
case ue_if_same:
if (is_same)
@@ -1692,7 +1624,8 @@ Decider::_get_unmatching_constraints(
false,
last_ct,
! (*c)->untaken(),
- make_null_shared_ptr()
+ make_null_shared_ptr(),
+ std::tr1::bind(&Decider::_fixup_changes_to_make_decision, this, resolution, std::tr1::placeholders::_1)
));
if (! _check_constraint(*c, decision))
result->add(*c);
@@ -1765,9 +1698,6 @@ Decider::resolve()
break;
}
- _imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Finding Destinations"));
- _resolve_destinations();
-
_imp->env->trigger_notifier_callback(NotifierCallbackResolverStageEvent("Confirming"));
_resolve_confirmations();
}
diff --git a/paludis/resolver/decider.hh b/paludis/resolver/decider.hh
index 69ddc8d..3e1a87e 100644
--- a/paludis/resolver/decider.hh
+++ b/paludis/resolver/decider.hh
@@ -134,6 +134,10 @@ namespace paludis
void _resolve_destinations();
void _resolve_confirmations();
+ void _fixup_changes_to_make_decision(
+ const std::tr1::shared_ptr<const Resolution> &,
+ ChangesToMakeDecision &) const;
+
const std::tr1::shared_ptr<Destination> _make_destination_for(
const std::tr1::shared_ptr<const Resolution> & resolution,
const ChangesToMakeDecision &) const;
@@ -152,9 +156,6 @@ namespace paludis
const std::tr1::shared_ptr<Decision> _cannot_decide_for(
const std::tr1::shared_ptr<const Resolution> & resolution) const;
- void _do_destination_if_necessary(
- const std::tr1::shared_ptr<Resolution> & our_resolution);
-
void _add_dependencies_if_necessary(
const std::tr1::shared_ptr<Resolution> & our_resolution);
diff --git a/paludis/resolver/decision.cc b/paludis/resolver/decision.cc
index 183f06c..59f903d 100644
--- a/paludis/resolver/decision.cc
+++ b/paludis/resolver/decision.cc
@@ -128,7 +128,8 @@ ChangesToMakeDecision::deserialise(Deserialisation & d)
v.member<bool>("best"),
destringify<ChangeType>(v.member<std::string>("change_type")),
v.member<bool>("taken"),
- v.member<std::tr1::shared_ptr<const Destination> >("destination")
+ v.member<std::tr1::shared_ptr<const Destination> >("destination"),
+ std::tr1::function<void (const ChangesToMakeDecision &)>()
));
{
@@ -369,9 +370,12 @@ ChangesToMakeDecision::ChangesToMakeDecision(
const bool b,
const ChangeType c,
const bool t,
- const std::tr1::shared_ptr<const Destination> & d) :
+ const std::tr1::shared_ptr<const Destination> & d,
+ const std::tr1::function<void (ChangesToMakeDecision &)> & f) :
PrivateImplementationPattern<ChangesToMakeDecision>(new Implementation<ChangesToMakeDecision>(r, o, b, c, t, d))
{
+ if (f)
+ f(*this);
}
#ifdef PALUDIS_HAVE_DEFAULT_DELETED
diff --git a/paludis/resolver/decision.hh b/paludis/resolver/decision.hh
index cbafe90..38c1328 100644
--- a/paludis/resolver/decision.hh
+++ b/paludis/resolver/decision.hh
@@ -153,7 +153,8 @@ namespace paludis
const bool best,
const ChangeType,
const bool taken,
- const std::tr1::shared_ptr<const Destination> &
+ const std::tr1::shared_ptr<const Destination> &,
+ const std::tr1::function<void (ChangesToMakeDecision &)> &
);
~ChangesToMakeDecision();