libzypp
10.5.0
|
00001 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */ 00002 /* SolverQueueItem.cc 00003 * 00004 * Copyright (C) 2008 SUSE Linux Products GmbH 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License, 00008 * version 2, as published by the Free Software Foundation. 00009 * 00010 * This program is distributed in the hope that it will be useful, but 00011 * WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 * General Public License for more details. 00014 * 00015 * You should have received a copy of the GNU General Public License 00016 * along with this program; if not, write to the Free Software 00017 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 00018 * 02111-1307, USA. 00019 */ 00020 extern "C" 00021 { 00022 #include <solv/solver.h> 00023 } 00024 00025 #include "zypp/base/Logger.h" 00026 #include "zypp/IdString.h" 00027 #include "zypp/Resolver.h" 00028 #include "zypp/solver/detail/SolverQueueItemDelete.h" 00029 00031 namespace zypp 00032 { 00033 00034 namespace solver 00035 { 00036 00037 namespace detail 00038 { 00039 00040 using namespace std; 00041 00042 IMPL_PTR_TYPE(SolverQueueItemDelete); 00043 00044 //--------------------------------------------------------------------------- 00045 00046 std::ostream & 00047 SolverQueueItemDelete::dumpOn( std::ostream & os ) const 00048 { 00049 os << "[" << (_soft?"Soft":"") << "Delete: " 00050 << _name << "]"; 00051 00052 return os; 00053 } 00054 00055 //--------------------------------------------------------------------------- 00056 00057 SolverQueueItemDelete::SolverQueueItemDelete (const ResPool & pool, std::string name, bool soft) 00058 : SolverQueueItem (QUEUE_ITEM_TYPE_DELETE, pool) 00059 , _name (name) 00060 , _soft (soft) 00061 { 00062 } 00063 00064 00065 SolverQueueItemDelete::~SolverQueueItemDelete() 00066 { 00067 } 00068 00069 //--------------------------------------------------------------------------- 00070 00071 bool SolverQueueItemDelete::addRule (_Queue & q) 00072 { 00073 #define MAYBE_CLEANDEPS (pool().resolver().cleandepsOnRemove()?SOLVER_CLEANDEPS:0) 00074 00075 ::Id id = IdString(_name).id(); 00076 if (_soft) { 00077 queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | SOLVER_WEAK | MAYBE_CLEANDEPS ); 00078 } else { 00079 queue_push( &(q), SOLVER_ERASE | SOLVER_SOLVABLE_NAME | MAYBE_CLEANDEPS ); 00080 } 00081 queue_push( &(q), id); 00082 00083 MIL << "Delete " << _name << (_soft ? "(soft)" : "") 00084 << " with SAT-Pool: " << id << endl; 00085 return true; 00086 } 00087 00088 SolverQueueItem_Ptr 00089 SolverQueueItemDelete::copy (void) const 00090 { 00091 SolverQueueItemDelete_Ptr new_delete = new SolverQueueItemDelete (pool(), _name); 00092 new_delete->SolverQueueItem::copy(this); 00093 00094 new_delete->_soft = _soft; 00095 return new_delete; 00096 } 00097 00098 int 00099 SolverQueueItemDelete::cmp (SolverQueueItem_constPtr item) const 00100 { 00101 int cmp = this->compare (item); 00102 if (cmp != 0) 00103 return cmp; 00104 SolverQueueItemDelete_constPtr del = dynamic_pointer_cast<const SolverQueueItemDelete>(item); 00105 if (_name != del->_name) { 00106 return _name.compare(del->_name); 00107 } 00108 return 0; 00109 } 00110 00111 //--------------------------------------------------------------------------- 00112 00113 00115 };// namespace detail 00118 };// namespace solver 00121 };// namespace zypp