libzypp 17.31.23
SolverQueueItemInstallOneOf.cc
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
2/* SolverQueueItem.cc
3 *
4 * Copyright (C) 2008 SUSE Linux Products GmbH
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License,
8 * version 2, as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 * 02111-1307, USA.
19 */
20extern "C"
21{
22#include <solv/solver.h>
23}
24
25#define ZYPP_USE_RESOLVER_INTERNALS
26
27#include <zypp/base/Logger.h>
29#include <zypp/sat/Pool.h>
30
31using std::endl;
32
34namespace zypp
35{
37 namespace solver
38 {
40 namespace detail
41 {
42
43
45
46//---------------------------------------------------------------------------
47
48std::ostream &
49SolverQueueItemInstallOneOf::dumpOn( std::ostream & os ) const
50{
51 os << "[" << (_soft?"Soft":"") << "InstallOneOf: ";
52 for (PoolItemList::const_iterator iter = _oneOfList.begin();
53 iter != _oneOfList.end();
54 iter++)
55 os << *iter;
56 os << "]";
57
58 return os;
59}
60
61//---------------------------------------------------------------------------
62
64 bool soft)
65 : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL_ONE_OF, pool)
66 , _oneOfList (itemList)
67 , _soft (soft)
68{
69}
70
71
73{
74}
75
76//---------------------------------------------------------------------------
77
79{
80 bool ret = true;
81 MIL << "Install one of " << (_soft ? "(soft):" : ":")<< endl;
82 Queue qs;
83
84 if (_soft) {
85 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_ONE_OF | SOLVER_WEAK);
86 } else {
87 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_ONE_OF );
88 }
89
90 queue_init(&qs);
91 for (PoolItemList::const_iterator iter = _oneOfList.begin(); iter != _oneOfList.end(); iter++) {
92 Id id = (*iter)->satSolvable().id();
93 if (id == ID_NULL) {
94 ERR << *iter << " not found" << endl;
95 ret = false;
96 } else {
97 MIL << " candidate:" << *iter << " with the SAT-Pool ID: " << id << endl;
98 queue_push( &(qs), id );
99 }
100 }
101 sat::Pool satPool( sat::Pool::instance() );
102 queue_push( &(q), pool_queuetowhatprovides(satPool.get(), &qs));
103 queue_free(&qs);
104
105 return ret;
106}
107
108SolverQueueItem_Ptr
110{
111 SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList);
112 new_installOneOf->SolverQueueItem::copy(this);
113 new_installOneOf->_soft = _soft;
114
115 return new_installOneOf;
116}
117
118int
119SolverQueueItemInstallOneOf::cmp (SolverQueueItem_constPtr item) const
120{
121 int cmp = this->compare (item);
122 if (cmp != 0)
123 return cmp;
124 SolverQueueItemInstallOneOf_constPtr install = dynamic_pointer_cast<const SolverQueueItemInstallOneOf>(item);
125
126 return (_oneOfList == install->_oneOfList) ? 0 : -1; // more evaluation would be not useful
127}
128
129
130//---------------------------------------------------------------------------
131
132
134 };// namespace detail
137 };// namespace solver
140};// namespace zypp
Global ResObject pool.
Definition: ResPool.h:61
Global sat-pool.
Definition: Pool.h:47
static Pool instance()
Singleton ctor.
Definition: Pool.h:55
detail::CPool * get() const
Expert backdoor.
Definition: Pool.cc:49
SolverQueueItemInstallOneOf(const ResPool &pool, const PoolItemList &itemList, bool soft=false)
virtual int cmp(SolverQueueItem_constPtr item) const
virtual std::ostream & dumpOn(std::ostream &str) const
::s_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:62
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
#define MIL
Definition: Logger.h:96
#define ERR
Definition: Logger.h:98
#define IMPL_PTR_TYPE(NAME)