libzypp  17.14.0
ResPool.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
12 #ifndef ZYPP_RESPOOL_H
13 #define ZYPP_RESPOOL_H
14 
15 #include <iosfwd>
16 
17 #include "zypp/APIConfig.h"
18 #include "zypp/base/Iterator.h"
19 
20 #include "zypp/pool/PoolTraits.h"
21 #include "zypp/PoolItem.h"
22 #include "zypp/Filter.h"
23 
25 namespace zypp
26 {
27 
28  class SerialNumber;
29  class ResPoolProxy;
30  class Resolver;
31 
33  //
34  // CLASS NAME : ResPool
35  //
60  class ResPool
61  {
62  friend std::ostream & operator<<( std::ostream & str, const ResPool & obj );
63 
64  public:
70 
71  public:
73  static ResPool instance();
74 
76  ResPoolProxy proxy() const;
77 
79  Resolver & resolver() const;
80 
81  public:
86  const SerialNumber & serial() const;
87 
88  public:
90  bool empty() const;
92  size_type size() const;
93 
98  { return make_filter_begin( pool::ByPoolItem(), store() ); }
101  { return make_filter_end( pool::ByPoolItem(), store() ); }
103 
104  public:
110  PoolItem find( const sat::Solvable & slv_r ) const;
112  PoolItem find( const ResObject::constPtr & resolvable_r ) const
113  { return( resolvable_r ? find( resolvable_r->satSolvable() ) : PoolItem() ); }
114 
115  public:
118  template<class TFilter>
119  filter_iterator<TFilter,const_iterator> filterBegin( const TFilter & filter_r ) const
120  { return make_filter_begin( filter_r, *this ); }
121 
122  template<class TFilter>
123  filter_iterator<TFilter,const_iterator> filterEnd( const TFilter & filter_r ) const
124  { return make_filter_end( filter_r, *this ); }
125 
126  template<class TFilter>
127  Iterable<filter_iterator<TFilter,const_iterator> > filter( const TFilter & filter_r ) const
128  { return makeIterable( filterBegin( filter_r ), filterEnd( filter_r ) ); }
130 
150  filter_iterator<filter::ByStatus,const_iterator> byStatusBegin( const filter::ByStatus & filter_r ) const
151  { return make_filter_begin( filter_r, *this ); }
152 
153  filter_iterator<filter::ByStatus,const_iterator> byStatusEnd( const filter::ByStatus & filter_r ) const
154  { return make_filter_end( filter_r, *this ); }
155 
157  { return makeIterable( byStatusBegin( filter_r ), byStatusEnd( filter_r ) ); }
159 
160  public:
165 
166  byIdent_iterator byIdentBegin( const ByIdent & ident_r ) const
167  {
168  return make_transform_iterator( id2item().equal_range( ident_r.get() ).first,
170  }
171 
173  { return byIdentBegin( ByIdent(kind_r,name_r) ); }
174 
175  byIdent_iterator byIdentBegin( ResKind kind_r, const C_Str & name_r ) const
176  { return byIdentBegin( ByIdent(kind_r,name_r) ); }
177 
178  template<class TRes>
180  { return byIdentBegin( ByIdent(ResTraits<TRes>::kind,name_r) ); }
181 
182  template<class TRes>
183  byIdent_iterator byIdentBegin( const C_Str & name_r ) const
184  { return byIdentBegin( ByIdent(ResTraits<TRes>::kind,name_r) ); }
185 
187  byIdent_iterator byIdentBegin( const PoolItem & pi_r ) const
188  { return byIdentBegin( ByIdent(pi_r.satSolvable()) ); }
191  { return byIdentBegin( ByIdent(slv_r) ); }
194  { return byIdentBegin( ByIdent(ident_r) ); }
195 
196 
197  byIdent_iterator byIdentEnd( const ByIdent & ident_r ) const
198  {
199  return make_transform_iterator( id2item().equal_range( ident_r.get() ).second,
201  }
202 
203  byIdent_iterator byIdentEnd( ResKind kind_r, IdString name_r ) const
204  { return byIdentEnd( ByIdent(kind_r,name_r) ); }
205 
206  byIdent_iterator byIdentEnd( ResKind kind_r, const C_Str & name_r ) const
207  { return byIdentEnd( ByIdent(kind_r,name_r) ); }
208 
209  template<class TRes>
211  { return byIdentEnd( ByIdent(ResTraits<TRes>::kind,name_r) ); }
212 
213  template<class TRes>
214  byIdent_iterator byIdentEnd( const C_Str & name_r ) const
215  { return byIdentEnd( ByIdent(ResTraits<TRes>::kind,name_r) ); }
216 
218  byIdent_iterator byIdentEnd( const PoolItem & pi_r ) const
219  { return byIdentEnd( ByIdent(pi_r.satSolvable()) ); }
222  { return byIdentEnd( ByIdent(slv_r) ); }
225  { return byIdentEnd( ByIdent(ident_r) ); }
226 
227 
228  Iterable<byIdent_iterator> byIdent( const ByIdent & ident_r ) const
229  { return makeIterable( byIdentBegin( ident_r ), byIdentEnd( ident_r ) ); }
230 
232  { return makeIterable( byIdentBegin( kind_r, name_r ), byIdentEnd( kind_r, name_r ) ); }
233 
234  Iterable<byIdent_iterator> byIdent( ResKind kind_r, const C_Str & name_r ) const
235  { return makeIterable( byIdentBegin( kind_r, name_r ), byIdentEnd( kind_r, name_r ) ); }
236 
237  template<class TRes>
239  { return makeIterable( byIdentBegin<TRes>( name_r ), byIdentEnd<TRes>( name_r ) ); }
240 
241  template<class TRes>
242  Iterable<byIdent_iterator> byIdent( const C_Str & name_r ) const
243  { return makeIterable( byIdentBegin<TRes>( name_r ), byIdentEnd<TRes>( name_r ) ); }
244 
246  { return makeIterable( byIdentBegin( pi_r ), byIdentEnd( pi_r ) ); }
247 
249  { return makeIterable( byIdentBegin( slv_r ), byIdentEnd( slv_r ) ); }
250 
252  { return makeIterable( byIdentBegin( ident_r ), byIdentEnd( ident_r ) ); }
254 
255  public:
259  typedef filter_iterator<ByKind,const_iterator> byKind_iterator;
260 
261  byKind_iterator byKindBegin( const ResKind & kind_r ) const
262  { return make_filter_begin( ByKind(kind_r), *this ); }
263 
264  template<class TRes>
266  { return make_filter_begin( resfilter::byKind<TRes>(), *this ); }
267 
268  byKind_iterator byKindEnd( const ResKind & kind_r ) const
269  { return make_filter_end( ByKind(kind_r), *this ); }
270 
271  template<class TRes>
273  { return make_filter_end( resfilter::byKind<TRes>(), *this ); }
274 
275  Iterable<byKind_iterator> byKind( const ResKind & kind_r ) const
276  { return makeIterable( byKindBegin( kind_r ), byKindEnd( kind_r ) ); }
277 
278  template<class TRes>
280  { return makeIterable( byKindBegin<TRes>(), byKindEnd<TRes>() ); }
282 
283  public:
287  typedef filter_iterator<ByName,const_iterator> byName_iterator;
288 
289  byName_iterator byNameBegin( const std::string & name_r ) const
290  { return make_filter_begin( ByName(name_r), *this ); }
291 
292  byName_iterator byNameEnd( const std::string & name_r ) const
293  { return make_filter_end( ByName(name_r), *this ); }
294 
295  Iterable<byName_iterator> byName( const std::string & name_r ) const
296  { return makeIterable( byNameBegin( name_r ), byNameEnd( name_r ) ); }
298 
299  public:
302 
304  public:
309 
311 
313 
317  Repository reposFind( const std::string & alias_r ) const;
318 
320  { return makeIterable( knownRepositoriesBegin(), knownRepositoriesEnd() ); }
322 
323  public:
352  void setRequestedLocales( const LocaleSet & locales_r );
353 
357  bool addRequestedLocale( const Locale & locale_r );
358 
362  bool eraseRequestedLocale( const Locale & locale_r );
363 
367  const LocaleSet & getRequestedLocales() const;
368 
370  bool isRequestedLocale( const Locale & locale_r ) const;
371 
376  const LocaleSet & getAvailableLocales() const;
377 
379  bool isAvailableLocale( const Locale & locale_r ) const;
381 
382  public:
392 
393  bool hardLockQueriesEmpty() const;
397 
399  { return makeIterable( hardLockQueriesBegin(), hardLockQueriesEnd() ); }
400 
405  void setHardLockQueries( const HardLockQueries & newLocks_r );
406 
410  void getHardLockQueries( HardLockQueries & activeLocks_r );
412 
413  private:
414  const pool::PoolTraits::ItemContainerT & store() const;
415  const pool::PoolTraits::Id2ItemT & id2item() const;
416 
417  private:
422  };
424 
426  std::ostream & operator<<( std::ostream & str, const ResPool & obj );
427 
429 } // namespace zypp
431 
432 #include "zypp/ResPoolProxy.h"
433 
434 #endif // ZYPP_RESPOOL_H