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 <satsolver/solver.h> 00023 } 00024 00025 #include "zypp/base/Logger.h" 00026 #include "zypp/IdString.h" 00027 #include "zypp/solver/detail/SolverQueueItemDelete.h" 00028 00030 namespace zypp 00031 { 00032 00033 namespace solver 00034 { 00035 00036 namespace detail 00037 { 00038 00039 using namespace std; 00040 00041 IMPL_PTR_TYPE(SolverQueueItemDelete); 00042 00043 //--------------------------------------------------------------------------- 00044 00045 std::ostream & 00046 SolverQueueItemDelete::dumpOn( std::ostream & os ) const 00047 { 00048 os << "[" << (_soft?"Soft":"") << "Delete: " 00049 << _name << "]"; 00050 00051 return os; 00052 } 00053 00054 //--------------------------------------------------------------------------- 00055 00056 SolverQueueItemDelete::SolverQueueItemDelete (const ResPool & pool, std::string name, bool soft) 00057 : SolverQueueItem (QUEUE_ITEM_TYPE_DELETE, pool) 00058 , _name (name) 00059 , _soft (soft) 00060 { 00061 } 00062 00063 00064 SolverQueueItemDelete::~SolverQueueItemDelete() 00065 { 00066 } 00067 00068 //--------------------------------------------------------------------------- 00069 00070 bool SolverQueueItemDelete::addRule (_Queue & q) 00071 { 00072 ::Id id = IdString(_name).id(); 00073 if (_soft) { 00074 queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME | SOLVER_WEAK); 00075 } else { 00076 queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME ); 00077 } 00078 queue_push( &(q), id); 00079 00080 MIL << "Delete " << _name << (_soft ? "(soft)" : "") 00081 << " with SAT-Pool: " << id << endl; 00082 return true; 00083 } 00084 00085 SolverQueueItem_Ptr 00086 SolverQueueItemDelete::copy (void) const 00087 { 00088 SolverQueueItemDelete_Ptr new_delete = new SolverQueueItemDelete (pool(), _name); 00089 new_delete->SolverQueueItem::copy(this); 00090 00091 new_delete->_soft = _soft; 00092 return new_delete; 00093 } 00094 00095 int 00096 SolverQueueItemDelete::cmp (SolverQueueItem_constPtr item) const 00097 { 00098 int cmp = this->compare (item); 00099 if (cmp != 0) 00100 return cmp; 00101 SolverQueueItemDelete_constPtr del = dynamic_pointer_cast<const SolverQueueItemDelete>(item); 00102 if (_name != del->_name) { 00103 return _name.compare(del->_name); 00104 } 00105 return 0; 00106 } 00107 00108 //--------------------------------------------------------------------------- 00109 00110 00112 };// namespace detail 00115 };// namespace solver 00118 };// namespace zypp