libzypp  11.13.5
PoolItem.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_POOLITEM_H
13 #define ZYPP_POOLITEM_H
14 
15 #include <iosfwd>
16 #include <functional>
17 
18 #include "zypp/base/PtrTypes.h"
19 #include "zypp/ResObject.h"
20 #include "zypp/ResStatus.h"
21 
23 namespace zypp
24 {
25 
26  class ResPool;
27 
28  namespace pool
29  {
30  class PoolImpl;
31  }
32 
34  //
35  // CLASS NAME : PoolItem
36  //
50  class PoolItem
51  {
52  friend std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
53 
54  public:
56  class Impl;
57 
58  public:
60  PoolItem();
61 
63  explicit PoolItem( const sat::Solvable & solvable_r );
64 
66  explicit PoolItem( const ResObject::constPtr & resolvable_r );
67 
69  ~PoolItem();
70 
71  public:
75  ResStatus & status() const;
76 
78  ResStatus & statusReset() const;
79 
80 
86  bool isUndetermined() const;
87 
91  bool isRelevant() const;
92 
94  bool isSatisfied() const;
95 
97  bool isBroken() const;
98 
102  bool isNeeded() const;
103 
105  bool isUnwanted() const;
107 
109  public:
111  ResPool pool() const;
112 
115  { return resolvable() ? resolvable()->satSolvable() : sat::Solvable::noSolvable; }
116 
120  sat::Solvable buddy() const;
121 
122  public:
127 
131  operator ResObject::constPtr() const
132  { return resolvable(); }
133 
136  { return resolvable(); }
137 
140  operator ResObject::constPtr::unspecified_bool_type() const
141  { return resolvable(); }
142 
143  private:
144  friend class Impl;
145  friend class pool::PoolImpl;
147  static PoolItem makePoolItem( const sat::Solvable & solvable_r );
149  void setBuddy( sat::Solvable solv_r );
151  explicit PoolItem( Impl * implptr_r );
154 
155  private:
159  friend class PoolItemSaver;
160  void saveState() const;
161  void restoreState() const;
162  bool sameState() const;
164  };
166 
168  std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
169 
171  inline bool operator==( const PoolItem & lhs, const PoolItem & rhs )
172  { return lhs.resolvable() == rhs.resolvable(); }
173 
175  inline bool operator==( const PoolItem & lhs, const ResObject::constPtr & rhs )
176  { return lhs.resolvable() == rhs; }
177 
179  inline bool operator==( const ResObject::constPtr & lhs, const PoolItem & rhs )
180  { return lhs == rhs.resolvable(); }
181 
182 
184  inline bool operator!=( const PoolItem & lhs, const PoolItem & rhs )
185  { return ! (lhs==rhs); }
186 
188  inline bool operator!=( const PoolItem & lhs, const ResObject::constPtr & rhs )
189  { return ! (lhs==rhs); }
190 
192  inline bool operator!=( const ResObject::constPtr & lhs, const PoolItem & rhs )
193  { return ! (lhs==rhs); }
194 
195 
197  inline bool identical( const PoolItem & lhs, const PoolItem & rhs )
198  { return lhs == rhs || lhs.satSolvable().identical( rhs.satSolvable() ); }
199 
201  inline bool identical( const PoolItem & lhs, sat::Solvable rhs )
202  { return lhs.satSolvable().identical( rhs ); }
203 
205  inline bool identical( sat::Solvable lhs, const PoolItem & rhs )
206  { return lhs.identical( rhs.satSolvable() ); }
207 
208 
210  inline bool sameNVRA( const PoolItem & lhs, const PoolItem & rhs )
211  { return lhs == rhs || lhs.satSolvable().sameNVRA( rhs.satSolvable() ); }
212 
214  inline bool sameNVRA( const PoolItem & lhs, sat::Solvable rhs )
215  { return lhs.satSolvable().sameNVRA( rhs ); }
216 
218  inline bool sameNVRA( sat::Solvable lhs, const PoolItem & rhs )
219  { return lhs.sameNVRA( rhs.satSolvable() ); }
220 
225  struct asPoolItem
226  {
228 
229  PoolItem operator()( const sat::Solvable & solv_r ) const
230  { return PoolItem( solv_r ); }
231  };
232 
234 } // namespace zypp
237 namespace std
238 {
239 
241  template<>
242  inline bool less<zypp::PoolItem>::operator()( const zypp::PoolItem & lhs, const zypp::PoolItem & rhs ) const
243  { return lhs.resolvable() < rhs.resolvable(); }
244 
246 } // namespace zypp
248 #endif // ZYPP_POOLITEM_H