libzypp  17.5.0
ResPoolProxy.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESPOOLPROXY_H
13 #define ZYPP_RESPOOLPROXY_H
14 
15 #include <iosfwd>
16 
17 #include "zypp/base/PtrTypes.h"
18 
19 #include "zypp/ResPool.h"
20 #include "zypp/ui/Selectable.h"
21 #include "zypp/ui/SelFilters.h"
22 
24 namespace zypp
25 {
26 
28  //
29  // CLASS NAME : ResPoolProxy
30  //
35  {
36  friend std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
37  friend std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
38  typedef std::multimap<ResKind,ui::Selectable::Ptr> SelectablePool;
39 
40  public:
42  class Impl;
43 
46 
48 
49  public:
50 
58  ResPoolProxy();
59 
61  ~ResPoolProxy();
62 
63  public:
66  ui::Selectable::Ptr lookup( const pool::ByIdent & ident_r ) const;
67 
69  { return lookup( pool::ByIdent( ident_r ) ); }
70 
71  ui::Selectable::Ptr lookup( ResKind kind_r, const std::string & name_r ) const
72  { return lookup( pool::ByIdent( kind_r, name_r ) ); }
73 
74  ui::Selectable::Ptr lookup( const sat::Solvable & solv_r ) const
75  { return lookup( pool::ByIdent( solv_r ) ); }
76 
77  ui::Selectable::Ptr lookup( const ResObject::constPtr & resolvable_r ) const
78  { return resolvable_r ? lookup( resolvable_r->satSolvable() ) : ui::Selectable::Ptr(); }
79 
80  ui::Selectable::Ptr lookup( const PoolItem & pi_r ) const
81  { return lookup( pi_r.satSolvable() ); }
83 
84  public:
87  bool empty() const;
88  size_type size() const;
89  const_iterator begin() const;
90  const_iterator end() const;
92 
96  bool empty( const ResKind & kind_r ) const;
97 
98  template<class TRes>
99  bool empty() const
100  { return empty( ResTraits<TRes>::kind ); }
101 
103  size_type size( const ResKind & kind_r ) const;
104 
105  template<class TRes>
106  size_type size() const
107  { return size( ResTraits<TRes>::kind ); }
108 
109  const_iterator byKindBegin( const ResKind & kind_r ) const;
110 
111  template<class TRes>
113  { return byKindBegin( ResTraits<TRes>::kind ); }
114 
115 
116  const_iterator byKindEnd( const ResKind & kind_r ) const;
117 
118  template<class TRes>
120  { return byKindEnd( ResTraits<TRes>::kind ); }
121 
122 
123  Iterable<const_iterator> byKind( const ResKind & kind_r ) const
124  { return makeIterable( byKindBegin( kind_r ), byKindEnd( kind_r ) ); }
125 
126  template<class TRes>
128  { return makeIterable( byKindBegin<TRes>(), byKindEnd<TRes>() ); }
129 
131 
132  public:
137 
139 
141 
143  { return makeIterable( knownRepositoriesBegin(), knownRepositoriesEnd() ); }
145 
146  public:
150  bool hasInstalledObj( const ResKind & kind_r ) const
151  {
152  return( make_begin<ui::selfilter::ByHasInstalledObj>( kind_r )
153  != make_end<ui::selfilter::ByHasInstalledObj>( kind_r ) );
154  }
155 
156  template<class TRes>
157  bool hasInstalledObj() const
159 
160  public:
171  void saveState() const;
172 
173  void saveState( const ResKind & kind_r ) const;
174 
175  template<class TRes>
176  void saveState() const
177  { return saveState( ResTraits<TRes>::kind ); }
178 
179  void restoreState() const;
180 
181  void restoreState( const ResKind & kind_r ) const;
182 
183  template<class TRes>
184  void restoreState() const
185  { return restoreState( ResTraits<TRes>::kind ); }
186 
187  bool diffState() const;
188 
189  bool diffState( const ResKind & kind_r ) const;
190 
191  template<class TRes>
192  bool diffState() const
193  { return diffState( ResTraits<TRes>::kind ); }
194 
202  struct ScopedSaveState;
203 
204  ScopedSaveState scopedSaveState() const;
205 
206  ScopedSaveState scopedSaveState( const ResKind & kind_r ) const;
207 
208  template<class TRes>
211 
213 
214  private:
215  template<class TFilter>
216  filter_iterator<TFilter,const_iterator>
217  make_begin( TFilter filter_r, const ResKind & kind_r ) const
218  {
219  return make_filter_iterator( filter_r,
220  byKindBegin(kind_r),
221  byKindEnd(kind_r) );
222  }
223  template<class TFilter>
224  filter_iterator<TFilter,const_iterator>
225  make_begin( const ResKind & kind_r ) const
226  {
227  return make_begin( TFilter(), kind_r );
228  }
229 
230 
231  template<class TFilter>
232  filter_iterator<TFilter,const_iterator>
233  make_end( TFilter filter_r, const ResKind & kind_r ) const
234  {
235  return make_filter_iterator( filter_r,
236  byKindEnd(kind_r),
237  byKindEnd(kind_r) );
238  }
239  template<class TFilter>
240  filter_iterator<TFilter,const_iterator>
241  make_end( const ResKind & kind_r ) const
242  {
243  return make_end( TFilter(), kind_r );
244  }
245 
246  private:
247  friend class pool::PoolImpl;
249  ResPoolProxy( ResPool pool_r, const pool::PoolImpl & poolImpl_r );
252  };
254 
256  std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
257 
259  std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
260 
262 
264  {
266 
267  ScopedSaveState( const ResPoolProxy & pool_r )
268  : _pimpl( new Impl( pool_r ) )
269  { _pimpl->saveState(); }
270 
271  ScopedSaveState( const ResPoolProxy & pool_r, const ResKind & kind_r )
272  : _pimpl( new Impl( pool_r, kind_r ) )
273  { _pimpl->saveState(); }
274 
276  { if ( _pimpl ) _pimpl->restoreState(); }
277 
278  void acceptState()
279  { _pimpl.reset(); }
280 
281  private:
282  struct Impl
283  {
284  Impl( const ResPoolProxy & pool_r )
285  : _pool( pool_r )
286  {}
287  Impl( const ResPoolProxy & pool_r, const ResKind & kind_r )
288  : _pool( pool_r ), _kind( new ResKind( kind_r ) )
289  {}
290  void saveState()
291  { if ( _kind ) _pool.saveState( *_kind ); else _pool.saveState(); }
293  { if ( _kind ) _pool.restoreState( *_kind ); else _pool.restoreState(); }
295  scoped_ptr<ResKind> _kind;
296 
297  };
298  std::unique_ptr<Impl> _pimpl;
299  };
300 
302  { return ScopedSaveState( *this ); }
303 
305  { return ScopedSaveState( *this, kind_r ); }
306 
308 } // namespace zypp
310 #endif // ZYPP_RESPOOLPROXY_H
void restoreState() const
Definition: ResPoolProxy.h:184
filter_iterator< TFilter, const_iterator > make_begin(const ResKind &kind_r) const
Definition: ResPoolProxy.h:225
A Solvable object within the sat Pool.
Definition: Solvable.h:53
filter_iterator< TFilter, const_iterator > make_end(TFilter filter_r, const ResKind &kind_r) const
Definition: ResPoolProxy.h:233
size_type size() const
Definition: ResPoolProxy.h:106
filter_iterator< TFilter, const_iterator > make_end(const ResKind &kind_r) const
Definition: ResPoolProxy.h:241
intrusive_ptr< Selectable > Ptr
Definition: Selectable.h:57
ui::Selectable::Ptr lookup(ResKind kind_r, const std::string &name_r) const
Definition: ResPoolProxy.h:71
String related utilities and Regular expression matching.
bool diffState() const
transform_iterator< GetPairSecond< typename MapType::value_type >, typename MapType::const_iterator > Value_const_iterator
The value iterator type.
Definition: Iterator.h:223
bool diffState() const
Definition: ResPoolProxy.h:192
ui::Selectable::Ptr lookup(const PoolItem &pi_r) const
Definition: ResPoolProxy.h:80
Access to the sat-pools string space.
Definition: IdString.h:41
ResTraits.
Definition: ResTraits.h:79
void saveState() const
TraitsType::constPtrType constPtr
Definition: ResObject.h:44
ResPool::instance().proxy();.
Definition: ResPoolProxy.h:34
ResPoolProxy implementation.
Definition: ResPoolProxy.cc:91
Exception safe scoped save/restore state.
Definition: ResPoolProxy.h:263
const_iterator byKindEnd() const
Definition: ResPoolProxy.h:119
ui::Selectable::Ptr lookup(const ResObject::constPtr &resolvable_r) const
Definition: ResPoolProxy.h:77
bool empty() const
repository_iterator knownRepositoriesEnd() const
size_type knownRepositoriesSize() const
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
friend std::ostream & operator<<(std::ostream &str, const ResPoolProxy &obj)
ResPool::repository_iterator repository_iterator
Definition: ResPoolProxy.h:47
Impl(const ResPoolProxy &pool_r, const ResKind &kind_r)
Definition: ResPoolProxy.h:287
ui::Selectable::Ptr lookup(IdString ident_r) const
Definition: ResPoolProxy.h:68
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: ResPoolProxy.h:251
const_iterator end() const
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:444
friend std::ostream & dumpOn(std::ostream &str, const ResPoolProxy &obj)
SolvableIdType size_type
Definition: PoolMember.h:126
std::unique_ptr< Impl > _pimpl
Definition: ResPoolProxy.h:298
Iterable< repository_iterator > knownRepositories() const
Definition: ResPoolProxy.h:142
Global ResObject pool.
Definition: ResPool.h:60
void saveState() const
Definition: ResPoolProxy.h:176
SelectablePool::size_type size_type
Definition: ResPoolProxy.h:45
repository_iterator knownRepositoriesBegin() const
std::multimap< ResKind, ui::Selectable::Ptr > SelectablePool
Definition: ResPoolProxy.h:38
Iterable< const_iterator > byKind() const
Definition: ResPoolProxy.h:127
const_iterator begin() const
filter_iterator< TFilter, const_iterator > make_begin(TFilter filter_r, const ResKind &kind_r) const
Definition: ResPoolProxy.h:217
ui::Selectable::Ptr lookup(const sat::Solvable &solv_r) const
Definition: ResPoolProxy.h:74
const_iterator byKindBegin() const
Definition: ResPoolProxy.h:112
ResPoolProxy()
Default ctor: no pool Nonempty proxies are provided by ResPool.
size_type size() const
bool hasInstalledObj() const
Definition: ResPoolProxy.h:157
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
bool empty() const
Definition: ResPoolProxy.h:99
void restoreState() const
MapKVIteratorTraits< SelectablePool >::Value_const_iterator const_iterator
Definition: ResPoolProxy.h:42
ui::Selectable::Ptr lookup(const pool::ByIdent &ident_r) const
ScopedSaveState(const ResPoolProxy &pool_r, const ResKind &kind_r)
Definition: ResPoolProxy.h:271
ScopedSaveState(const ResPoolProxy &pool_r)
Definition: ResPoolProxy.h:267
Resolvable kinds.
Definition: ResKind.h:32
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Impl(const ResPoolProxy &pool_r)
Definition: ResPoolProxy.h:284
Iterable< const_iterator > byKind(const ResKind &kind_r) const
Definition: ResPoolProxy.h:123
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:26
ScopedSaveState && scopedSaveState() const
Definition: ResPoolProxy.h:209
ScopedSaveState scopedSaveState() const
Definition: ResPoolProxy.h:301
bool hasInstalledObj(const ResKind &kind_r) const
Test whether there is at least one ui::Selectable with an installed object.
Definition: ResPoolProxy.h:150