ProblemSolution.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "zypp/solver/detail/Types.h"
00025 #include "zypp/solver/detail/SolutionAction.h"
00026 #include "zypp/ProblemSolution.h"
00027 #include "zypp/base/Logger.h"
00028 #include "zypp/solver/detail/Resolver.h"
00029
00030 using namespace std;
00031
00033 namespace zypp
00034 {
00035
00036 IMPL_PTR_TYPE(ProblemSolution);
00037
00038
00039
00040 ostream&
00041 operator<<( ostream& os, const ProblemSolution & solution)
00042 {
00043 os << "Solution:" << endl;
00044 os << solution._description << endl;
00045 os << solution._details << endl;
00046 os << solution._actions;
00047 return os;
00048 }
00049
00050 ostream&
00051 operator<<( ostream& os, const ProblemSolutionList & solutionlist)
00052 {
00053 for (ProblemSolutionList::const_iterator iter = solutionlist.begin(); iter != solutionlist.end(); ++iter) {
00054 os << *(*iter) << endl;
00055 }
00056 return os;
00057 }
00058
00059 ostream&
00060 operator<<( ostream& os, const CProblemSolutionList & solutionlist)
00061 {
00062 for (CProblemSolutionList::const_iterator iter = solutionlist.begin(); iter != solutionlist.end(); ++iter) {
00063 os << *(*iter) << endl;
00064 }
00065 return os;
00066 }
00067
00068
00069
00070 ProblemSolution::ProblemSolution( ResolverProblem_Ptr parent, const string & description, const string & details )
00071 : _problem (parent)
00072 , _description (description)
00073 , _details (details)
00074 {
00075 }
00076
00077
00078 ProblemSolution::~ProblemSolution()
00079 {
00080 }
00081
00082
00089 bool
00090 ProblemSolution::apply (solver::detail::Resolver & resolver)
00091 {
00092 DBG << "apply solution " << *this << endl;
00093 bool ret = true;
00094 for (solver::detail::CSolutionActionList::const_iterator iter = _actions.begin();
00095 iter != _actions.end(); ++iter) {
00096 solver::detail::SolutionAction_constPtr action = *iter;
00097 if (! action->execute (resolver))
00098 {
00099 ret = false;
00100 break;
00101 }
00102 }
00103 return true;
00104 }
00105
00106
00110 void
00111 ProblemSolution::addAction (solver::detail::SolutionAction_constPtr action)
00112 {
00113 _actions.push_back (action);
00114 }
00115
00116
00117 void
00118 ProblemSolution::clear()
00119 {
00120 _actions.clear();
00121 }
00122
00124 };