libzypp 17.35.11
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/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 //
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
46 using size_type = SelectablePool::size_type;
47
49
50 public:
51
60
63
64 public:
67 ui::Selectable::Ptr lookup( const pool::ByIdent & ident_r ) const;
68
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
76 { return lookup( pool::ByIdent( solv_r ) ); }
77
79 { return resolvable_r ? lookup( resolvable_r->satSolvable() ) : ui::Selectable::Ptr(); }
80
82 { return lookup( pi_r.satSolvable() ); }
84
85 public:
88 bool empty() const;
89 size_type size() const;
90 const_iterator begin() const;
91 const_iterator end() const;
93
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>
108 { return size( ResTraits<TRes>::kind ); }
109
110 const_iterator byKindBegin( const ResKind & kind_r ) const;
111
112 template<class TRes>
114 { return byKindBegin( ResTraits<TRes>::kind ); }
115
116
117 const_iterator byKindEnd( const ResKind & kind_r ) const;
118
119 template<class TRes>
121 { return byKindEnd( ResTraits<TRes>::kind ); }
122
123
125 { return makeIterable( byKindBegin( kind_r ), byKindEnd( kind_r ) ); }
126
127 template<class TRes>
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
144 { return makeIterable( knownRepositoriesBegin(), knownRepositoriesEnd() ); }
146
147 public:
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>
211 { return scopedSaveState( ResTraits<TRes>::kind ); }
212
214
215 private:
216 template<class TFilter>
219 {
220 return make_filter_iterator( filter_r,
221 byKindBegin(kind_r),
222 byKindEnd(kind_r) );
223 }
224 template<class TFilter>
226 make_begin( const ResKind & kind_r ) const
227 {
228 return make_begin( TFilter(), kind_r );
229 }
230
231
232 template<class TFilter>
235 {
236 return make_filter_iterator( filter_r,
237 byKindEnd(kind_r),
238 byKindEnd(kind_r) );
239 }
240 template<class TFilter>
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;
253 };
255
257 std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
258
260 std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
261
263
265 {
267
269 : _pimpl( new Impl( pool_r ) )
270 { _pimpl->saveState(); }
271
273 : _pimpl( new Impl( pool_r, kind_r ) )
274 { _pimpl->saveState(); }
275
277 { if ( _pimpl ) _pimpl->restoreState(); }
278
280 { _pimpl.reset(); }
281
282 private:
283 struct Impl
284 {
286 : _pool( pool_r )
287 {}
289 : _pool( pool_r ), _kind( new ResKind( kind_r ) )
290 {}
292 { if ( _kind ) _pool.saveState( *_kind ); else _pool.saveState(); }
294 { if ( _kind ) _pool.restoreState( *_kind ); else _pool.restoreState(); }
297
298 };
299 std::unique_ptr<Impl> _pimpl;
300 };
301
304
307
309} // namespace zypp
311#endif // ZYPP_RESPOOLPROXY_H
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition AutoDispose.h:95
void reset()
Reset to default Ctor values.
Access to the sat-pools string space.
Definition IdString.h:44
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();.
bool hasInstalledObj(const ResKind &kind_r) const
Test whether there is at least one ui::Selectable with an installed object.
void saveState() const
void saveState() const
bool hasInstalledObj() const
Iterable< const_iterator > byKind(const ResKind &kind_r) const
const_iterator byKindEnd() const
ui::Selectable::Ptr lookup(const PoolItem &pi_r) const
ui::Selectable::Ptr lookup(ResKind kind_r, const std::string &name_r) const
ui::Selectable::Ptr lookup(const sat::Solvable &solv_r) const
ui::Selectable::Ptr lookup(IdString ident_r) const
filter_iterator< TFilter, const_iterator > make_begin(const ResKind &kind_r) const
Iterable< const_iterator > byKind() const
Iterable< repository_iterator > knownRepositories() const
filter_iterator< TFilter, const_iterator > make_end(const ResKind &kind_r) const
std::multimap< ResKind, ui::Selectable::Ptr > SelectablePool
ui::Selectable::Ptr lookup(const ResObject::constPtr &resolvable_r) const
bool empty() const
RW_pointer< Impl > _pimpl
Pointer to implementation.
MapKVIteratorTraits< SelectablePool >::Value_const_iterator const_iterator
filter_iterator< TFilter, const_iterator > make_end(TFilter filter_r, const ResKind &kind_r) const
filter_iterator< TFilter, const_iterator > make_begin(TFilter filter_r, const ResKind &kind_r) const
void restoreState() const
ScopedSaveState && scopedSaveState() const
SelectablePool::size_type size_type
void restoreState() const
size_type size() const
ScopedSaveState scopedSaveState() const
const_iterator byKindBegin() const
bool diffState() const
Global ResObject pool.
Definition ResPool.h:62
pool::PoolTraits::repository_iterator repository_iterator
Definition ResPool.h:70
Main filter selecting PoolItems by name and kind.
Definition ByIdent.h:29
A Solvable object within the sat Pool.
Definition Solvable.h:54
intrusive_ptr< Selectable > Ptr
Definition Selectable.h:58
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
Definition Arch.h:247
transform_iterator< GetPairSecond< typename MapType::value_type >, typename MapType::const_iterator > Value_const_iterator
The value iterator type.
Definition Iterator.h:221
ResPoolProxy implementation.
Impl(const ResPoolProxy &pool_r, const ResKind &kind_r)
Exception safe scoped save/restore state.
ScopedSaveState(const ResPoolProxy &pool_r)
ScopedSaveState(const ResPoolProxy &pool_r, const ResKind &kind_r)
std::unique_ptr< Impl > _pimpl
ResTraits.
Definition ResTraits.h:80