libzypp  15.28.6
SelectableTraits.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_UI_SELECTABLETRAITS_H
13 #define ZYPP_UI_SELECTABLETRAITS_H
14 
15 #include <set>
16 #include <vector>
17 
18 #include "zypp/base/Iterator.h"
19 #include "zypp/PoolItem.h"
20 #include "zypp/pool/ByIdent.h"
21 
23 namespace zypp
24 {
25  namespace ui
27  {
28 
30  //
31  // CLASS NAME : SelectableTraits
32  //
35  {
43  struct AVOrder : public std::binary_function<PoolItem,PoolItem,bool>
44  {
45  // NOTE: operator() provides LESS semantics to order the set.
46  // So LESS means 'prior in set'. We want 'better' archs and
47  // 'better' editions at the beginning of the set. So we return
48  // TRUE if (lhs > rhs)!
49  //
50  bool operator()( const PoolItem & lhs, const PoolItem & rhs ) const
51  {
52  int lprio = lhs->satSolvable().repository().satInternalPriority();
53  int rprio = rhs->satSolvable().repository().satInternalPriority();
54  if ( lprio != rprio )
55  return( lprio > rprio );
56 
57  // arch/noarch changes are ok.
58  if ( lhs->arch() != Arch_noarch && rhs->arch() != Arch_noarch )
59  {
60  int res = lhs->arch().compare( rhs->arch() );
61  if ( res )
62  return res > 0;
63  }
64 
65  int res = lhs->edition().compare( rhs->edition() );
66  if ( res )
67  return res > 0;
68 
69  lprio = lhs->buildtime();
70  rprio = rhs->buildtime();
71  if ( lprio != rprio )
72  return( lprio > rprio );
73 
76  if ( lprio != rprio )
77  return( lprio > rprio );
78 
79  // no more criteria, still equal: sort by id
80  return lhs.satSolvable().id() < rhs.satSolvable().id();
81  }
82  };
83 
90  struct IOrder : public std::binary_function<PoolItem,PoolItem,bool>
91  {
92  // NOTE: operator() provides LESS semantics to order the set.
93  // So LESS means 'prior in set'. We want 'newer' install time
94  // at the beginning of the set.
95  //
96  bool operator()( const PoolItem & lhs, const PoolItem & rhs ) const
97  {
98  int res = lhs->arch().compare( rhs->arch() );
99  if ( res )
100  return res > 0;
101  res = lhs->edition().compare( rhs->edition() );
102  if ( res )
103  return res > 0;
104  Date ldate = lhs->installtime();
105  Date rdate = rhs->installtime();
106  if ( ldate != rdate )
107  return( ldate > rdate );
108 
109  // no more criteria, still equal: sort by id
110  return lhs.satSolvable().id() < rhs.satSolvable().id();
111  }
112  };
113 
114  typedef std::set<PoolItem,AVOrder> AvailableItemSet;
115  typedef AvailableItemSet::iterator available_iterator;
116  typedef AvailableItemSet::const_iterator available_const_iterator;
118 
119  typedef std::set<PoolItem,IOrder> InstalledItemSet;
120  typedef AvailableItemSet::iterator installed_iterator;
121  typedef AvailableItemSet::const_iterator installed_const_iterator;
123 
124  typedef std::vector<PoolItem> PickList;
125  typedef PickList::const_iterator picklist_iterator;
127  };
129 
131  } // namespace ui
134 } // namespace zypp
136 #endif // ZYPP_UI_SELECTABLETRAITS_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:351
PickList::const_iterator picklist_iterator
Oder on InstalledItemSet.
Date buildtime() const
Definition: SolvableType.h:82
std::vector< PoolItem > PickList
int satInternalSubPriority() const
Definition: Repository.cc:79
std::set< PoolItem, AVOrder > AvailableItemSet
bool operator()(const PoolItem &lhs, const PoolItem &rhs) const
int compare(const Arch &rhs) const
Arch comparison.
Definition: Arch.cc:532
static int compare(const Derived &lhs, const Derived &rhs)
Definition: IdStringType.h:127
Store and operate on date (time_t).
Definition: Date.h:32
AvailableItemSet::const_iterator available_const_iterator
AvailableItemSet::const_iterator installed_const_iterator
bool operator()(const PoolItem &lhs, const PoolItem &rhs) const
SolvableIdType size_type
Definition: PoolMember.h:152
PickList::size_type picklist_size_type
int satInternalPriority() const
libsolv internal priorities.
Definition: Repository.cc:73
AvailableItemSet::iterator installed_iterator
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
std::set< PoolItem, IOrder > InstalledItemSet
AvailableItemSet::size_type installed_size_type
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
IdType id() const
Expert backdoor.
Definition: Solvable.h:374
Date installtime() const
Definition: SolvableType.h:83
Edition edition() const
Definition: SolvableType.h:71
AvailableItemSet::size_type available_size_type
AvailableItemSet::iterator available_iterator
Oder on AvailableItemSet.