solver/detail/SolverQueueItemDelete.cc
solver/detail/SolverQueueItemUpdate.cc
solver/detail/SolverQueueItemInstallOneOf.cc
+ solver/detail/SolverQueueItemLock.cc
solver/detail/SATResolver.cc
)
solver/detail/SolverQueueItemDelete.h
solver/detail/SolverQueueItemUpdate.h
solver/detail/SolverQueueItemInstallOneOf.h
+ solver/detail/SolverQueueItemLock.h
solver/detail/SATResolver.h
)
{
switch (_type) {
case QUEUE_ITEM_TYPE_UNKNOWN : os << "unknown"; break;
- case QUEUE_ITEM_TYPE_UPDATE : os << "update"; break;
+ case QUEUE_ITEM_TYPE_UPDATE : os << "update"; break;
+ case QUEUE_ITEM_TYPE_LOCK : os << "lock"; break;
case QUEUE_ITEM_TYPE_INSTALL : os << "install"; break;
- case QUEUE_ITEM_TYPE_DELETE : os << "delete"; break;
+ case QUEUE_ITEM_TYPE_DELETE : os << "delete"; break;
case QUEUE_ITEM_TYPE_INSTALL_ONE_OF: os << "install one of"; break;
default: os << "?solverqueueitem?"; break;
}
QUEUE_ITEM_TYPE_UPDATE,
QUEUE_ITEM_TYPE_INSTALL,
QUEUE_ITEM_TYPE_DELETE,
- QUEUE_ITEM_TYPE_INSTALL_ONE_OF,
+ QUEUE_ITEM_TYPE_INSTALL_ONE_OF,
+ QUEUE_ITEM_TYPE_LOCK
} SolverQueueItemType;
bool isDelete (void) const { return _type == QUEUE_ITEM_TYPE_DELETE; }
bool isInstall (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL; }
bool isUpdate (void) const { return _type == QUEUE_ITEM_TYPE_UPDATE; }
+ bool isLock (void) const { return _type == QUEUE_ITEM_TYPE_LOCK; }
bool isInstallOneOf (void) const { return _type == QUEUE_ITEM_TYPE_INSTALL_ONE_OF; }
bool SolverQueueItemDelete::addRule (Queue & q, Pool *SATPool)
{
Id id = str2id( SATPool, _name.c_str(), 0 );
- queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME );
+ if (_soft) {
+ queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME | SOLVER_WEAK);
+ } else {
+ queue_push( &(q), SOLVER_ERASE_SOLVABLE_NAME );
+ }
queue_push( &(q), id);
- if (_soft) {
- queue_push( &(q), SOLVER_WEAK );
- queue_push( &(q), id);
- }
+
MIL << "Delete " << _name << (_soft ? "(soft)" : "")
<< " with SAT-Pool: " << id << endl;
return true;
bool SolverQueueItemInstall::addRule (Queue & q, Pool *SATPool)
{
Id id = str2id( SATPool, _name.c_str(), 0 );
- queue_push( &(q), SOLVER_INSTALL_SOLVABLE_NAME );
- queue_push( &(q), id);
- if (_soft) {
- queue_push( &(q), SOLVER_WEAK );
- queue_push( &(q), id);
+ if (_soft) {
+ queue_push( &(q), SOLVER_INSTALL_SOLVABLE_NAME | SOLVER_WEAK );
+ } else {
+ queue_push( &(q), SOLVER_INSTALL_SOLVABLE_NAME );
}
+ queue_push( &(q), id);
+
MIL << "Install " << _name << (_soft ? "(soft)" : "")
<< " with SAT-Pooly: " << id << endl;
return true;
--- /dev/null
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* SolverQueueItem.cc
+ *
+ * Copyright (C) 2008 SUSE Linux Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "zypp/base/Logger.h"
+#include "zypp/solver/detail/SolverQueueItemLock.h"
+
+/////////////////////////////////////////////////////////////////////////
+namespace zypp
+{ ///////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
+ namespace solver
+ { /////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ namespace detail
+ { ///////////////////////////////////////////////////////////////////
+
+using namespace std;
+
+IMPL_PTR_TYPE(SolverQueueItemLock);
+
+//---------------------------------------------------------------------------
+
+std::ostream &
+SolverQueueItemLock::dumpOn( std::ostream & os ) const
+{
+ os << "[" << (_soft?"Soft":"") << "Lock: " <<
+ _item << "]";
+
+ return os;
+}
+
+//---------------------------------------------------------------------------
+
+SolverQueueItemLock::SolverQueueItemLock (const ResPool & pool,
+ const PoolItem & item, bool soft)
+ : SolverQueueItem (QUEUE_ITEM_TYPE_LOCK, pool)
+ , _item (item)
+ , _soft (soft)
+{
+}
+
+
+SolverQueueItemLock::~SolverQueueItemLock()
+{
+}
+
+//---------------------------------------------------------------------------
+
+bool SolverQueueItemLock::addRule (Queue & q, Pool *SATPool)
+{
+ Id id = _item.satSolvable().id();
+ if (id == ID_NULL) {
+ ERR << "Lock : " << _item << " not found" << endl;
+ return false;
+ }
+ MIL << "Lock " << _item << " with the SAT-Pool ID: " << id << endl;
+ if (_item.status().isInstalled()) {
+ if (_soft) {
+ queue_push( &(q), SOLVER_INSTALL_SOLVABLE | SOLVER_WEAK );
+ } else {
+ queue_push( &(q), SOLVER_INSTALL_SOLVABLE );
+ }
+ } else {
+ if (_soft) {
+ queue_push( &(q), SOLVER_ERASE_SOLVABLE | SOLVER_WEAK );
+ } else {
+ queue_push( &(q), SOLVER_ERASE_SOLVABLE );
+ }
+ }
+ queue_push( &(q), id );
+ return true;
+}
+
+SolverQueueItem_Ptr
+SolverQueueItemLock::copy (void) const
+{
+ SolverQueueItemLock_Ptr new_lock = new SolverQueueItemLock (pool(), _item);
+ new_lock->SolverQueueItem::copy(this);
+
+ new_lock->_soft = _soft;
+ return new_lock;
+}
+
+int
+SolverQueueItemLock::cmp (SolverQueueItem_constPtr item) const
+{
+ int cmp = this->compare (item);
+ if (cmp != 0)
+ return cmp;
+ SolverQueueItemLock_constPtr lock = dynamic_pointer_cast<const SolverQueueItemLock>(item);
+ return compareByNVRA (_item.resolvable(), lock->_item.resolvable());
+}
+
+
+//---------------------------------------------------------------------------
+
+
+///////////////////////////////////////////////////////////////////
+ };// namespace detail
+ /////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ };// namespace solver
+ ///////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
+};// namespace zypp
+/////////////////////////////////////////////////////////////////////////
--- /dev/null
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 4 -*- */
+/* QueueItem.h
+ *
+ * Copyright (C) 2008 SUSE Linux Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef ZYPP_SOLVER_DETAIL_QUEUEITEMLOCK_H
+#define ZYPP_SOLVER_DETAIL_QUEUEITEMLOCK_H
+
+#include <iosfwd>
+#include <string>
+
+#include "zypp/solver/detail/SolverQueueItem.h"
+#include "zypp/PoolItem.h"
+
+/////////////////////////////////////////////////////////////////////////
+namespace zypp
+{ ///////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
+ namespace solver
+ { /////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ namespace detail
+ { ///////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+//
+// CLASS NAME : SolverQueueItemLock
+
+class SolverQueueItemLock : public SolverQueueItem {
+
+ private:
+
+ PoolItem _item; // the item to-be-locked
+ bool _soft; // if triggered by a soft requirement (a recommends)
+
+ public:
+
+ SolverQueueItemLock (const ResPool & pool, const PoolItem & item, bool soft = false);
+ virtual ~SolverQueueItemLock();
+
+ // ---------------------------------- I/O
+
+ virtual std::ostream & dumpOn( std::ostream & str ) const;
+
+ friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemLock & obj)
+ { return obj.dumpOn (str); }
+
+ // ---------------------------------- accessors
+
+ bool isSoft (void) const { return _soft; }
+
+ // ---------------------------------- methods
+
+ virtual bool addRule (Queue & q, Pool *SATPool);
+ virtual SolverQueueItem_Ptr copy (void) const;
+ virtual int cmp (SolverQueueItem_constPtr item) const;
+};
+
+///////////////////////////////////////////////////////////////////
+ };// namespace detail
+ /////////////////////////////////////////////////////////////////////
+ /////////////////////////////////////////////////////////////////////
+ };// namespace solver
+ ///////////////////////////////////////////////////////////////////////
+ ///////////////////////////////////////////////////////////////////////
+};// namespace zypp
+/////////////////////////////////////////////////////////////////////////
+
+#endif // ZYPP_SOLVER_DETAIL_QUEUEITEMLOCK_H
DEFINE_PTR_TYPE(SolverQueueItemUpdate);
DEFINE_PTR_TYPE(SolverQueueItemDelete);
DEFINE_PTR_TYPE(SolverQueueItemInstall);
-DEFINE_PTR_TYPE(SolverQueueItemInstallOneOf);
+DEFINE_PTR_TYPE(SolverQueueItemInstallOneOf);
+DEFINE_PTR_TYPE(SolverQueueItemLock);
///////////////////////////////////////////////////////////////////
};// namespace detail