libzypp  13.10.6
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  explicit operator bool() const
141  { return bool(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
A Solvable object within the sat Pool.
Definition: Solvable.h:55
PoolItem()
Default ctor for use in std::container.
Definition: PoolItem.cc:178
bool sameNVRA(const PoolItem &lhs, const PoolItem &rhs)
Definition: PoolItem.h:210
bool operator==(const ResObject::constPtr &lhs, const PoolItem &rhs)
Definition: PoolItem.h:179
bool sameState() const
Definition: PoolItem.cc:277
ResStatus & statusReset() const
Reset status.
Definition: PoolItem.cc:244
bool identical(const PoolItem &lhs, const PoolItem &rhs)
Definition: PoolItem.h:197
bool identical(const PoolItem &lhs, sat::Solvable rhs)
Definition: PoolItem.h:201
PoolItem operator()(const sat::Solvable &solv_r) const
Definition: PoolItem.h:229
PoolItem result_type
Definition: PoolItem.h:227
void saveState() const
Definition: PoolItem.cc:271
~PoolItem()
Dtor.
Definition: PoolItem.cc:224
TraitsType::constPtrType constPtr
Definition: ResObject.h:50
static const Solvable noSolvable
Represents no Solvable.
Definition: Solvable.h:71
bool isUndetermined() const
No validation is performed for packages.
Definition: PoolItem.cc:253
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
Definition: PoolItem.cc:280
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
PoolItem implementation.
Definition: PoolItem.cc:37
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:241
static PoolItem makePoolItem(const sat::Solvable &solvable_r)
PoolItem generator for pool::PoolImpl.
Definition: PoolItem.cc:214
bool isRelevant() const
Returns true if the solvable is relevant which means e.g.
Definition: PoolItem.cc:256
bool isNeeded() const
This includes unlocked broken patches, as well as those already selected to be installed (otherwise c...
Definition: PoolItem.cc:265
bool operator!=(const PoolItem &lhs, const ResObject::constPtr &rhs)
Definition: PoolItem.h:188
void restoreState() const
Definition: PoolItem.cc:274
ResObject::constPtr operator->() const
Forward -&gt; access to ResObject.
Definition: PoolItem.h:135
bool isBroken() const
Whether a relevant items requirements are broken.
Definition: PoolItem.cc:262
friend std::ostream & operator<<(std::ostream &str, const PoolItem &obj)
Definition: PoolItem.cc:288
sat::Solvable buddy() const
Return the buddy we share our status object with.
Definition: PoolItem.cc:247
Global ResObject pool.
Definition: ResPool.h:48
bool sameNVRA(const PoolItem &lhs, sat::Solvable rhs)
Definition: PoolItem.h:214
bool operator==(const PoolItem &lhs, const PoolItem &rhs)
Definition: PoolItem.h:171
void setBuddy(sat::Solvable solv_r)
Buddies are set by pool::PoolImpl.
Definition: PoolItem.cc:250
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:265
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: PoolItem.h:114
Status bitfield.
Definition: ResStatus.h:53
bool isSatisfied() const
Whether a relevant items requirements are met.
Definition: PoolItem.cc:259
bool sameNVRA(Solvable rhs) const
Test for same name-version-release.arch.
Definition: Solvable.h:198
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
bool operator!=(const PoolItem &lhs, const PoolItem &rhs)
Definition: PoolItem.h:184
bool operator==(const PoolItem &lhs, const ResObject::constPtr &rhs)
Definition: PoolItem.h:175
bool identical(sat::Solvable lhs, const PoolItem &rhs)
Definition: PoolItem.h:205
bool sameNVRA(sat::Solvable lhs, const PoolItem &rhs)
Definition: PoolItem.h:218
ResPool pool() const
Return the ResPool the item belongs to.
Definition: PoolItem.cc:232
bool operator!=(const ResObject::constPtr &lhs, const PoolItem &rhs)
Definition: PoolItem.h:192
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: PoolItem.h:153
Solvable to PoolItem transform functor.
Definition: PoolItem.h:225
bool isUnwanted() const
Broken (needed) but locked patches.
Definition: PoolItem.cc:268
bool identical(Solvable rhs) const
Test whether two Solvables have the same content.
Definition: Solvable.cc:525