From f9fc0b873a56bc1abd0ebe3fba6425f27570ad0e Mon Sep 17 00:00:00 2001 From: Michael Andres Date: Wed, 22 Feb 2006 23:27:39 +0000 Subject: [PATCH] - ui::Selectable: Order available resolvables according to arch, edition. --- zypp/ui/SelectableTraits.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/zypp/ui/SelectableTraits.h b/zypp/ui/SelectableTraits.h index 87837ce..413a7fb 100644 --- a/zypp/ui/SelectableTraits.h +++ b/zypp/ui/SelectableTraits.h @@ -32,7 +32,35 @@ namespace zypp /** */ struct SelectableTraits { - typedef std::set AvialableItemSet; + /** Oder on AvialableItemSet. + * \li best Arch + * \li best Edition + * \li ResObject::constPtr as fallback. + */ + struct AVOrder : public std::binary_function + { + // NOTE: operator() provides LESS semantics to order the set. + // So LESS means 'prior in set'. We want 'better' archs and + // 'better' editions at the beginning of the set. So we return + // TRUE if (lhs > rhs)! + // + bool operator()( const PoolItem & lhs, const PoolItem & rhs ) const + { + int res = lhs->arch().compare( rhs->arch() ); + if ( res ) + return res > 0; + res = lhs->edition().compare( rhs->edition() ); + if ( res ) + return res > 0; + + // no more criteria, still equal: + // use the ResObject::constPtr (the poiner value) + // (here it's arbitrary whether < or > ) + return lhs.resolvable() < rhs.resolvable(); + } + }; + + typedef std::set AvialableItemSet; typedef AvialableItemSet::iterator availableItem_iterator; typedef AvialableItemSet::const_iterator availableItem_const_iterator; typedef AvialableItemSet::size_type availableItem_size_type; -- 2.7.4