From 5e440db95a0e7cbc1a41c19faa1f780c3f1926b1 Mon Sep 17 00:00:00 2001 From: Stefan Schubert Date: Tue, 15 Apr 2008 12:38:13 +0000 Subject: [PATCH] enabled cmp functions in solver queue --- zypp/solver/detail/SolverQueueItem.h | 2 +- zypp/solver/detail/SolverQueueItemDelete.cc | 20 +++++++++++++++++ zypp/solver/detail/SolverQueueItemDelete.h | 2 +- zypp/solver/detail/SolverQueueItemInstall.cc | 22 +++++++++++++++++++ zypp/solver/detail/SolverQueueItemInstall.h | 2 +- .../detail/SolverQueueItemInstallOneOf.cc | 11 ++++++++++ .../detail/SolverQueueItemInstallOneOf.h | 2 +- zypp/solver/detail/SolverQueueItemUpdate.cc | 10 +++++++++ zypp/solver/detail/SolverQueueItemUpdate.h | 2 +- 9 files changed, 68 insertions(+), 5 deletions(-) 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; }; /////////////////////////////////////////////////////////////////// -- 2.34.1