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

libzypp 17.25.10

SolverQueueItemDelete.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/IdString.h>
29 #include <zypp/Resolver.h>
30 #include <zypp/solver/detail/SolverQueueItemDelete.h>
31
32 using std::endl;
33
35 namespace zypp
36 {
38 namespace solver
39 {
41 namespace detail
42 {
43
44
45 IMPL_PTR_TYPE(SolverQueueItemDelete);
46
47 //---------------------------------------------------------------------------
48
49 std::ostream &
50 SolverQueueItemDelete::dumpOn( std::ostream & os ) const
51 {
52 os << "[" << (_soft?"Soft":"") << "Delete: "
53 << _name << "]";
54
55 return os;
56 }
57
58 //---------------------------------------------------------------------------
59
60 SolverQueueItemDelete::SolverQueueItemDelete (const ResPool & pool, std::string name, bool soft)
61 : SolverQueueItem (QUEUE_ITEM_TYPE_DELETE, pool)
62 , _name (name)
63 , _soft (soft)
64 {
65 }
66
67
68 SolverQueueItemDelete::~SolverQueueItemDelete()
69 {
70 }
71
72 //---------------------------------------------------------------------------
73
74 bool SolverQueueItemDelete::addRule (sat::detail::CQueue & q)
75 {
76 #define MAYBE_CLEANDEPS (pool().resolver().cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
77
78 ::Id id = IdString(_name).id();
79 if (_soft) {
80 queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
81 } else {
82 queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS );
83 }
84 queue_push( &(q), id);
85
86 MIL << "Delete " << _name << (_soft ? "(soft)" : "")
87 << " with SAT-Pool: " << id << endl;
88 return true;
89 }
90
91 SolverQueueItem_Ptr
92 SolverQueueItemDelete::copy (void) const
93 {
94 SolverQueueItemDelete_Ptr new_delete = new SolverQueueItemDelete (pool(), _name);
95 new_delete->SolverQueueItem::copy(this);
96
97 new_delete->_soft = _soft;
98 return new_delete;
99 }
100
101 int
102 SolverQueueItemDelete::cmp (SolverQueueItem_constPtr item) const
103 {
104 int cmp = this->compare (item);
105 if (cmp != 0)
106 return cmp;
107 SolverQueueItemDelete_constPtr del = dynamic_pointer_cast<const SolverQueueItemDelete>(item);
108 if (_name != del->_name) {
109 return _name.compare(del->_name);
110 }
111 return 0;
112 }
113
114 //---------------------------------------------------------------------------
115
116
118 };// namespace detail
121 };// namespace solver
124 };// namespace zypp
IdString.h
Logger.h
MIL
#define MIL
Definition: Logger.h:91
Resolver.h
MAYBE_CLEANDEPS
#define MAYBE_CLEANDEPS
SolverQueueItemDelete.h
SolverQueueItem
zypp::IdString
Access to the sat-pools string space.
Definition: IdString.h:43
zypp::IdString::id
IdType id() const
Expert backdoor.
Definition: IdString.h:122
zypp::ResPool
Global ResObject pool.
Definition: ResPool.h:61
zypp::solver::detail::SolverQueueItemDelete
Definition: SolverQueueItemDelete.h:45
zypp::solver::detail::SolverQueueItemDelete::dumpOn
virtual std::ostream & dumpOn(std::ostream &str) const
Definition: SolverQueueItemDelete.cc:50
zypp::solver::detail::SolverQueueItemDelete::SolverQueueItemDelete
SolverQueueItemDelete(const ResPool &pool, std::string name, bool soft=false)
Definition: SolverQueueItemDelete.cc:60
zypp::solver::detail::SolverQueueItemDelete::_soft
bool _soft
Definition: SolverQueueItemDelete.h:50
zypp::solver::detail::SolverQueueItemDelete::_name
std::string _name
Definition: SolverQueueItemDelete.h:49
zypp::solver::detail::SolverQueueItemDelete::~SolverQueueItemDelete
virtual ~SolverQueueItemDelete()
Definition: SolverQueueItemDelete.cc:68
zypp::solver::detail::SolverQueueItemDelete::addRule
virtual bool addRule(sat::detail::CQueue &q)
Definition: SolverQueueItemDelete.cc:74
zypp::solver::detail::SolverQueueItemDelete::copy
virtual SolverQueueItem_Ptr copy(void) const
Definition: SolverQueueItemDelete.cc:92
zypp::solver::detail::SolverQueueItemDelete::cmp
virtual int cmp(SolverQueueItem_constPtr item) const
Definition: SolverQueueItemDelete.cc:102
zypp::sat::detail::CQueue
::s_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:62
zypp::solver::detail::IMPL_PTR_TYPE
IMPL_PTR_TYPE(SATResolver)
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2