From 6083d2a048b9386f9dd584c3dca8ce041ac4edc1 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Mon, 14 Jan 2008 13:31:23 +0000 Subject: [PATCH] ordering combiSolutions --- zypp/ResolverProblem.cc | 9 +++++++-- zypp/ResolverProblem.h | 2 +- zypp/sat/SATResolver.cc | 3 ++- zypp/solver/detail/ProblemSolutionCombi.cc | 2 ++ zypp/solver/detail/ProblemSolutionCombi.h | 11 ++++++++++- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/zypp/ResolverProblem.cc b/zypp/ResolverProblem.cc index af733aa33..41969de77 100644 --- a/zypp/ResolverProblem.cc +++ b/zypp/ResolverProblem.cc @@ -101,9 +101,14 @@ ResolverProblem::solutions() const **/ void -ResolverProblem::addSolution( ProblemSolution_Ptr solution ) +ResolverProblem::addSolution( ProblemSolution_Ptr solution, + bool inFront ) { - _solutions.push_back (solution); + if (inFront) { + _solutions.push_front (solution); + } else { + _solutions.push_back (solution); + } } void diff --git a/zypp/ResolverProblem.h b/zypp/ResolverProblem.h index 6780b967b..4cd6b0dc6 100644 --- a/zypp/ResolverProblem.h +++ b/zypp/ResolverProblem.h @@ -97,7 +97,7 @@ namespace zypp * Add a solution to this problem. This class takes over ownership of * the problem and will delete it when neccessary. **/ - void addSolution( ProblemSolution_Ptr solution ); + void addSolution( ProblemSolution_Ptr solution, bool inFront = false ); }; /////////////////////////////////////////////////////////////////////// diff --git a/zypp/sat/SATResolver.cc b/zypp/sat/SATResolver.cc index b0c36cf4f..c1a20a9d4 100644 --- a/zypp/sat/SATResolver.cc +++ b/zypp/sat/SATResolver.cc @@ -796,7 +796,8 @@ SATResolver::problems () } } } - resolverProblem->addSolution (problemSolution); + resolverProblem->addSolution (problemSolution, + problemSolution->actionCount() > 1 ? true : false); // Solutions with more than 1 action will be shown first. MIL << "------------------------------------" << endl; } // save problem diff --git a/zypp/solver/detail/ProblemSolutionCombi.cc b/zypp/solver/detail/ProblemSolutionCombi.cc index 3facc6e74..dd7586335 100644 --- a/zypp/solver/detail/ProblemSolutionCombi.cc +++ b/zypp/solver/detail/ProblemSolutionCombi.cc @@ -48,6 +48,7 @@ IMPL_PTR_TYPE(ProblemSolutionCombi); ProblemSolutionCombi::ProblemSolutionCombi( ResolverProblem_Ptr parent) : ProblemSolution (parent, "", "") + , actNumber(0) { _description = ""; _details = ""; @@ -56,6 +57,7 @@ ProblemSolutionCombi::ProblemSolutionCombi( ResolverProblem_Ptr parent) void ProblemSolutionCombi::addSingleAction( PoolItem_Ref item, const TransactionKind action) { addAction (new TransactionSolutionAction(item, action)); + actNumber++; } void ProblemSolutionCombi::addDescription( const std::string description) diff --git a/zypp/solver/detail/ProblemSolutionCombi.h b/zypp/solver/detail/ProblemSolutionCombi.h index ba71bed5a..39587783f 100644 --- a/zypp/solver/detail/ProblemSolutionCombi.h +++ b/zypp/solver/detail/ProblemSolutionCombi.h @@ -44,6 +44,8 @@ namespace zypp **/ class ProblemSolutionCombi : public ProblemSolution { + protected: + int actNumber; // number of actions public: /** @@ -54,10 +56,17 @@ namespace zypp * Add a single action */ void addSingleAction( PoolItem_Ref item, const TransactionKind action); + + /** + * returns the number of actions + */ + int actionCount() { return actNumber;} + /** * Set description text */ - void addDescription( const std::string description); + void addDescription( const std::string description); + }; /////////////////////////////////////////////////////////////////// -- 2.34.1