libzypp  11.13.5
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 #include "zypp/base/Logger.h"
26 #include "zypp/IdString.h"
27 #include "zypp/Resolver.h"
29 
31 namespace zypp
32 {
33 
34  namespace solver
35  {
36 
37  namespace detail
38  {
39 
40 using namespace std;
41 
42 IMPL_PTR_TYPE(SolverQueueItemDelete);
43 
44 //---------------------------------------------------------------------------
45 
46 std::ostream &
47 SolverQueueItemDelete::dumpOn( std::ostream & os ) const
48 {
49  os << "[" << (_soft?"Soft":"") << "Delete: "
50  << _name << "]";
51 
52  return os;
53 }
54 
55 //---------------------------------------------------------------------------
56 
57 SolverQueueItemDelete::SolverQueueItemDelete (const ResPool & pool, std::string name, bool soft)
59  , _name (name)
60  , _soft (soft)
61 {
62 }
63 
64 
66 {
67 }
68 
69 //---------------------------------------------------------------------------
70 
72 {
73 #define MAYBE_CLEANDEPS (pool().resolver().cleandepsOnRemove()?SOLVER_CLEANDEPS:0)
74 
75  ::Id id = IdString(_name).id();
76  if (_soft) {
77  queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS );
78  } else {
79  queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS );
80  }
81  queue_push( &(q), id);
82 
83  MIL << "Delete " << _name << (_soft ? "(soft)" : "")
84  << " with SAT-Pool: " << id << endl;
85  return true;
86 }
87 
88 SolverQueueItem_Ptr
90 {
91  SolverQueueItemDelete_Ptr new_delete = new SolverQueueItemDelete (pool(), _name);
92  new_delete->SolverQueueItem::copy(this);
93 
94  new_delete->_soft = _soft;
95  return new_delete;
96 }
97 
98 int
99 SolverQueueItemDelete::cmp (SolverQueueItem_constPtr item) const
100 {
101  int cmp = this->compare (item);
102  if (cmp != 0)
103  return cmp;
104  SolverQueueItemDelete_constPtr del = dynamic_pointer_cast<const SolverQueueItemDelete>(item);
105  if (_name != del->_name) {
106  return _name.compare(del->_name);
107  }
108  return 0;
109 }
110 
111 //---------------------------------------------------------------------------
112 
113 
115  };// namespace detail
118  };// namespace solver
121 };// namespace zypp