libzypp: zypp/ResPoolProxy.h Source File

libzypp 17.38.6

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#include <utility>
17
18#include <zypp-core/base/PtrTypes.h>
19
20#include <zypp/ResPool.h>
21#include <zypp/ui/Selectable.h>
22#include <zypp/ui/SelFilters.h>
23
25namespace zypp
26{
27
29 //
30 // CLASS NAME : ResPoolProxy
31 //
35 class ZYPP_API ResPoolProxy
36 {
37 friend std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
38 friend std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
39 using SelectablePool = std::multimap<ResKind, ui::Selectable::Ptr>;
40
41 public:
43 struct Impl;
44
45 using const_iterator = MapKVIteratorTraits<SelectablePool>::Value_const_iterator;
46 using size_type = SelectablePool::size_type;
47
48 using repository_iterator = ResPool::repository_iterator;
49
50 public:
51
59 ResPoolProxy();
60
62 ~ResPoolProxy();
63
64 public:
67 ui::Selectable::Ptr lookup( const pool::ByIdent & ident_r ) const;
68
69 ui::Selectable::Ptr lookup( IdString ident_r ) const
70 { return lookup( pool::ByIdent( ident_r ) ); }
71
72 ui::Selectable::Ptr lookup( ResKind kind_r, const std::string & name_r ) const
73 { return lookup( pool::ByIdent( std::move(kind_r), name_r ) ); }
74
75 ui::Selectable::Ptr lookup( const sat::Solvable & solv_r ) const
76 { return lookup( pool::ByIdent( solv_r ) ); }
77
78 ui::Selectable::Ptr lookup( const ResObject::constPtr & resolvable_r ) const
79 { return resolvable_r ? lookup( resolvable_r->satSolvable() ) : ui::Selectable::Ptr(); }
80
81 ui::Selectable::Ptr lookup( const PoolItem & pi_r ) const
82 { return lookup( pi_r.satSolvable() ); }
83
84
85 public:
88 bool empty() const;
89 size_type size() const;
90 const_iterator begin() const;
91 const_iterator end() const;
93
96
97 bool empty( const ResKind & kind_r ) const;
98
99 template<class TRes>
100 bool empty() const
101 { return empty( ResTraits<TRes>::kind ); }
102
104 size_type size( const ResKind & kind_r ) const;
105
106 template<class TRes>
107 size_type size() const
108 { return size( ResTraits<TRes>::kind ); }
109
110 const_iterator byKindBegin( const ResKind & kind_r ) const;
111
112 template<class TRes>
113 const_iterator byKindBegin() const
114 { return byKindBegin( ResTraits<TRes>::kind ); }
115
116
117 const_iterator byKindEnd( const ResKind & kind_r ) const;
118
119 template<class TRes>
120 const_iterator byKindEnd() const
121 { return byKindEnd( ResTraits<TRes>::kind ); }
122
123
124 Iterable<const_iterator> byKind( const ResKind & kind_r ) const
125 { return makeIterable( byKindBegin( kind_r ), byKindEnd( kind_r ) ); }
126
127 template<class TRes>
128 Iterable<const_iterator> byKind() const
129 { return makeIterable( byKindBegin<TRes>(), byKindEnd<TRes>() ); }
130
132
133 public:
137 size_type knownRepositoriesSize() const;
138
139 repository_iterator knownRepositoriesBegin() const;
140
141 repository_iterator knownRepositoriesEnd() const;
142
143 Iterable<repository_iterator> knownRepositories() const
144 { return makeIterable( knownRepositoriesBegin(), knownRepositoriesEnd() ); }
145
146
147 public:
151 bool hasInstalledObj( const ResKind & kind_r ) const
152 {
153 return( make_begin<ui::selfilter::ByHasInstalledObj>( kind_r )
154 != make_end<ui::selfilter::ByHasInstalledObj>( kind_r ) );
155 }
156
157 template<class TRes>
158 bool hasInstalledObj() const
159 { return hasInstalledObj( ResTraits<TRes>::kind ); }
160
161 public:
172 void saveState() const;
173
174 void saveState( const ResKind & kind_r ) const;
175
176 template<class TRes>
177 void saveState() const
178 { return saveState( ResTraits<TRes>::kind ); }
179
180 void restoreState() const;
181
182 void restoreState( const ResKind & kind_r ) const;
183
184 template<class TRes>
185 void restoreState() const
186 { return restoreState( ResTraits<TRes>::kind ); }
187
188 bool diffState() const;
189
190 bool diffState( const ResKind & kind_r ) const;
191
192 template<class TRes>
193 bool diffState() const
194 { return diffState( ResTraits<TRes>::kind ); }
195
203 struct ScopedSaveState;
204
205 ScopedSaveState scopedSaveState() const;
206
207 ScopedSaveState scopedSaveState( const ResKind & kind_r ) const;
208
209 template<class TRes>
210 ScopedSaveState && scopedSaveState() const
211 { return scopedSaveState( ResTraits<TRes>::kind ); }
212
214
215 private:
216 template<class TFilter>
217 filter_iterator<TFilter,const_iterator>
218 make_begin( TFilter filter_r, const ResKind & kind_r ) const
219 {
220 return make_filter_iterator( filter_r,
221 byKindBegin(kind_r),
222 byKindEnd(kind_r) );
223 }
224 template<class TFilter>
225 filter_iterator<TFilter,const_iterator>
226 make_begin( const ResKind & kind_r ) const
227 {
228 return make_begin( TFilter(), kind_r );
229 }
230
231
232 template<class TFilter>
233 filter_iterator<TFilter,const_iterator>
234 make_end( TFilter filter_r, const ResKind & kind_r ) const
235 {
236 return make_filter_iterator( filter_r,
237 byKindEnd(kind_r),
238 byKindEnd(kind_r) );
239 }
240 template<class TFilter>
241 filter_iterator<TFilter,const_iterator>
242 make_end( const ResKind & kind_r ) const
243 {
244 return make_end( TFilter(), kind_r );
245 }
246
247 private:
248 friend class pool::PoolImpl;
250 ResPoolProxy( ResPool pool_r, const pool::PoolImpl & poolImpl_r );
252 RW_pointer<Impl> _pimpl;
253 };
254
255
257 std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
258
260 std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
261
263
264 struct ResPoolProxy::ScopedSaveState
265 {
266 NON_COPYABLE_BUT_MOVE( ScopedSaveState );
267
268 ScopedSaveState( const ResPoolProxy & pool_r )
269 : _pimpl( new Impl( pool_r ) )
270 { _pimpl->saveState(); }
271
272 ScopedSaveState( const ResPoolProxy & pool_r, const ResKind & kind_r )
273 : _pimpl( new Impl( pool_r, kind_r ) )
274 { _pimpl->saveState(); }
275
276 ~ScopedSaveState()
277 { if ( _pimpl ) _pimpl->restoreState(); }
278
279 void acceptState()
280 { _pimpl.reset(); }
281
282 private:
283 struct Impl
284 {
285 Impl( const ResPoolProxy & pool_r )
286 : _pool( pool_r )
287 {}
288 Impl( const ResPoolProxy & pool_r, const ResKind & kind_r )
289 : _pool( pool_r ), _kind( new ResKind( kind_r ) )
290 {}
291 void saveState()
292 { if ( _kind ) _pool.saveState( *_kind ); else _pool.saveState(); }
293 void restoreState()
294 { if ( _kind ) _pool.restoreState( *_kind ); else _pool.restoreState(); }
295 ResPoolProxy _pool;
296 scoped_ptr<ResKind> _kind;
297
298 };
299 std::unique_ptr<Impl> _pimpl;
300 };
301
302 inline ResPoolProxy::ScopedSaveState ResPoolProxy::scopedSaveState() const
303 { return ScopedSaveState( *this ); }
304
305 inline ResPoolProxy::ScopedSaveState ResPoolProxy::scopedSaveState( const ResKind & kind_r ) const
306 { return ScopedSaveState( *this, kind_r ); }
307
309} // namespace zypp
311#endif // ZYPP_RESPOOLPROXY_H
PtrTypes.h
ResPool.h
SelFilters.h
Selectable.h
filter_iterator
An iterator over the subset of elements of some sequence which satisfy a given predicate.
scoped_ptr
zypp::IdString
Access to the sat-pools string space.
Definition IdString.h:55
zypp::Iterable
Definition Iterable.h:37
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
zypp::ResKind
Resolvable kinds.
Definition ResKind.h:33
zypp::ResObject::constPtr
TraitsType::constPtrType constPtr
Definition ResObject.h:43
zypp::ResPoolProxy
ResPool::instance().proxy();.
Definition ResPoolProxy.h:36
zypp::ResPoolProxy::hasInstalledObj
bool hasInstalledObj(const ResKind &kind_r) const
Test whether there is at least one ui::Selectable with an installed object.
Definition ResPoolProxy.h:151
zypp::ResPoolProxy::repository_iterator
ResPool::repository_iterator repository_iterator
Definition ResPoolProxy.h:48
zypp::ResPoolProxy::saveState
void saveState() const
Definition ResPoolProxy.h:177
zypp::ResPoolProxy::saveState
void saveState() const
Definition ResPoolProxy.cc:312
zypp::ResPoolProxy::hasInstalledObj
bool hasInstalledObj() const
Definition ResPoolProxy.h:158
zypp::ResPoolProxy::byKind
Iterable< const_iterator > byKind(const ResKind &kind_r) const
Definition ResPoolProxy.h:124
zypp::ResPoolProxy::size
size_type size() const
Definition ResPoolProxy.cc:282
zypp::ResPoolProxy::byKindEnd
const_iterator byKindEnd() const
Definition ResPoolProxy.h:120
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(const PoolItem &pi_r) const
Definition ResPoolProxy.h:81
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(ResKind kind_r, const std::string &name_r) const
Definition ResPoolProxy.h:72
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(const sat::Solvable &solv_r) const
Definition ResPoolProxy.h:75
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(IdString ident_r) const
Definition ResPoolProxy.h:69
zypp::ResPoolProxy::make_begin
filter_iterator< TFilter, const_iterator > make_begin(const ResKind &kind_r) const
Definition ResPoolProxy.h:226
zypp::ResPoolProxy::byKind
Iterable< const_iterator > byKind() const
Definition ResPoolProxy.h:128
zypp::ResPoolProxy::knownRepositories
Iterable< repository_iterator > knownRepositories() const
Definition ResPoolProxy.h:143
zypp::ResPoolProxy::byKindBegin
const_iterator byKindBegin(const ResKind &kind_r) const
Definition ResPoolProxy.cc:297
zypp::ResPoolProxy::make_end
filter_iterator< TFilter, const_iterator > make_end(const ResKind &kind_r) const
Definition ResPoolProxy.h:242
zypp::ResPoolProxy::SelectablePool
std::multimap< ResKind, ui::Selectable::Ptr > SelectablePool
Definition ResPoolProxy.h:39
zypp::ResPoolProxy::byKindEnd
const_iterator byKindEnd(const ResKind &kind_r) const
Definition ResPoolProxy.cc:300
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(const ResObject::constPtr &resolvable_r) const
Definition ResPoolProxy.h:78
zypp::ResPoolProxy::empty
bool empty() const
Definition ResPoolProxy.h:100
zypp::ResPoolProxy::ResPoolProxy
ResPoolProxy()
Default ctor: no pool Nonempty proxies are provided by ResPool.
Definition ResPoolProxy.cc:249
zypp::ResPoolProxy::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition ResPoolProxy.h:252
zypp::ResPoolProxy::empty
bool empty() const
Definition ResPoolProxy.cc:279
zypp::ResPoolProxy::diffState
bool diffState() const
Definition ResPoolProxy.cc:324
zypp::ResPoolProxy::const_iterator
MapKVIteratorTraits< SelectablePool >::Value_const_iterator const_iterator
Definition ResPoolProxy.h:45
zypp::ResPoolProxy::make_end
filter_iterator< TFilter, const_iterator > make_end(TFilter filter_r, const ResKind &kind_r) const
Definition ResPoolProxy.h:234
zypp::ResPoolProxy::make_begin
filter_iterator< TFilter, const_iterator > make_begin(TFilter filter_r, const ResKind &kind_r) const
Definition ResPoolProxy.h:218
zypp::ResPoolProxy::restoreState
void restoreState() const
Definition ResPoolProxy.cc:318
zypp::ResPoolProxy::scopedSaveState
ScopedSaveState && scopedSaveState() const
Definition ResPoolProxy.h:210
zypp::ResPoolProxy::size_type
SelectablePool::size_type size_type
Definition ResPoolProxy.h:46
zypp::ResPoolProxy::knownRepositoriesBegin
repository_iterator knownRepositoriesBegin() const
Definition ResPoolProxy.cc:306
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(const pool::ByIdent &ident_r) const
Definition ResPoolProxy.cc:276
zypp::ResPoolProxy::restoreState
void restoreState() const
Definition ResPoolProxy.h:185
zypp::ResPoolProxy::size
size_type size() const
Definition ResPoolProxy.h:107
zypp::ResPoolProxy::knownRepositoriesEnd
repository_iterator knownRepositoriesEnd() const
Definition ResPoolProxy.cc:309
zypp::ResPoolProxy::scopedSaveState
ScopedSaveState scopedSaveState() const
Definition ResPoolProxy.h:302
zypp::ResPoolProxy::byKindBegin
const_iterator byKindBegin() const
Definition ResPoolProxy.h:113
zypp::ResPoolProxy::diffState
bool diffState() const
Definition ResPoolProxy.h:193
zypp::ResPool
Global ResObject pool.
Definition ResPool.h:62
zypp::ResPool::repository_iterator
pool::PoolTraits::repository_iterator repository_iterator
Definition ResPool.h:70
zypp::pool::ByIdent
Main filter selecting PoolItems by name and kind.
Definition ByIdent.h:29
zypp::pool::PoolImpl
Definition PoolImpl.h:169
zypp::sat::Solvable
A Solvable object within the sat Pool.
Definition Solvable.h:54
zypp::ui::Selectable::Ptr
intrusive_ptr< Selectable > Ptr
Definition Selectable.h:58
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::makeIterable
Iterable< TIterator > makeIterable(TIterator &&begin_r, TIterator &&end_r)
relates: Iterable convenient construction.
Definition Iterable.h:88
zypp::ZYPP_API
const Arch Arch_empty ZYPP_API
relates: Arch This is an empty Arch represented by an empty string.
Definition Arch.h:173
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
relates: Capability Detailed stream output
Definition Capability.cc:589
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Capabilities &obj)
relates: Capabilities Stream output
Definition Capabilities.cc:65
zypp::MapKVIteratorTraits::Value_const_iterator
transform_iterator< GetPairSecond< typename MapType::value_type >, typename MapType::const_iterator > Value_const_iterator
The value iterator type.
Definition Iterator.h:221
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition PtrTypes.h:293
zypp::ResPoolProxy::Impl
ResPoolProxy implementation.
Definition ResPoolProxy.cc:93
zypp::ResPoolProxy::ScopedSaveState::Impl
Definition ResPoolProxy.h:284
zypp::ResPoolProxy::ScopedSaveState::Impl::_pool
ResPoolProxy _pool
Definition ResPoolProxy.h:295
zypp::ResPoolProxy::ScopedSaveState::Impl::_kind
scoped_ptr< ResKind > _kind
Definition ResPoolProxy.h:296
zypp::ResPoolProxy::ScopedSaveState::Impl::saveState
void saveState()
Definition ResPoolProxy.h:291
zypp::ResPoolProxy::ScopedSaveState::Impl::restoreState
void restoreState()
Definition ResPoolProxy.h:293
zypp::ResPoolProxy::ScopedSaveState::Impl::Impl
Impl(const ResPoolProxy &pool_r, const ResKind &kind_r)
Definition ResPoolProxy.h:288
zypp::ResPoolProxy::ScopedSaveState::Impl::Impl
Impl(const ResPoolProxy &pool_r)
Definition ResPoolProxy.h:285
zypp::ResPoolProxy::ScopedSaveState
Exception safe scoped save/restore state.
Definition ResPoolProxy.h:265
zypp::ResPoolProxy::ScopedSaveState::NON_COPYABLE_BUT_MOVE
NON_COPYABLE_BUT_MOVE(ScopedSaveState)
zypp::ResPoolProxy::ScopedSaveState::ScopedSaveState
ScopedSaveState(const ResPoolProxy &pool_r)
Definition ResPoolProxy.h:268
zypp::ResPoolProxy::ScopedSaveState::~ScopedSaveState
~ScopedSaveState()
Definition ResPoolProxy.h:276
zypp::ResPoolProxy::ScopedSaveState::acceptState
void acceptState()
Definition ResPoolProxy.h:279
zypp::ResPoolProxy::ScopedSaveState::ScopedSaveState
ScopedSaveState(const ResPoolProxy &pool_r, const ResKind &kind_r)
Definition ResPoolProxy.h:272
zypp::ResPoolProxy::ScopedSaveState::_pimpl
std::unique_ptr< Impl > _pimpl
Definition ResPoolProxy.h:299
zypp::ResTraits
ResTraits.
Definition ResTraits.h:80
zypp::sat::SolvableType::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition SolvableType.h:57