Satsolver includes are system includes.
[platform/upstream/libzypp.git] / zypp / solver / detail / SolverQueueItemDelete.cc
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 <satsolver/solver.h>
23 }
24
25 #include "zypp/base/Logger.h"
26 #include "zypp/IdString.h"
27 #include "zypp/solver/detail/SolverQueueItemDelete.h"
28
29 /////////////////////////////////////////////////////////////////////////
30 namespace zypp
31 { ///////////////////////////////////////////////////////////////////////
32   ///////////////////////////////////////////////////////////////////////
33   namespace solver
34   { /////////////////////////////////////////////////////////////////////
35     /////////////////////////////////////////////////////////////////////
36     namespace detail
37     { ///////////////////////////////////////////////////////////////////
38
39 using namespace std;
40
41 IMPL_PTR_TYPE(SolverQueueItemDelete);
42
43 //---------------------------------------------------------------------------
44
45 std::ostream &
46 SolverQueueItemDelete::dumpOn( std::ostream & os ) const
47 {
48     os << "[" << (_soft?"Soft":"") << "Delete: "
49        << _name << "]";
50
51     return os;
52 }
53
54 //---------------------------------------------------------------------------
55
56 SolverQueueItemDelete::SolverQueueItemDelete (const ResPool & pool, std::string name, bool soft)
57     : SolverQueueItem (QUEUE_ITEM_TYPE_DELETE, pool)
58     , _name (name)
59     , _soft (soft)
60 {
61 }
62
63
64 SolverQueueItemDelete::~SolverQueueItemDelete()
65 {
66 }
67
68 //---------------------------------------------------------------------------
69
70 bool SolverQueueItemDelete::addRule (_Queue & q)
71 {
72     ::Id id = IdString(_name).id();
73     if (_soft) {
74         queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME | SOLVER_WEAK);
75     } else {
76         queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME );
77     }
78     queue_push( &(q), id);
79
80     MIL << "Delete " << _name << (_soft ? "(soft)" : "")
81         << " with SAT-Pool: " << id << endl;
82     return true;
83 }
84
85 SolverQueueItem_Ptr
86 SolverQueueItemDelete::copy (void) const
87 {
88     SolverQueueItemDelete_Ptr new_delete = new SolverQueueItemDelete (pool(), _name);
89     new_delete->SolverQueueItem::copy(this);
90
91     new_delete->_soft = _soft;
92     return new_delete;
93 }
94
95 int
96 SolverQueueItemDelete::cmp (SolverQueueItem_constPtr item) const
97 {
98     int cmp = this->compare (item);
99     if (cmp != 0)
100         return cmp;
101     SolverQueueItemDelete_constPtr del = dynamic_pointer_cast<const SolverQueueItemDelete>(item);
102     if (_name != del->_name) {
103         return _name.compare(del->_name);
104     }
105     return 0;
106 }
107
108 //---------------------------------------------------------------------------
109
110
111 ///////////////////////////////////////////////////////////////////
112     };// namespace detail
113     /////////////////////////////////////////////////////////////////////
114     /////////////////////////////////////////////////////////////////////
115   };// namespace solver
116   ///////////////////////////////////////////////////////////////////////
117   ///////////////////////////////////////////////////////////////////////
118 };// namespace zypp
119 /////////////////////////////////////////////////////////////////////////