#include "zypp/base/PtrTypes.h"
#include "zypp/ResPool.h"
+extern "C" {
+#include "satsolver/solver.h"
+#include "satsolver/pool.h"
+}
+
+
/////////////////////////////////////////////////////////////////////////
namespace zypp
{ ///////////////////////////////////////////////////////////////////////
virtual SolverQueueItem_Ptr copy (void) const = 0;
+ virtual bool addRule (Queue & q, Pool *SATPool) =0 ;
virtual int cmp (SolverQueueItem_constPtr item) const = 0;
int compare (SolverQueueItem_constPtr item) const { return CMP(_type, item->_type); }
std::ostream &
SolverQueueItemDelete::dumpOn( std::ostream & os ) const
{
- os << "[" << (_soft?"Soft":"") << "Delete: ";
- os << _name;
+ os << "[" << (_soft?"Soft":"") << "Delete: "
+ << _name << "]";
return os;
}
//---------------------------------------------------------------------------
+bool SolverQueueItemDelete::addRule (Queue & q, Pool *SATPool)
+{
+ Id id = str2id( SATPool, _name.c_str(), 0 );
+ 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;
+}
+
SolverQueueItem_Ptr
SolverQueueItemDelete::copy (void) const
{
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;
};
std::ostream &
SolverQueueItemInstall::dumpOn( std::ostream & os ) const
{
- os << "[" << (_soft?"Soft":"") << "Install: ";
- os << _name;
-
+ os << "[" << (_soft?"Soft":"") << "Install: "
+ << _name
+ << "]";
+
return os;
}
//---------------------------------------------------------------------------
+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);
+ }
+ MIL << "Install " << _name << (_soft ? "(soft)" : "")
+ << " with SAT-Pooly: " << id << endl;
+ return true;
+}
+
SolverQueueItem_Ptr
SolverQueueItemInstall::copy (void) const
{
return new_install;
}
-
int
SolverQueueItemInstall::cmp (SolverQueueItem_constPtr item) const
{
// ---------------------------------- methods
+ virtual bool addRule (Queue & q, Pool *SATPool);
virtual SolverQueueItem_Ptr copy (void) const;
virtual int cmp (SolverQueueItem_constPtr item) const;
};
std::ostream &
SolverQueueItemInstallOneOf::dumpOn( std::ostream & os ) const
{
- os << "[" << (_soft?"Soft":"") << "InstallOneOf: ";
+ os << "[" << "InstallOneOf: ";
for (PoolItemList::const_iterator iter = _oneOfList.begin();
iter != _oneOfList.end();
iter++)
os << *iter;
-
+ os << "]";
+
return os;
}
//---------------------------------------------------------------------------
-SolverQueueItemInstallOneOf::SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList, bool soft)
+SolverQueueItemInstallOneOf::SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList)
: SolverQueueItem (QUEUE_ITEM_TYPE_INSTALL_ONE_OF, pool)
, _oneOfList (itemList)
- , _soft (soft)
{
}
//---------------------------------------------------------------------------
+bool SolverQueueItemInstallOneOf::addRule (Queue & q, Pool *SATPool)
+{
+ bool ret = true;
+ MIL << "Install one of: " << endl;
+ queue_push( &(q), SOLVER_INSTALL_SOLVABLE_ONE_OF );
+ for (PoolItemList::const_iterator iter = _oneOfList.begin(); iter != _oneOfList.end(); iter++) {
+ Id id = (*iter)->satSolvable().id();
+ if (id == ID_NULL) {
+ ERR << *iter << " not found" << endl;
+ ret = false;
+ } else {
+ MIL << " candidate:" << *iter << " with the SAT-Pool ID: " << id << endl;
+ queue_push( &(q), id );
+ }
+ }
+ queue_push( &(q), 0 ); // finish candidate
+
+ return ret;
+}
+
SolverQueueItem_Ptr
SolverQueueItemInstallOneOf::copy (void) const
{
- SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList, _soft);
+ SolverQueueItemInstallOneOf_Ptr new_installOneOf = new SolverQueueItemInstallOneOf (pool(), _oneOfList);
new_installOneOf->SolverQueueItem::copy(this);
-
- new_installOneOf->_soft = _soft;
+
return new_installOneOf;
}
private:
PoolItemList _oneOfList; // List of candidates
- bool _soft; // if triggered by a soft requirement (a recommends)
public:
- SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList, bool soft = false);
+ SolverQueueItemInstallOneOf (const ResPool & pool, const PoolItemList & itemList);
virtual ~SolverQueueItemInstallOneOf();
// ---------------------------------- I/O
friend std::ostream& operator<<(std::ostream & str, const SolverQueueItemInstallOneOf & 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;
};
std::ostream &
SolverQueueItemUpdate::dumpOn( std::ostream & os ) const
{
- os << "[" << (_soft?"Soft":"") << "Update: ";
- os << _item;
+ os << "[" << (_soft?"Soft":"") << "Update: " <<
+ _item << "]";
return os;
}
//---------------------------------------------------------------------------
+bool SolverQueueItemUpdate::addRule (Queue & q, Pool *SATPool)
+{
+ Id id = _item.satSolvable().id();
+ if (id == ID_NULL) {
+ ERR << "Update explicit: " << _item << " not found" << endl;
+ return false;
+ }
+ MIL << "Update explicit " << _item << " with the SAT-Pool ID: " << id << endl;
+ queue_push( &(q), SOLVER_INSTALL_SOLVABLE_UPDATE );
+ queue_push( &(q), id );
+ return true;
+}
+
SolverQueueItem_Ptr
SolverQueueItemUpdate::copy (void) const
{
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;
};