libzypp
10.5.0
|
00001 00002 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 00003 /* ProblemSolution.cc 00004 * 00005 * Easy-to use interface to the ZYPP dependency resolver 00006 * 00007 * Copyright (C) 2000-2002 Ximian, Inc. 00008 * Copyright (C) 2005 SUSE Linux Products GmbH 00009 * 00010 * This program is free software; you can redistribute it and/or 00011 * modify it under the terms of the GNU General Public License, 00012 * version 2, as published by the Free Software Foundation. 00013 * 00014 * This program is distributed in the hope that it will be useful, but 00015 * WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00022 * 02111-1307, USA. 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 WAR << "apply solution action failed: " << action << endl; 00100 ret = false; 00101 break; 00102 } 00103 } 00104 return ret; 00105 } 00106 00107 00111 void 00112 ProblemSolution::addAction (solver::detail::SolutionAction_constPtr action) 00113 { 00114 _actions.push_back (action); 00115 } 00116 00117 00118 void 00119 ProblemSolution::clear() 00120 { 00121 _actions.clear(); 00122 } 00123 00125 };// namespace zypp