libzypp  15.28.6
SolverQueueItemUpdate.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"
29 
31 namespace zypp
32 {
33  namespace solver
35  {
36  namespace detail
38  {
39 
40 using namespace std;
41 
42 IMPL_PTR_TYPE(SolverQueueItemUpdate);
43 
44 //---------------------------------------------------------------------------
45 
46 std::ostream &
47 SolverQueueItemUpdate::dumpOn( std::ostream & os ) const
48 {
49  os << "[" << (_soft?"Soft":"") << "Update: " <<
50  _item << "]";
51 
52  return os;
53 }
54 
55 //---------------------------------------------------------------------------
56 
58  const PoolItem & item, bool soft)
59  : SolverQueueItem (QUEUE_ITEM_TYPE_UPDATE, pool)
60  , _item (item)
61  , _soft (soft)
62 {
63 }
64 
65 
67 {
68 }
69 
70 //---------------------------------------------------------------------------
71 
73 {
74  ::Id id = _item.satSolvable().id();
75  if (id == ID_NULL) {
76  ERR << "Update explicit: " << _item << " not found" << endl;
77  return false;
78  }
79  MIL << "Update explicit " << _item << " with the SAT-Pool ID: " << id << endl;
80  queue_push( &(q), SOLVER_UPDATE | SOLVER_SOLVABLE );
81  queue_push( &(q), id );
82  return true;
83 }
84 
85 SolverQueueItem_Ptr
87 {
88  SolverQueueItemUpdate_Ptr new_update = new SolverQueueItemUpdate (pool(), _item);
89  new_update->SolverQueueItem::copy(this);
90 
91  new_update->_soft = _soft;
92  return new_update;
93 }
94 
95 int
96 SolverQueueItemUpdate::cmp (SolverQueueItem_constPtr item) const
97 {
98  int cmp = this->compare (item);
99  if (cmp != 0)
100  return cmp;
101  SolverQueueItemUpdate_constPtr update = dynamic_pointer_cast<const SolverQueueItemUpdate>(item);
102  return compareByNVRA (_item, update->_item);
103 }
104 
105 
106 //---------------------------------------------------------------------------
107 
108 
110  };// namespace detail
113  };// namespace solver
116 };// namespace zypp
#define MIL
Definition: Logger.h:64
SolverQueueItemUpdate(const ResPool &pool, const PoolItem &item, bool soft=false)
virtual SolverQueueItem_Ptr copy(void) const
bool compareByNVRA(const SolvableType< Derived > &lhs, const Solvable &rhs)
Definition: SolvableType.h:265
#define ERR
Definition: Logger.h:66
virtual std::ostream & dumpOn(std::ostream &str) const
virtual int cmp(SolverQueueItem_constPtr item) const
virtual bool addRule(sat::detail::CQueue &q)
Global ResObject pool.
Definition: ResPool.h:60
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
IMPL_PTR_TYPE(SATResolver)
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
IdType id() const
Expert backdoor.
Definition: Solvable.h:374
::_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:87