libzypp 17.31.23
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
21#include <zypp/PoolItem.h>
22#include <zypp/Filter.h>
23
25namespace 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>
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
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
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
219 { return byIdentEnd( ByIdent(pi_r.satSolvable()) ); }
222 { return byIdentEnd( ByIdent(slv_r) ); }
225 { return byIdentEnd( ByIdent(ident_r) ); }
226
227
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>
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
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:
314 {
315 public:
318 typedef std::map<PoolItem,ResStatus::ValidateValue> ChangedPseudoInstalled;
321 private:
322 class Impl;
324 private:
325 friend class pool::PoolImpl;
327 EstablishedStates( shared_ptr<Impl> pimpl_r )
328 : _pimpl { pimpl_r }
329 {}
330 };
332
338 EstablishedStates establishedStates() const;
339
342
352 public:
357
359
361
365 Repository reposFind( const std::string & alias_r ) const;
366
368 { return makeIterable( knownRepositoriesBegin(), knownRepositoriesEnd() ); }
370
371 public:
400 void setRequestedLocales( const LocaleSet & locales_r );
401
405 bool addRequestedLocale( const Locale & locale_r );
406
410 bool eraseRequestedLocale( const Locale & locale_r );
411
415 const LocaleSet & getRequestedLocales() const;
416
418 bool isRequestedLocale( const Locale & locale_r ) const;
419
424 const LocaleSet & getAvailableLocales() const;
425
427 bool isAvailableLocale( const Locale & locale_r ) const;
429
430 public:
440
441 bool hardLockQueriesEmpty() const;
445
447 { return makeIterable( hardLockQueriesBegin(), hardLockQueriesEnd() ); }
448
453 void setHardLockQueries( const HardLockQueries & newLocks_r );
454
458 void getHardLockQueries( HardLockQueries & activeLocks_r );
460
461 private:
463 const pool::PoolTraits::Id2ItemT & id2item() const;
464
465 private:
470 };
472
474 std::ostream & operator<<( std::ostream & str, const ResPool & obj );
475
477} // namespace zypp
479
480#include <zypp/ResPoolProxy.h>
481
482#endif // ZYPP_RESPOOL_H
Provides API related macros.
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string.
Definition: String.h:91
Access to the sat-pools string space.
Definition: IdString.h:43
'Language[_Country]' codes.
Definition: Locale.h:50
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:51
Resolvable kinds.
Definition: ResKind.h:33
TraitsType::constPtrType constPtr
Definition: ResObject.h:43
ResPool::instance().proxy();.
Definition: ResPoolProxy.h:35
Store initial establish status of pseudo installed items.
Definition: PoolImpl.h:117
A copy of the Pools initial ValidateValues of pseudo installed items.
Definition: ResPool.h:314
RW_pointer< Impl > _pimpl
Definition: ResPool.h:323
ChangedPseudoInstalled changedPseudoInstalled() const
Return all pseudo installed items whose current state differs from the established one.
Definition: PoolImpl.cc:26
EstablishedStates(shared_ptr< Impl > pimpl_r)
Factory: ResPool::establishedStates.
Definition: ResPool.h:327
std::map< PoolItem, ResStatus::ValidateValue > ChangedPseudoInstalled
Map holding pseudo installed items where current and established status differ.
Definition: ResPool.h:318
Global ResObject pool.
Definition: ResPool.h:61
hardLockQueries_iterator hardLockQueriesBegin() const
Definition: ResPool.cc:97
bool isAvailableLocale(const Locale &locale_r) const
Whether this Locale is in the set of available locales.
Definition: ResPool.cc:139
pool::PoolTraits::byIdent_iterator byIdent_iterator
Definition: ResPool.h:164
const pool::PoolTraits::ItemContainerT & store() const
Definition: ResPool.cc:110
bool hardLockQueriesEmpty() const
Definition: ResPool.cc:91
byName_iterator byNameEnd(const std::string &name_r) const
Definition: ResPool.h:292
pool::PoolTraits::const_iterator const_iterator
Definition: ResPool.h:68
size_type knownRepositoriesSize() const
Definition: ResPool.cc:79
filter_iterator< TFilter, const_iterator > filterEnd(const TFilter &filter_r) const
Definition: ResPool.h:123
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
Definition: ResPool.cc:73
Iterable< byIdent_iterator > byIdent(IdString name_r) const
Definition: ResPool.h:238
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:37
byIdent_iterator byIdentEnd(const PoolItem &pi_r) const
Derive name and kind from PoolItem.
Definition: ResPool.h:218
filter_iterator< filter::ByStatus, const_iterator > byStatusEnd(const filter::ByStatus &filter_r) const
Definition: ResPool.h:153
bool empty() const
Definition: ResPool.cc:67
PoolItem value_type
PoolItem
Definition: ResPool.h:66
EstablishedStates::ChangedPseudoInstalled ChangedPseudoInstalled
Map holding pseudo installed items where current and established status differ.
Definition: ResPool.h:341
repository_iterator knownRepositoriesBegin() const
Definition: ResPool.cc:82
byKind_iterator byKindEnd() const
Definition: ResPool.h:272
bool eraseRequestedLocale(const Locale &locale_r)
Erase one Locale from the set of requested locales.
Definition: ResPool.cc:127
bool addRequestedLocale(const Locale &locale_r)
Add one Locale to the set of requested locales.
Definition: ResPool.cc:124
byIdent_iterator byIdentEnd(ResKind kind_r, IdString name_r) const
Definition: ResPool.h:203
Repository reposFind(const std::string &alias_r) const
Find a Repository named alias_r.
Definition: ResPool.cc:88
byIdent_iterator byIdentBegin(IdString ident_r) const
Takes a sat::Solvable::ident string.
Definition: ResPool.h:193
filter::ByKind ByKind
Definition: ResPool.h:258
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
Definition: ResPool.cc:103
Iterable< byKind_iterator > byKind() const
Definition: ResPool.h:279
Iterable< filter_iterator< TFilter, const_iterator > > filter(const TFilter &filter_r) const
Definition: ResPool.h:127
byIdent_iterator byIdentBegin(IdString name_r) const
Definition: ResPool.h:179
Iterable< byIdent_iterator > byIdent(ResKind kind_r, IdString name_r) const
Definition: ResPool.h:231
Resolver & resolver() const
The Resolver.
Definition: ResPool.cc:61
ResPoolProxy proxy() const
preliminary
Definition: ResPool.cc:58
pool::PoolTraits::size_type size_type
Definition: ResPool.h:67
pool::ByIdent ByIdent
Definition: ResPool.h:163
const LocaleSet & getAvailableLocales() const
Get the set of available locales.
Definition: ResPool.cc:136
byIdent_iterator byIdentBegin(const PoolItem &pi_r) const
Derive name and kind from PoolItem.
Definition: ResPool.h:187
const_iterator end() const
Definition: ResPool.h:100
pool::PoolTraits::HardLockQueries HardLockQueries
Definition: ResPool.h:438
filter_iterator< TFilter, const_iterator > filterBegin(const TFilter &filter_r) const
Definition: ResPool.h:119
pool::PoolTraits::repository_iterator repository_iterator
Definition: ResPool.h:69
Iterable< hardLockQueries_iterator > hardLockQueries() const
Definition: ResPool.h:446
byIdent_iterator byIdentEnd(IdString ident_r) const
Takes a sat::Solvable::ident string.
Definition: ResPool.h:224
const LocaleSet & getRequestedLocales() const
Return the requested locales.
Definition: ResPool.cc:130
filter_iterator< ByName, const_iterator > byName_iterator
Definition: ResPool.h:287
ChangedPseudoInstalled changedPseudoInstalled() const
Return all pseudo installed items whose current state differs from their initial one.
Definition: ResPool.h:349
Iterable< byIdent_iterator > byIdent(const C_Str &name_r) const
Definition: ResPool.h:242
byKind_iterator byKindEnd(const ResKind &kind_r) const
Definition: ResPool.h:268
Iterable< byName_iterator > byName(const std::string &name_r) const
Definition: ResPool.h:295
repository_iterator knownRepositoriesEnd() const
Definition: ResPool.cc:85
byKind_iterator byKindBegin() const
Definition: ResPool.h:265
byIdent_iterator byIdentBegin(const C_Str &name_r) const
Definition: ResPool.h:183
Iterable< byIdent_iterator > byIdent(ResKind kind_r, const C_Str &name_r) const
Definition: ResPool.h:234
void setRequestedLocales(const LocaleSet &locales_r)
Set the requested locales.
Definition: ResPool.cc:121
filter_iterator< ByKind, const_iterator > byKind_iterator
Definition: ResPool.h:259
zypp::resfilter::ByName ByName
Definition: ResPool.h:286
size_type hardLockQueriesSize() const
Definition: ResPool.cc:94
byName_iterator byNameBegin(const std::string &name_r) const
Definition: ResPool.h:289
const pool::PoolTraits::Id2ItemT & id2item() const
Definition: ResPool.cc:113
filter_iterator< filter::ByStatus, const_iterator > byStatusBegin(const filter::ByStatus &filter_r) const
Definition: ResPool.h:150
Iterable< byIdent_iterator > byIdent(IdString ident_r) const
Definition: ResPool.h:251
EstablishedStates establishedStates() const
Factory for EstablishedStates.
Definition: ResPool.cc:76
RW_pointer< pool::PoolTraits::Impl > _pimpl
Access to implementation.
Definition: ResPool.h:469
pool::PoolTraits::hardLockQueries_iterator hardLockQueries_iterator
Definition: ResPool.h:439
const SerialNumber & serial() const
The pools serial number.
Definition: ResPool.cc:64
byIdent_iterator byIdentEnd(sat::Solvable slv_r) const
Derive name and kind from sat::Solvable.
Definition: ResPool.h:221
Iterable< byIdent_iterator > byIdent(sat::Solvable slv_r) const
Definition: ResPool.h:248
byIdent_iterator byIdentBegin(sat::Solvable slv_r) const
Derive name and kind from sat::Solvable.
Definition: ResPool.h:190
byKind_iterator byKindBegin(const ResKind &kind_r) const
Definition: ResPool.h:261
const_iterator begin() const
Definition: ResPool.h:97
Iterable< byKind_iterator > byKind(const ResKind &kind_r) const
Definition: ResPool.h:275
void getHardLockQueries(HardLockQueries &activeLocks_r)
Suggest a new set of queries based on the current selection.
Definition: ResPool.cc:106
Iterable< byIdent_iterator > byIdent(const ByIdent &ident_r) const
Definition: ResPool.h:228
friend std::ostream & operator<<(std::ostream &str, const ResPool &obj)
Definition: ResPool.cc:147
byIdent_iterator byIdentEnd(IdString name_r) const
Definition: ResPool.h:210
byIdent_iterator byIdentBegin(ResKind kind_r, IdString name_r) const
Definition: ResPool.h:172
byIdent_iterator byIdentEnd(const C_Str &name_r) const
Definition: ResPool.h:214
PoolItem find(const ResObject::constPtr &resolvable_r) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: ResPool.h:112
size_type size() const
Definition: ResPool.cc:70
byIdent_iterator byIdentBegin(ResKind kind_r, const C_Str &name_r) const
Definition: ResPool.h:175
Iterable< repository_iterator > knownRepositories() const
Definition: ResPool.h:367
byIdent_iterator byIdentBegin(const ByIdent &ident_r) const
Definition: ResPool.h:166
byIdent_iterator byIdentEnd(const ByIdent &ident_r) const
Definition: ResPool.h:197
hardLockQueries_iterator hardLockQueriesEnd() const
Definition: ResPool.cc:100
bool isRequestedLocale(const Locale &locale_r) const
Whether this Locale is in the set of requested locales.
Definition: ResPool.cc:133
byIdent_iterator byIdentEnd(ResKind kind_r, const C_Str &name_r) const
Definition: ResPool.h:206
Iterable< byIdent_iterator > byIdent(const PoolItem &pi_r) const
Definition: ResPool.h:245
Iterable< filter_iterator< filter::ByStatus, const_iterator > > byStatus(const filter::ByStatus &filter_r) const
Definition: ResPool.h:156
Dependency resolver interface.
Definition: Resolver.h:45
Simple serial number provider.
Definition: SerialNumber.h:45
Filter solvables according to their kind.
Definition: Filter.h:106
Filter solvables according to their status.
Definition: Filter.h:142
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:27
sat::detail::IdType get() const
Definition: ByIdent.h:88
A Solvable object within the sat Pool.
Definition: Solvable.h:54
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
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
std::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
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
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286
ResTraits.
Definition: ResTraits.h:80
Pool internal filter skiping invalid/unwanted PoolItems.
Definition: PoolTraits.h:41
std::_Select2nd
Definition: PoolTraits.h:50
filter_iterator< ByPoolItem, ItemContainerT::const_iterator > const_iterator
Definition: PoolTraits.h:74
shared_ptr< PoolImpl > Impl_Ptr
Definition: PoolTraits.h:92
std::vector< PoolItem > ItemContainerT
pure items
Definition: PoolTraits.h:71
transform_iterator< Id2ItemValueSelector, Id2ItemT::const_iterator > byIdent_iterator
Definition: PoolTraits.h:82
std::unordered_multimap< sat::detail::IdType, PoolItem > Id2ItemT
ident index
Definition: PoolTraits.h:79
std::list< PoolQuery > HardLockQueries
hard locks from etc/zypp/locks
Definition: PoolTraits.h:88
HardLockQueries::const_iterator hardLockQueries_iterator
Definition: PoolTraits.h:89
ItemContainerT::size_type size_type
Definition: PoolTraits.h:75
Select ResObject by name.
Definition: ResFilters.h:150
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57