From: Stefan Schubert Date: Tue, 15 Apr 2008 12:38:13 +0000 (+0000) Subject: enabled cmp functions in solver queue X-Git-Tag: 6.6.0~1048 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5e440db95a0e7cbc1a41c19faa1f780c3f1926b1;p=platform%2Fupstream%2Flibzypp.git enabled cmp functions in solver queue --- diff --git a/zypp/solver/detail/SolverQueueItem.h b/zypp/solver/detail/SolverQueueItem.h index 30b463fe4..49e87ba66 100644 --- a/zypp/solver/detail/SolverQueueItem.h +++ b/zypp/solver/detail/SolverQueueItem.h @@ -96,7 +96,7 @@ class SolverQueueItem : public base::ReferenceCounted, private base::NonCopyable virtual SolverQueueItem_Ptr copy (void) const = 0; - //virtual int cmp (SolverQueueItem_constPtr item) const = 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 1f5c5eb97..dbc729718 100644 --- a/zypp/solver/detail/SolverQueueItemDelete.cc +++ b/zypp/solver/detail/SolverQueueItemDelete.cc @@ -72,6 +72,26 @@ SolverQueueItemDelete::copy (void) const return new_delete; } +int +SolverQueueItemDelete::cmp (SolverQueueItem_constPtr item) const +{ + int cmp = this->compare (item); + if (cmp != 0) + return cmp; + SolverQueueItemDelete_constPtr del = dynamic_pointer_cast(item); + if (_name != del->_name) { + return _name.compare(del->_name); + } else { + if (_soft == del->_soft) { + return 0; + } else { + if (_soft) + return 1; + else + return -1; + } + } +} //--------------------------------------------------------------------------- diff --git a/zypp/solver/detail/SolverQueueItemDelete.h b/zypp/solver/detail/SolverQueueItemDelete.h index 29adeb8e4..a0c503156 100644 --- a/zypp/solver/detail/SolverQueueItemDelete.h +++ b/zypp/solver/detail/SolverQueueItemDelete.h @@ -68,7 +68,7 @@ class SolverQueueItemDelete : public SolverQueueItem { // ---------------------------------- methods virtual SolverQueueItem_Ptr copy (void) const; - //virtual int cmp (SolverQueueItem_constPtr item) const; + virtual int cmp (SolverQueueItem_constPtr item) const; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/solver/detail/SolverQueueItemInstall.cc b/zypp/solver/detail/SolverQueueItemInstall.cc index a129defa6..808b1ed69 100644 --- a/zypp/solver/detail/SolverQueueItemInstall.cc +++ b/zypp/solver/detail/SolverQueueItemInstall.cc @@ -73,6 +73,28 @@ SolverQueueItemInstall::copy (void) const } +int +SolverQueueItemInstall::cmp (SolverQueueItem_constPtr item) const +{ + int cmp = this->compare (item); + if (cmp != 0) + return cmp; + SolverQueueItemInstall_constPtr ins = dynamic_pointer_cast(item); + if (_name != ins->_name) { + return _name.compare(ins->_name); + } else { + if (_soft == ins->_soft) { + return 0; + } else { + if (_soft) + return 1; + else + return -1; + } + } +} + + //--------------------------------------------------------------------------- diff --git a/zypp/solver/detail/SolverQueueItemInstall.h b/zypp/solver/detail/SolverQueueItemInstall.h index 06220ba61..b1047dfd7 100644 --- a/zypp/solver/detail/SolverQueueItemInstall.h +++ b/zypp/solver/detail/SolverQueueItemInstall.h @@ -67,7 +67,7 @@ class SolverQueueItemInstall : public SolverQueueItem { // ---------------------------------- methods virtual SolverQueueItem_Ptr copy (void) const; - //virtual int cmp (SolverQueueItem_constPtr item) const; + virtual int cmp (SolverQueueItem_constPtr item) const; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/solver/detail/SolverQueueItemInstallOneOf.cc b/zypp/solver/detail/SolverQueueItemInstallOneOf.cc index df29fb10c..7a0cca19f 100644 --- a/zypp/solver/detail/SolverQueueItemInstallOneOf.cc +++ b/zypp/solver/detail/SolverQueueItemInstallOneOf.cc @@ -75,6 +75,17 @@ SolverQueueItemInstallOneOf::copy (void) const return new_installOneOf; } +int +SolverQueueItemInstallOneOf::cmp (SolverQueueItem_constPtr item) const +{ + int cmp = this->compare (item); + if (cmp != 0) + return cmp; + SolverQueueItemInstallOneOf_constPtr install = dynamic_pointer_cast(item); + + return (_oneOfList == install->_oneOfList) ? 0 : -1; // more evaluation would be not useful +} + //--------------------------------------------------------------------------- diff --git a/zypp/solver/detail/SolverQueueItemInstallOneOf.h b/zypp/solver/detail/SolverQueueItemInstallOneOf.h index 5a8f27498..a0846f1b1 100644 --- a/zypp/solver/detail/SolverQueueItemInstallOneOf.h +++ b/zypp/solver/detail/SolverQueueItemInstallOneOf.h @@ -69,7 +69,7 @@ class SolverQueueItemInstallOneOf : public SolverQueueItem { // ---------------------------------- methods virtual SolverQueueItem_Ptr copy (void) const; - //virtual int cmp (SolverQueueItem_constPtr item) const; + virtual int cmp (SolverQueueItem_constPtr item) const; }; /////////////////////////////////////////////////////////////////// diff --git a/zypp/solver/detail/SolverQueueItemUpdate.cc b/zypp/solver/detail/SolverQueueItemUpdate.cc index 5656e7473..8a58c5b8b 100644 --- a/zypp/solver/detail/SolverQueueItemUpdate.cc +++ b/zypp/solver/detail/SolverQueueItemUpdate.cc @@ -73,6 +73,16 @@ SolverQueueItemUpdate::copy (void) const return new_update; } +int +SolverQueueItemUpdate::cmp (SolverQueueItem_constPtr item) const +{ + int cmp = this->compare (item); + if (cmp != 0) + return cmp; + SolverQueueItemUpdate_constPtr update = dynamic_pointer_cast(item); + return compareByNVRA (_item.resolvable(), update->_item.resolvable()); +} + //--------------------------------------------------------------------------- diff --git a/zypp/solver/detail/SolverQueueItemUpdate.h b/zypp/solver/detail/SolverQueueItemUpdate.h index c307b7ed4..4839f96b8 100644 --- a/zypp/solver/detail/SolverQueueItemUpdate.h +++ b/zypp/solver/detail/SolverQueueItemUpdate.h @@ -67,7 +67,7 @@ class SolverQueueItemUpdate : public SolverQueueItem { // ---------------------------------- methods virtual SolverQueueItem_Ptr copy (void) const; - //virtual int cmp (SolverQueueItem_constPtr item) const; + virtual int cmp (SolverQueueItem_constPtr item) const; }; ///////////////////////////////////////////////////////////////////