1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
4 * Easy-to use interface to the ZYPP dependency resolver
6 * Copyright (C) 2000-2002 Ximian, Inc.
7 * Copyright (C) 2005 SUSE Linux Products GmbH
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License,
11 * version 2, as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
24 #include "zypp/base/LogTools.h"
26 #include "zypp/ResolverProblem.h"
27 #include "zypp/ProblemSolution.h"
31 /////////////////////////////////////////////////////////////////////////
34 IMPL_PTR_TYPE(ResolverProblem);
36 ///////////////////////////////////////////////////////////////////
37 /// \class ResolverProblem::Impl
38 /// \brief ResolverProblem implementation.
39 ///////////////////////////////////////////////////////////////////
40 struct ResolverProblem::Impl
45 Impl( std::string && description )
46 : _description( std::move(description) )
49 Impl( std::string && description, std::string && details )
50 : _description( std::move(description) )
51 , _details( std::move(details) )
54 std::string _description;
56 ProblemSolutionList _solutions;
59 friend Impl * rwcowClone<Impl>( const Impl * rhs );
60 /** clone for RWCOW_pointer */
62 { return new Impl( *this ); }
64 ///////////////////////////////////////////////////////////////////
66 ResolverProblem::ResolverProblem()
67 : _pimpl( new Impl() )
70 ResolverProblem::ResolverProblem( std::string description )
71 : _pimpl( new Impl( std::move(description) ) )
74 ResolverProblem::ResolverProblem( std::string description, std::string details )
75 : _pimpl( new Impl( std::move(description), std::move(details) ) )
78 ResolverProblem::~ResolverProblem()
82 const std::string & ResolverProblem::description() const
83 { return _pimpl->_description; }
85 const std::string & ResolverProblem::details() const
86 { return _pimpl->_details; }
88 const ProblemSolutionList & ResolverProblem::solutions() const
89 { return _pimpl->_solutions; }
92 void ResolverProblem::setDescription( std::string description )
93 { _pimpl->_description = std::move(description); }
95 void ResolverProblem::setDetails( std::string details )
96 { _pimpl->_details = std::move(details); }
98 void ResolverProblem::addSolution( ProblemSolution_Ptr solution, bool inFront )
101 { _pimpl->_solutions.push_front( solution ); }
103 { _pimpl->_solutions.push_back( solution ); }
107 std::ostream & operator<<( std::ostream & os, const ResolverProblem & obj )
109 os << "Problem:" << endl;
110 os << "==============================" << endl;
111 os << obj.description() << endl;
112 os << obj.details() << endl;
113 os << "------------------------------" << endl;
114 os << obj.solutions();
115 os << "==============================" << endl;
119 std::ostream & operator<<( std::ostream & os, const ResolverProblemList & obj )
120 { return dumpRange( os, obj.begin(), obj.end(), "", "", ", ", "", "" ); }
123 /////////////////////////////////////////////////////////////////////////