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/solver/detail/SolverQueueItemUpdate.h" 00027 00029 namespace zypp 00030 { 00031 00032 namespace solver 00033 { 00034 00035 namespace detail 00036 { 00037 00038 using namespace std; 00039 00040 IMPL_PTR_TYPE(SolverQueueItemUpdate); 00041 00042 //--------------------------------------------------------------------------- 00043 00044 std::ostream & 00045 SolverQueueItemUpdate::dumpOn( std::ostream & os ) const 00046 { 00047 os << "[" << (_soft?"Soft":"") << "Update: " << 00048 _item << "]"; 00049 00050 return os; 00051 } 00052 00053 //--------------------------------------------------------------------------- 00054 00055 SolverQueueItemUpdate::SolverQueueItemUpdate (const ResPool & pool, 00056 const PoolItem & item, bool soft) 00057 : SolverQueueItem (QUEUE_ITEM_TYPE_UPDATE, pool) 00058 , _item (item) 00059 , _soft (soft) 00060 { 00061 } 00062 00063 00064 SolverQueueItemUpdate::~SolverQueueItemUpdate() 00065 { 00066 } 00067 00068 //--------------------------------------------------------------------------- 00069 00070 bool SolverQueueItemUpdate::addRule (_Queue & q) 00071 { 00072 ::Id id = _item.satSolvable().id(); 00073 if (id == ID_NULL) { 00074 ERR << "Update explicit: " << _item << " not found" << endl; 00075 return false; 00076 } 00077 MIL << "Update explicit " << _item << " with the SAT-Pool ID: " << id << endl; 00078 queue_push( &(q), SOLVER_UPDATE | SOLVER_SOLVABLE ); 00079 queue_push( &(q), id ); 00080 return true; 00081 } 00082 00083 SolverQueueItem_Ptr 00084 SolverQueueItemUpdate::copy (void) const 00085 { 00086 SolverQueueItemUpdate_Ptr new_update = new SolverQueueItemUpdate (pool(), _item); 00087 new_update->SolverQueueItem::copy(this); 00088 00089 new_update->_soft = _soft; 00090 return new_update; 00091 } 00092 00093 int 00094 SolverQueueItemUpdate::cmp (SolverQueueItem_constPtr item) const 00095 { 00096 int cmp = this->compare (item); 00097 if (cmp != 0) 00098 return cmp; 00099 SolverQueueItemUpdate_constPtr update = dynamic_pointer_cast<const SolverQueueItemUpdate>(item); 00100 return compareByNVRA (_item.resolvable(), update->_item.resolvable()); 00101 } 00102 00103 00104 //--------------------------------------------------------------------------- 00105 00106 00108 };// namespace detail 00111 };// namespace solver 00114 };// namespace zypp