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