libzypp 17.37.17
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
31#include <utility>
32
33using std::endl;
34
36namespace zypp
37{
39 namespace solver
40 {
42 namespace detail
43 {
44
45
47
48//---------------------------------------------------------------------------
49
50std::ostream &
51SolverQueueItemInstallOneOf::dumpOn( std::ostream & os ) const
52{
53 os << "[" << (_soft?"Soft":"") << "InstallOneOf: ";
54 for (PoolItemList::const_iterator iter = _oneOfList.begin();
55 iter != _oneOfList.end();
56 iter++)
57 os << *iter;
58 os << "]";
59
60 return os;
61}
62
63//---------------------------------------------------------------------------
64
66 bool soft)
67 : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL_ONE_OF, pool)
68 , _oneOfList (std::move(itemList))
69 , _soft (soft)
70{
71}
72
73
77
78//---------------------------------------------------------------------------
79
81{
82 bool ret = true;
83 MIL << "Install one of " << (_soft ? "(soft):" : ":")<< endl;
84 Queue qs;
85
86 if (_soft) {
87 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_ONE_OF | SOLVER_WEAK);
88 } else {
89 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_ONE_OF );
90 }
91
92 queue_init(&qs);
93 for (PoolItemList::const_iterator iter = _oneOfList.begin(); iter != _oneOfList.end(); iter++) {
94 Id id = (*iter)->satSolvable().id();
95 if (id == ID_NULL) {
96 ERR << *iter << " not found" << endl;
97 ret = false;
98 } else {
99 MIL << " candidate:" << *iter << " with the SAT-Pool ID: " << id << endl;
100 queue_push( &(qs), id );
101 }
102 }
103 sat::Pool satPool( sat::Pool::instance() );
104 queue_push( &(q), pool_queuetowhatprovides(satPool.get(), &qs));
105 queue_free(&qs);
106
107 return ret;
108}
109
110SolverQueueItem_Ptr
112{
113 SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList);
114 new_installOneOf->SolverQueueItem::copy(this);
115 new_installOneOf->_soft = _soft;
116
117 return new_installOneOf;
118}
119
120int
121SolverQueueItemInstallOneOf::cmp (SolverQueueItem_constPtr item) const
122{
123 int cmp = this->compare (item);
124 if (cmp != 0)
125 return cmp;
126 SolverQueueItemInstallOneOf_constPtr install = dynamic_pointer_cast<const SolverQueueItemInstallOneOf>(item);
127
128 return (_oneOfList == install->_oneOfList) ? 0 : -1; // more evaluation would be not useful
129}
130
131
132//---------------------------------------------------------------------------
133
134
136 };// namespace detail
139 };// namespace solver
142};// namespace zypp
Global ResObject pool.
Definition ResPool.h:62
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
virtual int cmp(SolverQueueItem_constPtr item) const
SolverQueueItemInstallOneOf(const ResPool &pool, PoolItemList itemList, bool soft=false)
virtual std::ostream & dumpOn(std::ostream &str) const
Definition Arch.h:364
::s_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition PoolMember.h:62
Easy-to use interface to the ZYPP dependency resolver.
#define MIL
Definition Logger.h:100
#define ERR
Definition Logger.h:102
#define IMPL_PTR_TYPE(NAME)