libzypp 17.31.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
17#include <zypp/base/PtrTypes.h>
18
19#include <zypp/ResPool.h>
20#include <zypp/ui/Selectable.h>
21#include <zypp/ui/SelFilters.h>
22
24namespace zypp
25{
26
28 //
29 // CLASS NAME : ResPoolProxy
30 //
35 {
36 friend std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
37 friend std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
38 typedef std::multimap<ResKind,ui::Selectable::Ptr> SelectablePool;
39
40 public:
42 struct Impl;
43
46
48
49 public:
50
59
62
63 public:
66 ui::Selectable::Ptr lookup( const pool::ByIdent & ident_r ) const;
67
69 { return lookup( pool::ByIdent( ident_r ) ); }
70
71 ui::Selectable::Ptr lookup( ResKind kind_r, const std::string & name_r ) const
72 { return lookup( pool::ByIdent( kind_r, name_r ) ); }
73
75 { return lookup( pool::ByIdent( solv_r ) ); }
76
77 ui::Selectable::Ptr lookup( const ResObject::constPtr & resolvable_r ) const
78 { return resolvable_r ? lookup( resolvable_r->satSolvable() ) : ui::Selectable::Ptr(); }
79
80 ui::Selectable::Ptr lookup( const PoolItem & pi_r ) const
81 { return lookup( pi_r.satSolvable() ); }
83
84 public:
87 bool empty() const;
88 size_type size() const;
89 const_iterator begin() const;
90 const_iterator end() const;
92
96 bool empty( const ResKind & kind_r ) const;
97
98 template<class TRes>
99 bool empty() const
100 { return empty( ResTraits<TRes>::kind ); }
101
103 size_type size( const ResKind & kind_r ) const;
104
105 template<class TRes>
107 { return size( ResTraits<TRes>::kind ); }
108
109 const_iterator byKindBegin( const ResKind & kind_r ) const;
110
111 template<class TRes>
114
115
116 const_iterator byKindEnd( const ResKind & kind_r ) const;
117
118 template<class TRes>
120 { return byKindEnd( ResTraits<TRes>::kind ); }
121
122
124 { return makeIterable( byKindBegin( kind_r ), byKindEnd( kind_r ) ); }
125
126 template<class TRes>
128 { return makeIterable( byKindBegin<TRes>(), byKindEnd<TRes>() ); }
129
131
132 public:
137
139
141
143 { return makeIterable( knownRepositoriesBegin(), knownRepositoriesEnd() ); }
145
146 public:
150 bool hasInstalledObj( const ResKind & kind_r ) const
151 {
152 return( make_begin<ui::selfilter::ByHasInstalledObj>( kind_r )
153 != make_end<ui::selfilter::ByHasInstalledObj>( kind_r ) );
154 }
155
156 template<class TRes>
157 bool hasInstalledObj() const
159
160 public:
171 void saveState() const;
172
173 void saveState( const ResKind & kind_r ) const;
174
175 template<class TRes>
176 void saveState() const
177 { return saveState( ResTraits<TRes>::kind ); }
178
179 void restoreState() const;
180
181 void restoreState( const ResKind & kind_r ) const;
182
183 template<class TRes>
184 void restoreState() const
186
187 bool diffState() const;
188
189 bool diffState( const ResKind & kind_r ) const;
190
191 template<class TRes>
192 bool diffState() const
193 { return diffState( ResTraits<TRes>::kind ); }
194
202 struct ScopedSaveState;
203
204 ScopedSaveState scopedSaveState() const;
205
206 ScopedSaveState scopedSaveState( const ResKind & kind_r ) const;
207
208 template<class TRes>
211
213
214 private:
215 template<class TFilter>
216 filter_iterator<TFilter,const_iterator>
217 make_begin( TFilter filter_r, const ResKind & kind_r ) const
218 {
219 return make_filter_iterator( filter_r,
220 byKindBegin(kind_r),
221 byKindEnd(kind_r) );
222 }
223 template<class TFilter>
224 filter_iterator<TFilter,const_iterator>
225 make_begin( const ResKind & kind_r ) const
226 {
227 return make_begin( TFilter(), kind_r );
228 }
229
230
231 template<class TFilter>
232 filter_iterator<TFilter,const_iterator>
233 make_end( TFilter filter_r, const ResKind & kind_r ) const
234 {
235 return make_filter_iterator( filter_r,
236 byKindEnd(kind_r),
237 byKindEnd(kind_r) );
238 }
239 template<class TFilter>
240 filter_iterator<TFilter,const_iterator>
241 make_end( const ResKind & kind_r ) const
242 {
243 return make_end( TFilter(), kind_r );
244 }
245
246 private:
247 friend class pool::PoolImpl;
249 ResPoolProxy( ResPool pool_r, const pool::PoolImpl & poolImpl_r );
252 };
254
256 std::ostream & operator<<( std::ostream & str, const ResPoolProxy & obj );
257
259 std::ostream & dumpOn( std::ostream & str, const ResPoolProxy & obj );
260
262
264 {
266
268 : _pimpl( new Impl( pool_r ) )
269 { _pimpl->saveState(); }
270
271 ScopedSaveState( const ResPoolProxy & pool_r, const ResKind & kind_r )
272 : _pimpl( new Impl( pool_r, kind_r ) )
273 { _pimpl->saveState(); }
274
276 { if ( _pimpl ) _pimpl->restoreState(); }
277
279 { _pimpl.reset(); }
280
281 private:
282 struct Impl
283 {
284 Impl( const ResPoolProxy & pool_r )
285 : _pool( pool_r )
286 {}
287 Impl( const ResPoolProxy & pool_r, const ResKind & kind_r )
288 : _pool( pool_r ), _kind( new ResKind( kind_r ) )
289 {}
291 { if ( _kind ) _pool.saveState( *_kind ); else _pool.saveState(); }
293 { if ( _kind ) _pool.restoreState( *_kind ); else _pool.restoreState(); }
295 scoped_ptr<ResKind> _kind;
296
297 };
298 std::unique_ptr<Impl> _pimpl;
299 };
300
302 { return ScopedSaveState( *this ); }
303
305 { return ScopedSaveState( *this, kind_r ); }
306
308} // namespace zypp
310#endif // ZYPP_RESPOOLPROXY_H
Access to the sat-pools string space.
Definition: IdString.h:43
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
MapKVIteratorTraits< SelectablePool >::Value_const_iterator const_iterator
Definition: ResPoolProxy.h:42
bool hasInstalledObj(const ResKind &kind_r) const
Test whether there is at least one ui::Selectable with an installed object.
Definition: ResPoolProxy.h:150
void saveState() const
Definition: ResPoolProxy.h:176
void saveState() const
bool hasInstalledObj() const
Definition: ResPoolProxy.h:157
Iterable< const_iterator > byKind(const ResKind &kind_r) const
Definition: ResPoolProxy.h:123
size_type size() const
const_iterator byKindEnd() const
Definition: ResPoolProxy.h:119
ui::Selectable::Ptr lookup(const PoolItem &pi_r) const
Definition: ResPoolProxy.h:80
ui::Selectable::Ptr lookup(ResKind kind_r, const std::string &name_r) const
Definition: ResPoolProxy.h:71
ui::Selectable::Ptr lookup(const sat::Solvable &solv_r) const
Definition: ResPoolProxy.h:74
ui::Selectable::Ptr lookup(IdString ident_r) const
Definition: ResPoolProxy.h:68
filter_iterator< TFilter, const_iterator > make_begin(const ResKind &kind_r) const
Definition: ResPoolProxy.h:225
size_type knownRepositoriesSize() const
Iterable< const_iterator > byKind() const
Definition: ResPoolProxy.h:127
friend std::ostream & operator<<(std::ostream &str, const ResPoolProxy &obj)
const_iterator begin() const
Iterable< repository_iterator > knownRepositories() const
Definition: ResPoolProxy.h:142
ResPool::repository_iterator repository_iterator
Definition: ResPoolProxy.h:47
filter_iterator< TFilter, const_iterator > make_end(const ResKind &kind_r) const
Definition: ResPoolProxy.h:241
const_iterator end() const
std::multimap< ResKind, ui::Selectable::Ptr > SelectablePool
Definition: ResPoolProxy.h:38
ui::Selectable::Ptr lookup(const ResObject::constPtr &resolvable_r) const
Definition: ResPoolProxy.h:77
bool empty() const
Definition: ResPoolProxy.h:99
ResPoolProxy()
Default ctor: no pool Nonempty proxies are provided by ResPool.
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: ResPoolProxy.h:251
bool empty() const
bool diffState() const
filter_iterator< TFilter, const_iterator > make_end(TFilter filter_r, const ResKind &kind_r) const
Definition: ResPoolProxy.h:233
filter_iterator< TFilter, const_iterator > make_begin(TFilter filter_r, const ResKind &kind_r) const
Definition: ResPoolProxy.h:217
void restoreState() const
ScopedSaveState && scopedSaveState() const
Definition: ResPoolProxy.h:209
repository_iterator knownRepositoriesBegin() const
SelectablePool::size_type size_type
Definition: ResPoolProxy.h:45
ui::Selectable::Ptr lookup(const pool::ByIdent &ident_r) const
friend std::ostream & dumpOn(std::ostream &str, const ResPoolProxy &obj)
void restoreState() const
Definition: ResPoolProxy.h:184
size_type size() const
Definition: ResPoolProxy.h:106
repository_iterator knownRepositoriesEnd() const
ScopedSaveState scopedSaveState() const
Definition: ResPoolProxy.h:301
const_iterator byKindBegin() const
Definition: ResPoolProxy.h:112
bool diffState() const
Definition: ResPoolProxy.h:192
Global ResObject pool.
Definition: ResPool.h:61
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:27
A Solvable object within the sat Pool.
Definition: Solvable.h:54
intrusive_ptr< Selectable > Ptr
Definition: Selectable.h:57
String related utilities and Regular expression matching.
SolvableIdType size_type
Definition: PoolMember.h:126
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:567
std::ostream & operator<<(std::ostream &str, const SerialNumber &obj)
Definition: SerialNumber.cc:52
transform_iterator< GetPairSecond< typename MapType::value_type >, typename MapType::const_iterator > Value_const_iterator
The value iterator type.
Definition: Iterator.h:223
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286
ResPoolProxy implementation.
Definition: ResPoolProxy.cc:92
Impl(const ResPoolProxy &pool_r, const ResKind &kind_r)
Definition: ResPoolProxy.h:287
Impl(const ResPoolProxy &pool_r)
Definition: ResPoolProxy.h:284
Exception safe scoped save/restore state.
Definition: ResPoolProxy.h:264
ScopedSaveState(const ResPoolProxy &pool_r)
Definition: ResPoolProxy.h:267
ScopedSaveState(const ResPoolProxy &pool_r, const ResKind &kind_r)
Definition: ResPoolProxy.h:271
std::unique_ptr< Impl > _pimpl
Definition: ResPoolProxy.h:298
ResTraits.
Definition: ResTraits.h:80
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57