libzypp  13.10.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 #include "zypp/base/Logger.h"
26 #include "zypp/IdString.h"
27 #include "zypp/IdStringType.h"
29 
31 namespace zypp
32 {
33  namespace solver
35  {
36  namespace detail
38  {
39 
40 using namespace std;
41 
42 IMPL_PTR_TYPE(SolverQueueItemInstall);
43 
44 //---------------------------------------------------------------------------
45 
46 std::ostream &
47 SolverQueueItemInstall::dumpOn( std::ostream & os ) const
48 {
49  os << "[" << (_soft?"Soft":"") << "Install: "
50  << _name
51  << "]";
52 
53  return os;
54 }
55 
56 //---------------------------------------------------------------------------
57 
58 SolverQueueItemInstall::SolverQueueItemInstall (const ResPool & pool, std::string name, bool soft)
60  , _name (name)
61  , _soft (soft)
62 {
63 }
64 
65 
67 {
68 }
69 
70 //---------------------------------------------------------------------------
71 
73 {
74  ::Id id = IdString(_name).id();
75  if (_soft) {
76  queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_WEAK );
77  } else {
78  queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME );
79  }
80  queue_push( &(q), id);
81 
82  MIL << "Install " << _name << (_soft ? "(soft)" : "")
83  << " with SAT-PoolID: " << id << endl;
84  return true;
85 }
86 
87 SolverQueueItem_Ptr
89 {
90  SolverQueueItemInstall_Ptr new_install = new SolverQueueItemInstall (pool(), _name);
91  new_install->SolverQueueItem::copy(this);
92 
93  new_install->_soft = _soft;
94  return new_install;
95 }
96 
97 int
98 SolverQueueItemInstall::cmp (SolverQueueItem_constPtr item) const
99 {
100  int cmp = this->compare (item);
101  if (cmp != 0)
102  return cmp;
103  SolverQueueItemInstall_constPtr ins = dynamic_pointer_cast<const SolverQueueItemInstall>(item);
104  if (_name != ins->_name) {
105  return _name.compare(ins->_name);
106  }
107  return 0;
108 }
109 
110 
111 //---------------------------------------------------------------------------
112 
113 
115  };// namespace detail
118  };// namespace solver
121 };// namespace zypp
#define MIL
Definition: Logger.h:47
IdType id() const
Expert backdoor.
Definition: IdString.h:103
Access to the sat-pools string space.
Definition: IdString.h:39
virtual SolverQueueItem_Ptr copy(void) const
SolverQueueItemInstall(const ResPool &pool, std::string name, bool soft=false)
virtual std::ostream & dumpOn(std::ostream &str) const
Overload to realize std::ostream &amp; operator&lt;&lt;.
Global ResObject pool.
Definition: ResPool.h:48
IMPL_PTR_TYPE(ProblemSolutionCombi)
virtual int cmp(SolverQueueItem_constPtr item) const
int compare(SolverQueueItem_constPtr item) const