libzypp  13.10.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  {
42  struct AVOrder : public std::binary_function<PoolItem,PoolItem,bool>
43  {
44  // NOTE: operator() provides LESS semantics to order the set.
45  // So LESS means 'prior in set'. We want 'better' archs and
46  // 'better' editions at the beginning of the set. So we return
47  // TRUE if (lhs > rhs)!
48  //
49  bool operator()( const PoolItem & lhs, const PoolItem & rhs ) const
50  {
51  int lprio = lhs->satSolvable().repository().satInternalPriority();
52  int rprio = rhs->satSolvable().repository().satInternalPriority();
53  if ( lprio != rprio )
54  return( lprio > rprio );
55 
56  // arch/noarch changes are ok.
57  if ( lhs->arch() != Arch_noarch && rhs->arch() != Arch_noarch )
58  {
59  int res = lhs->arch().compare( rhs->arch() );
60  if ( res )
61  return res > 0;
62  }
63 
64  int res = lhs->edition().compare( rhs->edition() );
65  if ( res )
66  return res > 0;
67 
70  if ( lprio != rprio )
71  return( lprio > rprio );
72 
73  // no more criteria, still equal: sort by id
74  return lhs.satSolvable().id() < rhs.satSolvable().id();
75  }
76  };
77 
84  struct IOrder : public std::binary_function<PoolItem,PoolItem,bool>
85  {
86  // NOTE: operator() provides LESS semantics to order the set.
87  // So LESS means 'prior in set'. We want 'newer' install time
88  // at the beginning of the set.
89  //
90  bool operator()( const PoolItem & lhs, const PoolItem & rhs ) const
91  {
92  int res = lhs->arch().compare( rhs->arch() );
93  if ( res )
94  return res > 0;
95  res = lhs->edition().compare( rhs->edition() );
96  if ( res )
97  return res > 0;
98  Date ldate = lhs->installtime();
99  Date rdate = rhs->installtime();
100  if ( ldate != rdate )
101  return( ldate > rdate );
102 
103  // no more criteria, still equal: sort by id
104  return lhs.satSolvable().id() < rhs.satSolvable().id();
105  }
106  };
107 
108  typedef std::set<PoolItem,AVOrder> AvailableItemSet;
109  typedef AvailableItemSet::iterator available_iterator;
110  typedef AvailableItemSet::const_iterator available_const_iterator;
112 
113  typedef std::set<PoolItem,IOrder> InstalledItemSet;
114  typedef AvailableItemSet::iterator installed_iterator;
115  typedef AvailableItemSet::const_iterator installed_const_iterator;
117 
118  typedef std::vector<PoolItem> PickList;
119  typedef PickList::const_iterator picklist_iterator;
121  };
123 
125  } // namespace ui
128 } // namespace zypp
130 #endif // ZYPP_UI_SELECTABLETRAITS_H
Repository repository() const
The Repository this Solvable belongs to.
Definition: Solvable.cc:148
PickList::const_iterator picklist_iterator
Oder on InstalledItemSet.
std::vector< PoolItem > PickList
int satInternalSubPriority() const
Definition: Repository.cc:74
const Arch Arch_noarch(_noarch())
std::set< PoolItem, AVOrder > AvailableItemSet
bool operator()(const PoolItem &lhs, const PoolItem &rhs) const
Store and operate on date (time_t).
Definition: Date.h:31
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:99
PickList::size_type picklist_size_type
int satInternalPriority() const
libsolv internal priorities.
Definition: Repository.cc:68
AvailableItemSet::iterator installed_iterator
std::set< PoolItem, IOrder > InstalledItemSet
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: PoolItem.h:114
AvailableItemSet::size_type installed_size_type
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
IdType id() const
Expert backdoor.
Definition: Solvable.h:296
AvailableItemSet::size_type available_size_type
AvailableItemSet::iterator available_iterator
Oder on AvailableItemSet.