libzypp: zypp/solver/detail/SolverQueueItemLock.cc Source File

libzypp 17.25.10

SolverQueueItemLock.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 */
20 extern "C"
21 {
22 #include <solv/solver.h>
23 }
24
25 #define ZYPP_USE_RESOLVER_INTERNALS
26
27 #include <zypp/base/Logger.h>
28 #include <zypp/solver/detail/SolverQueueItemLock.h>
29
30 using std::endl;
31
33 namespace zypp
34 {
36 namespace solver
37 {
39 namespace detail
40 {
41
42
43 IMPL_PTR_TYPE(SolverQueueItemLock);
44
45 //---------------------------------------------------------------------------
46
47 std::ostream &
48 SolverQueueItemLock::dumpOn( std::ostream & os ) const
49 {
50 os << "[" << (_soft?"Soft":"") << "Lock: " <<
51 _item << "]";
52
53 return os;
54 }
55
56 //---------------------------------------------------------------------------
57
58 SolverQueueItemLock::SolverQueueItemLock (const ResPool & pool,
59 const PoolItem & item, bool soft)
60 : SolverQueueItem (QUEUE_ITEM_TYPE_LOCK, pool)
61 , _item (item)
62 , _soft (soft)
63 {
64 }
65
66
67 SolverQueueItemLock::~SolverQueueItemLock()
68 {
69 }
70
71 //---------------------------------------------------------------------------
72
73 bool SolverQueueItemLock::addRule (sat::detail::CQueue & q)
74 {
75 ::Id id = _item.satSolvable().id();
76 if (id == ID_NULL) {
77 ERR << "Lock : " << _item << " not found" << endl;
78 return false;
79 }
80 MIL << "Lock " << _item << " with the SAT-Pool ID: " << id << endl;
81 if (_item.status().isInstalled()) {
82 if (_soft) {
83 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE | SOLVER_WEAK );
84 } else {
85 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE );
86 }
87 } else {
88 if (_soft) {
89 queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE | SOLVER_WEAK );
90 } else {
91 queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE );
92 }
93 }
94 queue_push( &(q), id );
95 return true;
96 }
97
98 SolverQueueItem_Ptr
99 SolverQueueItemLock::copy (void) const
100 {
101 SolverQueueItemLock_Ptr new_lock = new SolverQueueItemLock (pool(), _item);
102 new_lock->SolverQueueItem::copy(this);
103
104 new_lock->_soft = _soft;
105 return new_lock;
106 }
107
108 int
109 SolverQueueItemLock::cmp (SolverQueueItem_constPtr item) const
110 {
111 int cmp = this->compare (item);
112 if (cmp != 0)
113 return cmp;
114 SolverQueueItemLock_constPtr lock = dynamic_pointer_cast<const SolverQueueItemLock>(item);
115 return compareByNVRA (_item, lock->_item);
116 }
117
118
119 //---------------------------------------------------------------------------
120
121
123 };// namespace detail
126 };// namespace solver
129 };// namespace zypp
Logger.h
MIL
#define MIL
Definition: Logger.h:91
ERR
#define ERR
Definition: Logger.h:93
SolverQueueItemLock.h
SolverQueueItem
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:51
zypp::PoolItem::status
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:204
zypp::ResPool
Global ResObject pool.
Definition: ResPool.h:61
zypp::ResStatus::isInstalled
bool isInstalled() const
Definition: ResStatus.h:240
zypp::sat::Solvable::id
IdType id() const
Expert backdoor.
Definition: Solvable.h:399
zypp::solver::detail::SolverQueueItemLock
Definition: SolverQueueItemLock.h:44
zypp::solver::detail::SolverQueueItemLock::~SolverQueueItemLock
virtual ~SolverQueueItemLock()
Definition: SolverQueueItemLock.cc:67
zypp::solver::detail::SolverQueueItemLock::copy
virtual SolverQueueItem_Ptr copy(void) const
Definition: SolverQueueItemLock.cc:99
zypp::solver::detail::SolverQueueItemLock::addRule
virtual bool addRule(sat::detail::CQueue &q)
Definition: SolverQueueItemLock.cc:73
zypp::solver::detail::SolverQueueItemLock::cmp
virtual int cmp(SolverQueueItem_constPtr item) const
Definition: SolverQueueItemLock.cc:109
zypp::solver::detail::SolverQueueItemLock::_item
PoolItem _item
Definition: SolverQueueItemLock.h:48
zypp::solver::detail::SolverQueueItemLock::_soft
bool _soft
Definition: SolverQueueItemLock.h:49
zypp::solver::detail::SolverQueueItemLock::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: SolverQueueItemLock.cc:48
zypp::solver::detail::SolverQueueItemLock::SolverQueueItemLock
SolverQueueItemLock(const ResPool &pool, const PoolItem &item, bool soft=false)
Definition: SolverQueueItemLock.cc:58
zypp::sat::detail::CQueue
::s_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:62
zypp::sat::compareByNVRA
bool compareByNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: SolvableType.h:269
zypp::solver::detail::IMPL_PTR_TYPE
IMPL_PTR_TYPE(SATResolver)
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::sat::SolvableType::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57