libzypp  17.35.8
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>
31 
32 #include <utility>
33 
34 using std::endl;
35 
37 namespace zypp
38 {
39  namespace solver
41  {
42  namespace detail
44  {
45 
46 
47 IMPL_PTR_TYPE(SolverQueueItemDelete);
48 
49 //---------------------------------------------------------------------------
50 
51 std::ostream &
52 SolverQueueItemDelete::dumpOn( std::ostream & os ) const
53 {
54  os << "[" << (_soft?"Soft":"") << "Delete: "
55  << _name << "]";
56 
57  return os;
58 }
59 
60 //---------------------------------------------------------------------------
61 
62 SolverQueueItemDelete::SolverQueueItemDelete (const ResPool & pool, std::string name, bool soft)
63  : SolverQueueItem (QUEUE_ITEM_TYPE_DELETE, pool)
64  , _name (std::move(name))
65  , _soft (soft)
66 {
67 }
68 
69 
71 {
72 }
73 
74 //---------------------------------------------------------------------------
75 
77 {
78 #define MAYBE_CLEANDEPS (pool().resolver().cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
79 
80  ::Id id = IdString(_name).id();
81  if (_soft) {
82  queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
83  } else {
84  queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS );
85  }
86  queue_push( &(q), id);
87 
88  MIL << "Delete " << _name << (_soft ? "(soft)" : "")
89  << " with SAT-Pool: " << id << endl;
90  return true;
91 }
92 
93 SolverQueueItem_Ptr
95 {
96  SolverQueueItemDelete_Ptr new_delete = new SolverQueueItemDelete (pool(), _name);
97  new_delete->SolverQueueItem::copy(this);
98 
99  new_delete->_soft = _soft;
100  return new_delete;
101 }
102 
103 int
104 SolverQueueItemDelete::cmp (SolverQueueItem_constPtr item) const
105 {
106  int cmp = this->compare (item);
107  if (cmp != 0)
108  return cmp;
109  SolverQueueItemDelete_constPtr del = dynamic_pointer_cast<const SolverQueueItemDelete>(item);
110  if (_name != del->_name) {
111  return _name.compare(del->_name);
112  }
113  return 0;
114 }
115 
116 //---------------------------------------------------------------------------
117 
118 
120  };// namespace detail
123  };// namespace solver
126 };// namespace zypp
#define MIL
Definition: Logger.h:98
virtual SolverQueueItem_Ptr copy(void) const
#define MAYBE_CLEANDEPS
virtual std::ostream & dumpOn(std::ostream &str) const
IdType id() const
Expert backdoor.
Definition: IdString.h:133
SolverQueueItemDelete(const ResPool &pool, std::string name, bool soft=false)
Definition: Arch.h:363
Global ResObject pool.
Definition: ResPool.h:61
virtual int cmp(SolverQueueItem_constPtr item) const
virtual bool addRule(sat::detail::CQueue &q)
IMPL_PTR_TYPE(SATResolver)
::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: Application.cc:19
zypp::IdString IdString
Definition: idstring.h:16