libzypp  15.28.6
SolverQueueItemInstall.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/IdStringType.h"
31 
33 namespace zypp
34 {
35  namespace solver
37  {
38  namespace detail
40  {
41 
42 using namespace std;
43 
44 IMPL_PTR_TYPE(SolverQueueItemInstall);
45 
46 //---------------------------------------------------------------------------
47 
48 std::ostream &
49 SolverQueueItemInstall::dumpOn( std::ostream & os ) const
50 {
51  os << "[" << (_soft?"Soft":"") << "Install: "
52  << _name
53  << "]";
54 
55  return os;
56 }
57 
58 //---------------------------------------------------------------------------
59 
60 SolverQueueItemInstall::SolverQueueItemInstall (const ResPool & pool, std::string name, bool soft)
61  : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL, pool)
62  , _name (name)
63  , _soft (soft)
64 {
65 }
66 
67 
69 {
70 }
71 
72 //---------------------------------------------------------------------------
73 
75 {
76  ::Id id = IdString(_name).id();
77  if (_soft) {
78  queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_WEAK );
79  } else {
80  queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME );
81  }
82  queue_push( &(q), id);
83 
84  MIL << "Install " << _name << (_soft ? "(soft)" : "")
85  << " with SAT-PoolID: " << id << endl;
86  return true;
87 }
88 
89 SolverQueueItem_Ptr
91 {
92  SolverQueueItemInstall_Ptr new_install = new SolverQueueItemInstall (pool(), _name);
93  new_install->SolverQueueItem::copy(this);
94 
95  new_install->_soft = _soft;
96  return new_install;
97 }
98 
99 int
100 SolverQueueItemInstall::cmp (SolverQueueItem_constPtr item) const
101 {
102  int cmp = this->compare (item);
103  if (cmp != 0)
104  return cmp;
105  SolverQueueItemInstall_constPtr ins = dynamic_pointer_cast<const SolverQueueItemInstall>(item);
106  if (_name != ins->_name) {
107  return _name.compare(ins->_name);
108  }
109  return 0;
110 }
111 
112 
113 //---------------------------------------------------------------------------
114 
115 
117  };// namespace detail
120  };// namespace solver
123 };// namespace zypp
#define MIL
Definition: Logger.h:64
IdType id() const
Expert backdoor.
Definition: IdString.h:115
Access to the sat-pools string space.
Definition: IdString.h:41
virtual SolverQueueItem_Ptr copy(void) const
SolverQueueItemInstall(const ResPool &pool, std::string name, bool soft=false)
virtual std::ostream & dumpOn(std::ostream &str) const
Global ResObject pool.
Definition: ResPool.h:60
IMPL_PTR_TYPE(SATResolver)
::_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolMember.h:87
virtual int cmp(SolverQueueItem_constPtr item) const
virtual bool addRule(sat::detail::CQueue &q)