libzypp  13.10.6
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 #include "zypp/base/Logger.h"
27 
29 namespace zypp
30 {
31  namespace solver
33  {
34  namespace detail
36  {
37 
38 using namespace std;
39 
40 IMPL_PTR_TYPE(SolverQueueItemLock);
41 
42 //---------------------------------------------------------------------------
43 
44 std::ostream &
45 SolverQueueItemLock::dumpOn( std::ostream & os ) const
46 {
47  os << "[" << (_soft?"Soft":"") << "Lock: " <<
48  _item << "]";
49 
50  return os;
51 }
52 
53 //---------------------------------------------------------------------------
54 
56  const PoolItem & item, bool soft)
58  , _item (item)
59  , _soft (soft)
60 {
61 }
62 
63 
65 {
66 }
67 
68 //---------------------------------------------------------------------------
69 
71 {
72  ::Id id = _item.satSolvable().id();
73  if (id == ID_NULL) {
74  ERR << "Lock : " << _item << " not found" << endl;
75  return false;
76  }
77  MIL << "Lock " << _item << " with the SAT-Pool ID: " << id << endl;
78  if (_item.status().isInstalled()) {
79  if (_soft) {
80  queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE | SOLVER_WEAK );
81  } else {
82  queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE );
83  }
84  } else {
85  if (_soft) {
86  queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE | SOLVER_WEAK );
87  } else {
88  queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE );
89  }
90  }
91  queue_push( &(q), id );
92  return true;
93 }
94 
95 SolverQueueItem_Ptr
97 {
98  SolverQueueItemLock_Ptr new_lock = new SolverQueueItemLock (pool(), _item);
99  new_lock->SolverQueueItem::copy(this);
100 
101  new_lock->_soft = _soft;
102  return new_lock;
103 }
104 
105 int
106 SolverQueueItemLock::cmp (SolverQueueItem_constPtr item) const
107 {
108  int cmp = this->compare (item);
109  if (cmp != 0)
110  return cmp;
111  SolverQueueItemLock_constPtr lock = dynamic_pointer_cast<const SolverQueueItemLock>(item);
112  return compareByNVRA (_item.resolvable(), lock->_item.resolvable());
113 }
114 
115 
116 //---------------------------------------------------------------------------
117 
118 
120  };// namespace detail
123  };// namespace solver
126 };// namespace zypp
#define MIL
Definition: Logger.h:47
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream &amp; operator&lt;&lt;.
#define ERR
Definition: Logger.h:49
bool isInstalled() const
Definition: ResStatus.h:228
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
Definition: PoolItem.cc:280
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:241
Global ResObject pool.
Definition: ResPool.h:48
IMPL_PTR_TYPE(ProblemSolutionCombi)
virtual SolverQueueItem_Ptr copy(void) const
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: PoolItem.h:114
virtual int cmp(SolverQueueItem_constPtr item) const
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
IdType id() const
Expert backdoor.
Definition: Solvable.h:296
int compare(SolverQueueItem_constPtr item) const
SolverQueueItemLock(const ResPool &pool, const PoolItem &item, bool soft=false)