libzypp  17.19.0
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 
21 #include "zypp/sat/SolvableType.h"
22 #include "zypp/ResStatus.h"
23 
25 namespace zypp
26 {
27  class ResPool;
28  namespace pool
29  {
30  class PoolImpl;
31  }
50  class PoolItem : public sat::SolvableType<PoolItem>
51  {
52  friend std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
53  public:
55  PoolItem();
56 
58  explicit PoolItem( const sat::Solvable & solvable_r );
59 
61  template <class Derived>
62  explicit PoolItem( const SolvableType<Derived> & solvable_r )
63  : PoolItem( solvable_r.satSolvable() )
64  {}
65 
67  explicit PoolItem( const ResObject::constPtr & resolvable_r );
68 
70  ~PoolItem();
71 
72  public:
76  ResStatus & status() const;
77 
79  ResStatus & statusReset() const;
80 
81 
87  bool isUndetermined() const;
88 
92  bool isRelevant() const;
93 
95  bool isSatisfied() const;
96 
98  bool isBroken() const;
99 
103  bool isNeeded() const;
104 
106  bool isUnwanted() const;
107 
108  std::string patchStatusAsString () const;
109 
111 
113  public:
115  ResPool pool() const;
116 
118  explicit operator sat::Solvable() const
119  { return resolvable() ? resolvable()->satSolvable() : sat::Solvable::noSolvable; }
120 
124  sat::Solvable buddy() const;
125 
126  public:
131 
135  operator ResObject::constPtr() const
136  { return resolvable(); }
137 
140  { return resolvable(); }
141 
142  private:
143  friend class pool::PoolImpl;
145  static PoolItem makePoolItem( const sat::Solvable & solvable_r );
147  void setBuddy( const sat::Solvable & solv_r );
149  public:
150  struct Impl;
151  private:
152  explicit PoolItem( Impl * implptr_r );
155 
156  private:
160  friend struct PoolItemSaver;
161  void saveState() const;
162  void restoreState() const;
163  bool sameState() const;
165  };
167 
169  std::ostream & operator<<( std::ostream & str, const PoolItem & obj );
170 
171 
173  inline bool operator==( const PoolItem & lhs, const PoolItem & rhs )
174  { return lhs.resolvable() == rhs.resolvable(); }
175 
177  inline bool operator==( const PoolItem & lhs, const ResObject::constPtr & rhs )
178  { return lhs.resolvable() == rhs; }
179 
181  inline bool operator==( const ResObject::constPtr & lhs, const PoolItem & rhs )
182  { return lhs == rhs.resolvable(); }
183 
184 
186  inline bool operator!=( const PoolItem & lhs, const PoolItem & rhs )
187  { return ! (lhs==rhs); }
188 
190  inline bool operator!=( const PoolItem & lhs, const ResObject::constPtr & rhs )
191  { return ! (lhs==rhs); }
192 
194  inline bool operator!=( const ResObject::constPtr & lhs, const PoolItem & rhs )
195  { return ! (lhs==rhs); }
196 
201  struct asPoolItem
202  {
204 
205  PoolItem operator()( const sat::Solvable & solv_r ) const
206  { return PoolItem( solv_r ); }
207  };
208 
209 } // namespace zypp
211 #endif // ZYPP_POOLITEM_H
A Solvable object within the sat Pool.
Definition: Solvable.h:53
PoolItem()
Default ctor for use in std::container.
Definition: PoolItem.cc:187
PoolItem(const SolvableType< Derived > &solvable_r)
Ctor looking up the sat::Solvable in the ResPool.
Definition: PoolItem.h:62
bool sameState() const
Definition: PoolItem.cc:229
bool operator==(const ResObject::constPtr &lhs, const PoolItem &rhs)
Definition: PoolItem.h:181
void setBuddy(const sat::Solvable &solv_r)
Buddies are set by pool::PoolImpl.
Definition: PoolItem.cc:218
ResStatus & status() const
Returns the current status.
Definition: PoolItem.cc:215
PoolItem operator()(const sat::Solvable &solv_r) const
Definition: PoolItem.h:205
PoolItem result_type
Definition: PoolItem.h:203
String related utilities and Regular expression matching.
sat::Solvable buddy() const
Return the buddy we share our status object with.
Definition: PoolItem.cc:217
~PoolItem()
Dtor.
Definition: PoolItem.cc:208
bool isSatisfied() const
Whether a relevant items requirements are met.
Definition: PoolItem.cc:221
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
ResObject::constPtr operator->() const
Forward -> access to ResObject.
Definition: PoolItem.h:139
ResObject::constPtr resolvable() const
Returns the ResObject::constPtr.
Definition: PoolItem.cc:230
static const Solvable noSolvable
Represents no Solvable.
Definition: Solvable.h:74
bool isBroken() const
Whether a relevant items requirements are broken.
Definition: PoolItem.cc:222
ResStatus & statusReset() const
Reset status.
Definition: PoolItem.cc:216
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
bool isUndetermined() const
No validation is performed for packages.
Definition: PoolItem.cc:219
PoolItem implementation.
Definition: PoolItem.cc:37
void restoreState() const
Definition: PoolItem.cc:228
static PoolItem makePoolItem(const sat::Solvable &solvable_r)
PoolItem generator for pool::PoolImpl.
Definition: PoolItem.cc:203
bool operator!=(const PoolItem &lhs, const ResObject::constPtr &rhs)
Definition: PoolItem.h:190
bool isRelevant() const
Returns true if the solvable is relevant which means e.g.
Definition: PoolItem.cc:220
friend std::ostream & operator<<(std::ostream &str, const PoolItem &obj)
Definition: PoolItem.cc:233
ResPool pool() const
Return the ResPool the item belongs to.
Definition: PoolItem.cc:211
Global ResObject pool.
Definition: ResPool.h:60
bool operator==(const PoolItem &lhs, const PoolItem &rhs)
Definition: PoolItem.h:173
Status bitfield.
Definition: ResStatus.h:53
bool isNeeded() const
This includes unlocked broken patches, as well as those already selected to be installed (otherwise c...
Definition: PoolItem.cc:223
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
bool operator!=(const PoolItem &lhs, const PoolItem &rhs)
Definition: PoolItem.h:186
bool operator==(const PoolItem &lhs, const ResObject::constPtr &rhs)
Definition: PoolItem.h:177
std::string patchStatusAsString() const
Definition: PoolItem.cc:225
Base class for creating Solvable based types.
Definition: SolvableType.h:54
bool operator!=(const ResObject::constPtr &lhs, const PoolItem &rhs)
Definition: PoolItem.h:194
bool isUnwanted() const
Broken (needed) but locked patches.
Definition: PoolItem.cc:224
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: PoolItem.h:154
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Solvable to PoolItem transform functor.
Definition: PoolItem.h:201
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
void saveState() const
Definition: PoolItem.cc:227