libzypp  13.10.6
ProblemSolution.cc
Go to the documentation of this file.
1 
2 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
3 /* ProblemSolution.cc
4  *
5  * Easy-to use interface to the ZYPP dependency resolver
6  *
7  * Copyright (C) 2000-2002 Ximian, Inc.
8  * Copyright (C) 2005 SUSE Linux Products GmbH
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License,
12  * version 2, as published by the Free Software Foundation.
13  *
14  * This program is distributed in the hope that it will be useful, but
15  * WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22  * 02111-1307, USA.
23  */
26 #include "zypp/ProblemSolution.h"
27 #include "zypp/base/Logger.h"
29 
30 using namespace std;
31 
33 namespace zypp
34 {
35 
36 IMPL_PTR_TYPE(ProblemSolution);
37 
38 //---------------------------------------------------------------------------
39 
40 ostream&
41 operator<<( ostream& os, const ProblemSolution & solution)
42 {
43  os << "Solution:" << endl;
44  os << solution._description << endl;
45  if ( ! solution._details.empty() )
46  os << solution._details << endl;
47  os << solution._actions;
48  return os;
49 }
50 
51 ostream&
52 operator<<( ostream& os, const ProblemSolutionList & solutionlist)
53 {
54  for (ProblemSolutionList::const_iterator iter = solutionlist.begin(); iter != solutionlist.end(); ++iter) {
55  os << *(*iter);
56  }
57  return os;
58 }
59 
60 ostream&
61 operator<<( ostream& os, const CProblemSolutionList & solutionlist)
62 {
63  for (CProblemSolutionList::const_iterator iter = solutionlist.begin(); iter != solutionlist.end(); ++iter) {
64  os << *(*iter) << endl;
65  }
66  return os;
67 }
68 
69 //---------------------------------------------------------------------------
70 
71 ProblemSolution::ProblemSolution( ResolverProblem_Ptr parent, const string & description, const string & details )
72  : _problem (parent)
73  , _description (description)
74  , _details (details)
75 {
76 }
77 
78 
80 {
81 }
82 
83 
90 bool
92 {
93  DBG << "apply solution " << *this << endl;
94  bool ret = true;
95  for (solver::detail::CSolutionActionList::const_iterator iter = _actions.begin();
96  iter != _actions.end(); ++iter) {
97  solver::detail::SolutionAction_constPtr action = *iter;
98  if (! action->execute (resolver))
99  {
100  WAR << "apply solution action failed: " << action << endl;
101  ret = false;
102  break;
103  }
104  }
105  return ret;
106 }
107 
108 
112 void
113 ProblemSolution::addAction (solver::detail::SolutionAction_constPtr action)
114 {
115  _actions.push_back (action);
116 }
117 
118 
119 void
121 {
122  _actions.clear();
123 }
124 
126 };// namespace zypp
std::list< ProblemSolution_Ptr > ProblemSolutionList
Definition: ProblemTypes.h:42
void addAction(solver::detail::SolutionAction_constPtr action)
Add an action to the actions list.
void clear()
Clear all data.
A mid layer class we should remove.
Definition: Resolver.h:101
#define WAR
Definition: Logger.h:48
std::ostream & operator<<(std::ostream &str, const ::_Dataiterator *obj)
Definition: LookupAttr.cc:799
bool apply(solver::detail::Resolver &resolver)
Apply this solution, i.e.
solver::detail::CSolutionActionList _actions
Class representing one possible solution to one problem found during resolving.
#define IMPL_PTR_TYPE(NAME)
#define DBG
Definition: Logger.h:46
~ProblemSolution()
Destructor.
std::list< ProblemSolution_constPtr > CProblemSolutionList
Definition: ProblemTypes.h:43