From: Stefan Schubert Date: Tue, 15 Apr 2008 15:35:22 +0000 (+0000) Subject: added solver calls X-Git-Tag: 6.6.0~1047 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=566325a25c6621224b846ad2379adc62ba4a7e80;p=platform%2Fupstream%2Flibzypp.git added solver calls --- diff --git a/zypp/solver/detail/SolverQueueItem.h b/zypp/solver/detail/SolverQueueItem.h index 49e87ba66..dcebddb8b 100644 --- a/zypp/solver/detail/SolverQueueItem.h +++ b/zypp/solver/detail/SolverQueueItem.h @@ -31,6 +31,12 @@ #include "zypp/base/PtrTypes.h" #include "zypp/ResPool.h" +extern "C" { +#include "satsolver/solver.h" +#include "satsolver/pool.h" +} + + ///////////////////////////////////////////////////////////////////////// namespace zypp { /////////////////////////////////////////////////////////////////////// @@ -96,6 +102,7 @@ class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable 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); } diff --git a/zypp/solver/detail/SolverQueueItemDelete.cc b/zypp/solver/detail/SolverQueueItemDelete.cc index dbc729718..6defd1b66 100644 --- a/zypp/solver/detail/SolverQueueItemDelete.cc +++ b/zypp/solver/detail/SolverQueueItemDelete.cc @@ -40,8 +40,8 @@ IMPL_PTR_TYPE(SolverQueueItemDelete); std::ostream & SolverQueueItemDelete::dumpOn( std::ostream & os ) const { - os << "[" << (_soft?"Soft":"") << "Delete: "; - os << _name; + os << "[" << (_soft?"Soft":"") << "Delete: " + << _name << "]"; return os; } @@ -62,6 +62,20 @@ SolverQueueItemDelete::~SolverQueueItemDelete() //--------------------------------------------------------------------------- +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 { diff --git a/zypp/solver/detail/SolverQueueItemDelete.h b/zypp/solver/detail/SolverQueueItemDelete.h index a0c503156..dd26eead2 100644 --- a/zypp/solver/detail/SolverQueueItemDelete.h +++ b/zypp/solver/detail/SolverQueueItemDelete.h @@ -66,7 +66,8 @@ class SolverQueueItemDelete : public SolverQueueItem { 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; }; diff --git a/zypp/solver/detail/SolverQueueItemInstall.cc b/zypp/solver/detail/SolverQueueItemInstall.cc index 808b1ed69..79dc98911 100644 --- a/zypp/solver/detail/SolverQueueItemInstall.cc +++ b/zypp/solver/detail/SolverQueueItemInstall.cc @@ -40,9 +40,10 @@ IMPL_PTR_TYPE(SolverQueueItemInstall); std::ostream & SolverQueueItemInstall::dumpOn( std::ostream & os ) const { - os << "[" << (_soft?"Soft":"") << "Install: "; - os << _name; - + os << "[" << (_soft?"Soft":"") << "Install: " + << _name + << "]"; + return os; } @@ -62,6 +63,20 @@ SolverQueueItemInstall::~SolverQueueItemInstall() //--------------------------------------------------------------------------- +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 { @@ -72,7 +87,6 @@ SolverQueueItemInstall::copy (void) const return new_install; } - int SolverQueueItemInstall::cmp (SolverQueueItem_constPtr item) const { diff --git a/zypp/solver/detail/SolverQueueItemInstall.h b/zypp/solver/detail/SolverQueueItemInstall.h index b1047dfd7..d9994b1d6 100644 --- a/zypp/solver/detail/SolverQueueItemInstall.h +++ b/zypp/solver/detail/SolverQueueItemInstall.h @@ -66,6 +66,7 @@ class SolverQueueItemInstall : public SolverQueueItem { // ---------------------------------- methods + virtual bool addRule (Queue & q, Pool *SATPool); virtual SolverQueueItem_Ptr copy (void) const; virtual int cmp (SolverQueueItem_constPtr item) const; }; diff --git a/zypp/solver/detail/SolverQueueItemInstallOneOf.cc b/zypp/solver/detail/SolverQueueItemInstallOneOf.cc index 7a0cca19f..855983e01 100644 --- a/zypp/solver/detail/SolverQueueItemInstallOneOf.cc +++ b/zypp/solver/detail/SolverQueueItemInstallOneOf.cc @@ -40,21 +40,21 @@ IMPL_PTR_TYPE(SolverQueueItemInstallOneOf); 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) { } @@ -65,13 +65,32 @@ SolverQueueItemInstallOneOf::~SolverQueueItemInstallOneOf() //--------------------------------------------------------------------------- +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; } diff --git a/zypp/solver/detail/SolverQueueItemInstallOneOf.h b/zypp/solver/detail/SolverQueueItemInstallOneOf.h index a0846f1b1..3bdf09495 100644 --- a/zypp/solver/detail/SolverQueueItemInstallOneOf.h +++ b/zypp/solver/detail/SolverQueueItemInstallOneOf.h @@ -48,11 +48,10 @@ class SolverQueueItemInstallOneOf : public SolverQueueItem { 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 @@ -62,12 +61,9 @@ class SolverQueueItemInstallOneOf : public SolverQueueItem { 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; }; diff --git a/zypp/solver/detail/SolverQueueItemUpdate.cc b/zypp/solver/detail/SolverQueueItemUpdate.cc index 8a58c5b8b..e82357b9d 100644 --- a/zypp/solver/detail/SolverQueueItemUpdate.cc +++ b/zypp/solver/detail/SolverQueueItemUpdate.cc @@ -40,8 +40,8 @@ IMPL_PTR_TYPE(SolverQueueItemUpdate); std::ostream & SolverQueueItemUpdate::dumpOn( std::ostream & os ) const { - os << "[" << (_soft?"Soft":"") << "Update: "; - os << _item; + os << "[" << (_soft?"Soft":"") << "Update: " << + _item << "]"; return os; } @@ -63,6 +63,19 @@ SolverQueueItemUpdate::~SolverQueueItemUpdate() //--------------------------------------------------------------------------- +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 { diff --git a/zypp/solver/detail/SolverQueueItemUpdate.h b/zypp/solver/detail/SolverQueueItemUpdate.h index 4839f96b8..8bc524e8a 100644 --- a/zypp/solver/detail/SolverQueueItemUpdate.h +++ b/zypp/solver/detail/SolverQueueItemUpdate.h @@ -65,7 +65,8 @@ class SolverQueueItemUpdate : public SolverQueueItem { 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; };