libzypp: zypp/solver/detail/SolverQueueItemInstall.cc Source File

libzypp 17.38.9

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