SolverQueueItemLock.cc
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 extern "C"
00021 {
00022 #include <satsolver/solver.h>
00023 }
00024
00025 #include "zypp/base/Logger.h"
00026 #include "zypp/solver/detail/SolverQueueItemLock.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(SolverQueueItemLock);
00041
00042
00043
00044 std::ostream &
00045 SolverQueueItemLock::dumpOn( std::ostream & os ) const
00046 {
00047 os << "[" << (_soft?"Soft":"") << "Lock: " <<
00048 _item << "]";
00049
00050 return os;
00051 }
00052
00053
00054
00055 SolverQueueItemLock::SolverQueueItemLock (const ResPool & pool,
00056 const PoolItem & item, bool soft)
00057 : SolverQueueItem (QUEUE_ITEM_TYPE_LOCK, pool)
00058 , _item (item)
00059 , _soft (soft)
00060 {
00061 }
00062
00063
00064 SolverQueueItemLock::~SolverQueueItemLock()
00065 {
00066 }
00067
00068
00069
00070 bool SolverQueueItemLock::addRule (_Queue & q)
00071 {
00072 ::Id id = _item.satSolvable().id();
00073 if (id == ID_NULL) {
00074 ERR << "Lock : " << _item << " not found" << endl;
00075 return false;
00076 }
00077 MIL << "Lock " << _item << " with the SAT-Pool ID: " << id << endl;
00078 if (_item.status().isInstalled()) {
00079 if (_soft) {
00080 queue_push( &(q), SOLVER_INSTALL_SOLVABLE | SOLVER_WEAK );
00081 } else {
00082 queue_push( &(q), SOLVER_INSTALL_SOLVABLE );
00083 }
00084 } else {
00085 if (_soft) {
00086 queue_push( &(q), SOLVER_ERASE_SOLVABLE | SOLVER_WEAK );
00087 } else {
00088 queue_push( &(q), SOLVER_ERASE_SOLVABLE );
00089 }
00090 }
00091 queue_push( &(q), id );
00092 return true;
00093 }
00094
00095 SolverQueueItem_Ptr
00096 SolverQueueItemLock::copy (void) const
00097 {
00098 SolverQueueItemLock_Ptr new_lock = new SolverQueueItemLock (pool(), _item);
00099 new_lock->SolverQueueItem::copy(this);
00100
00101 new_lock->_soft = _soft;
00102 return new_lock;
00103 }
00104
00105 int
00106 SolverQueueItemLock::cmp (SolverQueueItem_constPtr item) const
00107 {
00108 int cmp = this->compare (item);
00109 if (cmp != 0)
00110 return cmp;
00111 SolverQueueItemLock_constPtr lock = dynamic_pointer_cast<const SolverQueueItemLock>(item);
00112 return compareByNVRA (_item.resolvable(), lock->_item.resolvable());
00113 }
00114
00115
00116
00117
00118
00120 };
00123 };
00126 };