libzypp  17.8.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
transform_iterator< Id2ItemValueSelector, Id2ItemT::const_iterator > byIdent_iterator
Definition: PoolTraits.h:82
sat::detail::IdType get() const
Definition: ByIdent.h:88
byIdent_iterator byIdentBegin(ResKind kind_r, IdString name_r) const
Definition: ResPool.h:172
ItemContainerT::size_type size_type
Definition: PoolTraits.h:75
Iterable< repository_iterator > knownRepositories() const
Definition: ResPool.h:319
A Solvable object within the sat Pool.
Definition: Solvable.h:53
ResPoolProxy proxy() const
preliminary
Definition: ResPool.cc:54
byKind_iterator byKindEnd() const
Definition: ResPool.h:272
Iterable< byIdent_iterator > byIdent(const ByIdent &ident_r) const
Definition: ResPool.h:228
zypp::resfilter::ByName ByName
Definition: ResPool.h:286
bool empty() const
Definition: ResPool.cc:63
Repository reposFind(const std::string &alias_r) const
Find a Repository named alias_r.
Definition: ResPool.cc:83
Iterable< byIdent_iterator > byIdent(sat::Solvable slv_r) const
Definition: ResPool.h:248
const LocaleSet & getRequestedLocales() const
Return the requested locales.
Definition: ResPool.cc:125
const_iterator end() const
Definition: ResPool.h:100
byIdent_iterator byIdentEnd(ResKind kind_r, const C_Str &name_r) const
Definition: ResPool.h:206
std::vector< PoolItem > ItemContainerT
pure items
Definition: PoolTraits.h:71
Filter solvables according to their status.
Definition: Filter.h:141
byIdent_iterator byIdentBegin(IdString name_r) const
Definition: ResPool.h:179
filter_iterator< filter::ByStatus, const_iterator > byStatusEnd(const filter::ByStatus &filter_r) const
Definition: ResPool.h:153
pool::PoolTraits::repository_iterator repository_iterator
Definition: ResPool.h:69
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
Definition: ResPool.cc:70
repository_iterator knownRepositoriesBegin() const
Definition: ResPool.cc:77
pool::PoolTraits::size_type size_type
Definition: ResPool.h:67
friend std::ostream & operator<<(std::ostream &str, const ResPool &obj)
Definition: ResPool.cc:142
Iterable< filter_iterator< filter::ByStatus, const_iterator > > byStatus(const filter::ByStatus &filter_r) const
Definition: ResPool.h:156
byKind_iterator byKindBegin(const ResKind &kind_r) const
Definition: ResPool.h:261
String related utilities and Regular expression matching.
In CXX0X std::_Select2nd does no longer derive from std::unary_function.
Definition: PoolTraits.h:49
Access to the sat-pools string space.
Definition: IdString.h:41
repository_iterator knownRepositoriesEnd() const
Definition: ResPool.cc:80
const SerialNumber & serial() const
The pools serial number.
Definition: ResPool.cc:60
bool hardLockQueriesEmpty() const
Definition: ResPool.cc:86
Iterable< filter_iterator< TFilter, const_iterator > > filter(const TFilter &filter_r) const
Definition: ResPool.h:127
pool::PoolTraits::HardLockQueries HardLockQueries
Definition: ResPool.h:390
ResTraits.
Definition: ResTraits.h:79
byKind_iterator byKindBegin() const
Definition: ResPool.h:265
TraitsType::constPtrType constPtr
Definition: ResObject.h:44
std::list< PoolQuery > HardLockQueries
hard locks from etc/zypp/locks
Definition: PoolTraits.h:88
byIdent_iterator byIdentEnd(const C_Str &name_r) const
Definition: ResPool.h:214
filter_iterator< TFilter, typename TContainer::const_iterator > make_filter_end(TFilter f, const TContainer &c)
Convenience to create filter_iterator from container::end().
Definition: Iterator.h:117
Select ResObject by name.
Definition: ResFilters.h:160
ResPool::instance().proxy();.
Definition: ResPoolProxy.h:34
const_iterator begin() const
Definition: ResPool.h:97
bool eraseRequestedLocale(const Locale &locale_r)
Erase one Locale from the set of requested locales.
Definition: ResPool.cc:122
Iterable< byKind_iterator > byKind() const
Definition: ResPool.h:279
shared_ptr< PoolImpl > Impl_Ptr
Definition: PoolTraits.h:92
byIdent_iterator byIdentEnd(IdString ident_r) const
Takes a sat::Solvable::ident string.
Definition: ResPool.h:224
const pool::PoolTraits::Id2ItemT & id2item() const
Definition: ResPool.cc:108
filter_iterator< ByKind, const_iterator > byKind_iterator
Definition: ResPool.h:259
filter_iterator< ByName, const_iterator > byName_iterator
Definition: ResPool.h:287
byIdent_iterator byIdentEnd(IdString name_r) const
Definition: ResPool.h:210
Dependency resolver interface.
Definition: Resolver.h:54
Iterable< byIdent_iterator > byIdent(IdString ident_r) const
Definition: ResPool.h:251
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
filter_iterator< TFilter, const_iterator > filterBegin(const TFilter &filter_r) const
Definition: ResPool.h:119
Iterable< byIdent_iterator > byIdent(const C_Str &name_r) const
Definition: ResPool.h:242
byIdent_iterator byIdentBegin(sat::Solvable slv_r) const
Derive name and kind from sat::Solvable.
Definition: ResPool.h:190
pool::PoolTraits::byIdent_iterator byIdent_iterator
Definition: ResPool.h:164
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:90
Provides API related macros.
void getHardLockQueries(HardLockQueries &activeLocks_r)
Suggest a new set of queries based on the current selection.
Definition: ResPool.cc:101
hardLockQueries_iterator hardLockQueriesBegin() const
Definition: ResPool.cc:92
PoolItem value_type
PoolItem
Definition: ResPool.h:66
Resolver & resolver() const
The Resolver.
Definition: ResPool.cc:57
byIdent_iterator byIdentBegin(const C_Str &name_r) const
Definition: ResPool.h:183
byName_iterator byNameBegin(const std::string &name_r) const
Definition: ResPool.h:289
filter_iterator< ByPoolItem, ItemContainerT::const_iterator > const_iterator
Definition: PoolTraits.h:74
Iterable< hardLockQueries_iterator > hardLockQueries() const
Definition: ResPool.h:398
Iterable< byIdent_iterator > byIdent(const PoolItem &pi_r) const
Definition: ResPool.h:245
Simple serial number provider.
Definition: SerialNumber.h:44
Iterable< byIdent_iterator > byIdent(IdString name_r) const
Definition: ResPool.h:238
&#39;Language[_Country]&#39; codes.
Definition: Locale.h:49
byKind_iterator byKindEnd(const ResKind &kind_r) const
Definition: ResPool.h:268
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
Definition: ResPool.cc:98
byIdent_iterator byIdentBegin(const PoolItem &pi_r) const
Derive name and kind from PoolItem.
Definition: ResPool.h:187
bool isRequestedLocale(const Locale &locale_r) const
Whether this Locale is in the set of requested locales.
Definition: ResPool.cc:128
PoolItem find(const ResObject::constPtr &resolvable_r) const
Definition: ResPool.h:112
byIdent_iterator byIdentBegin(IdString ident_r) const
Takes a sat::Solvable::ident string.
Definition: ResPool.h:193
Global ResObject pool.
Definition: ResPool.h:60
std::unordered_multimap< sat::detail::IdType, PoolItem > Id2ItemT
ident index
Definition: PoolTraits.h:79
bool addRequestedLocale(const Locale &locale_r)
Add one Locale to the set of requested locales.
Definition: ResPool.cc:119
Iterable< byName_iterator > byName(const std::string &name_r) const
Definition: ResPool.h:295
pool::PoolTraits::hardLockQueries_iterator hardLockQueries_iterator
Definition: ResPool.h:391
Iterable< byKind_iterator > byKind(const ResKind &kind_r) const
Definition: ResPool.h:275
size_type size() const
Definition: ResPool.cc:66
filter::ByKind ByKind
Definition: ResPool.h:258
byIdent_iterator byIdentEnd(const PoolItem &pi_r) const
Derive name and kind from PoolItem.
Definition: ResPool.h:218
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:285
filter_iterator< filter::ByStatus, const_iterator > byStatusBegin(const filter::ByStatus &filter_r) const
Definition: ResPool.h:150
byName_iterator byNameEnd(const std::string &name_r) const
Definition: ResPool.h:292
size_type knownRepositoriesSize() const
Definition: ResPool.cc:74
bool isAvailableLocale(const Locale &locale_r) const
Whether this Locale is in the set of available locales.
Definition: ResPool.cc:134
HardLockQueries::const_iterator hardLockQueries_iterator
Definition: PoolTraits.h:89
pool::ByIdent ByIdent
Definition: ResPool.h:163
Iterable< byIdent_iterator > byIdent(ResKind kind_r, const C_Str &name_r) const
Definition: ResPool.h:234
filter_iterator< TFilter, const_iterator > filterEnd(const TFilter &filter_r) const
Definition: ResPool.h:123
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
hardLockQueries_iterator hardLockQueriesEnd() const
Definition: ResPool.cc:95
filter_iterator< TFilter, typename TContainer::const_iterator > make_filter_begin(TFilter f, const TContainer &c)
Convenience to create filter_iterator from container::begin().
Definition: Iterator.h:101
byIdent_iterator byIdentEnd(const ByIdent &ident_r) const
Definition: ResPool.h:197
pool::PoolTraits::const_iterator const_iterator
Definition: ResPool.h:68
const LocaleSet & getAvailableLocales() const
Get the set of available locales.
Definition: ResPool.cc:131
size_type hardLockQueriesSize() const
Definition: ResPool.cc:89
Pool internal filter skiping invalid/unwanted PoolItems.
Definition: PoolTraits.h:40
Resolvable kinds.
Definition: ResKind.h:32
RW_pointer< pool::PoolTraits::Impl > _pimpl
Access to implementation.
Definition: ResPool.h:421
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
Iterable< byIdent_iterator > byIdent(ResKind kind_r, IdString name_r) const
Definition: ResPool.h:231
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57
ResPool(pool::PoolTraits::Impl_Ptr impl_r)
Ctor.
Definition: ResPool.cc:44
void setRequestedLocales(const LocaleSet &locales_r)
Set the requested locales.
Definition: ResPool.cc:116
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:27
byIdent_iterator byIdentEnd(sat::Solvable slv_r) const
Derive name and kind from sat::Solvable.
Definition: ResPool.h:221
const pool::PoolTraits::ItemContainerT & store() const
Definition: ResPool.cc:105
byIdent_iterator byIdentBegin(const ByIdent &ident_r) const
Definition: ResPool.h:166
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:26
byIdent_iterator byIdentEnd(ResKind kind_r, IdString name_r) const
Definition: ResPool.h:203
Filter solvables according to their kind.
Definition: Filter.h:105
byIdent_iterator byIdentBegin(ResKind kind_r, const C_Str &name_r) const
Definition: ResPool.h:175
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:33