libzypp 8.13.6
|
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/IdStringType.h" 00028 #include "zypp/solver/detail/SolverQueueItemInstall.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(SolverQueueItemInstall); 00043 00044 //--------------------------------------------------------------------------- 00045 00046 std::ostream & 00047 SolverQueueItemInstall::dumpOn( std::ostream & os ) const 00048 { 00049 os << "[" << (_soft?"Soft":"") << "Install: " 00050 << _name 00051 << "]"; 00052 00053 return os; 00054 } 00055 00056 //--------------------------------------------------------------------------- 00057 00058 SolverQueueItemInstall::SolverQueueItemInstall (const ResPool & pool, std::string name, bool soft) 00059 : SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL, pool) 00060 , _name (name) 00061 , _soft (soft) 00062 { 00063 } 00064 00065 00066 SolverQueueItemInstall::~SolverQueueItemInstall() 00067 { 00068 } 00069 00070 //--------------------------------------------------------------------------- 00071 00072 bool SolverQueueItemInstall::addRule (_Queue & q) 00073 { 00074 ::Id id = IdString(_name).id(); 00075 if (_soft) { 00076 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME | SOLVER_WEAK ); 00077 } else { 00078 queue_push( &(q), SOLVER_INSTALL | SOLVER_SOLVABLE_NAME ); 00079 } 00080 queue_push( &(q), id); 00081 00082 MIL << "Install " << _name << (_soft ? "(soft)" : "") 00083 << " with SAT-PoolID: " << id << endl; 00084 return true; 00085 } 00086 00087 SolverQueueItem_Ptr 00088 SolverQueueItemInstall::copy (void) const 00089 { 00090 SolverQueueItemInstall_Ptr new_install = new SolverQueueItemInstall (pool(), _name); 00091 new_install->SolverQueueItem::copy(this); 00092 00093 new_install->_soft = _soft; 00094 return new_install; 00095 } 00096 00097 int 00098 SolverQueueItemInstall::cmp (SolverQueueItem_constPtr item) const 00099 { 00100 int cmp = this->compare (item); 00101 if (cmp != 0) 00102 return cmp; 00103 SolverQueueItemInstall_constPtr ins = dynamic_pointer_cast<const SolverQueueItemInstall>(item); 00104 if (_name != ins->_name) { 00105 return _name.compare(ins->_name); 00106 } 00107 return 0; 00108 } 00109 00110 00111 //--------------------------------------------------------------------------- 00112 00113 00115 };// namespace detail 00118 };// namespace solver 00121 };// namespace zypp