libzypp: zypp/ResPoolProxy.h Source File

libzypp 17.25.10

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
24 namespace zypp
25 {
26
28 //
29 // CLASS NAME : ResPoolProxy
30 //
34 class ResPoolProxy
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
44 typedef MapKVIteratorTraits<SelectablePool>::Value_const_iterator const_iterator;
45 typedef SelectablePool::size_type size_type;
46
47 typedef ResPool::repository_iterator repository_iterator;
48
49 public:
50
58 ResPoolProxy();
59
61 ~ResPoolProxy();
62
63 public:
66 ui::Selectable::Ptr lookup( const pool::ByIdent & ident_r ) const;
67
68 ui::Selectable::Ptr lookup( IdString ident_r ) const
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
74 ui::Selectable::Ptr lookup( const sat::Solvable & solv_r ) const
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>
106 size_type size() const
107 { return size( ResTraits<TRes>::kind ); }
108
109 const_iterator byKindBegin( const ResKind & kind_r ) const;
110
111 template<class TRes>
112 const_iterator byKindBegin() const
113 { return byKindBegin( ResTraits<TRes>::kind ); }
114
115
116 const_iterator byKindEnd( const ResKind & kind_r ) const;
117
118 template<class TRes>
119 const_iterator byKindEnd() const
120 { return byKindEnd( ResTraits<TRes>::kind ); }
121
122
123 Iterable<const_iterator> byKind( const ResKind & kind_r ) const
124 { return makeIterable( byKindBegin( kind_r ), byKindEnd( kind_r ) ); }
125
126 template<class TRes>
127 Iterable<const_iterator> byKind() const
128 { return makeIterable( byKindBegin<TRes>(), byKindEnd<TRes>() ); }
129
131
132 public:
136 size_type knownRepositoriesSize() const;
137
138 repository_iterator knownRepositoriesBegin() const;
139
140 repository_iterator knownRepositoriesEnd() const;
141
142 Iterable<repository_iterator> knownRepositories() const
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
158 { return hasInstalledObj( ResTraits<TRes>::kind ); }
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
185 { return restoreState( ResTraits<TRes>::kind ); }
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>
209 ScopedSaveState && scopedSaveState() const
210 { return scopedSaveState( ResTraits<TRes>::kind ); }
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 );
251 RW_pointer<Impl> _pimpl;
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
263 struct ResPoolProxy::ScopedSaveState
264 {
265 NON_COPYABLE_BUT_MOVE( ScopedSaveState );
266
267 ScopedSaveState( const ResPoolProxy & pool_r )
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
275 ~ScopedSaveState()
276 { if ( _pimpl ) _pimpl->restoreState(); }
277
278 void acceptState()
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 {}
290 void saveState()
291 { if ( _kind ) _pool.saveState( *_kind ); else _pool.saveState(); }
292 void restoreState()
293 { if ( _kind ) _pool.restoreState( *_kind ); else _pool.restoreState(); }
294 ResPoolProxy _pool;
295 scoped_ptr<ResKind> _kind;
296
297 };
298 std::unique_ptr<Impl> _pimpl;
299 };
300
301 inline ResPoolProxy::ScopedSaveState ResPoolProxy::scopedSaveState() const
302 { return ScopedSaveState( *this ); }
303
304 inline ResPoolProxy::ScopedSaveState ResPoolProxy::scopedSaveState( const ResKind & kind_r ) const
305 { return ScopedSaveState( *this, kind_r ); }
306
308 } // namespace zypp
310 #endif // ZYPP_RESPOOLPROXY_H
PtrTypes.h
ResPool.h
SelFilters.h
Selectable.h
zypp::IdString
Access to the sat-pools string space.
Definition: IdString.h:43
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:35
zypp::ResPoolProxy::const_iterator
MapKVIteratorTraits< SelectablePool >::Value_const_iterator const_iterator
Definition: ResPoolProxy.h:42
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:150
zypp::ResPoolProxy::saveState
void saveState() const
Definition: ResPoolProxy.h:176
zypp::ResPoolProxy::saveState
void saveState() const
Definition: ResPoolProxy.cc:311
zypp::ResPoolProxy::hasInstalledObj
bool hasInstalledObj() const
Definition: ResPoolProxy.h:157
zypp::ResPoolProxy::size
size_type size() const
Definition: ResPoolProxy.cc:281
zypp::ResPoolProxy::make_begin
filter_iterator< TFilter, const_iterator > make_begin(const ResKind &kind_r) const
Definition: ResPoolProxy.h:225
zypp::ResPoolProxy::byKindEnd
const_iterator byKindEnd() const
Definition: ResPoolProxy.h:119
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(const PoolItem &pi_r) const
Definition: ResPoolProxy.h:80
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(ResKind kind_r, const std::string &name_r) const
Definition: ResPoolProxy.h:71
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(const sat::Solvable &solv_r) const
Definition: ResPoolProxy.h:74
zypp::ResPoolProxy::scopedSaveState
ScopedSaveState && scopedSaveState() const
Definition: ResPoolProxy.h:209
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(IdString ident_r) const
Definition: ResPoolProxy.h:68
zypp::ResPoolProxy::make_begin
filter_iterator< TFilter, const_iterator > make_begin(TFilter filter_r, const ResKind &kind_r) const
Definition: ResPoolProxy.h:217
zypp::ResPoolProxy::knownRepositoriesSize
size_type knownRepositoriesSize() const
Definition: ResPoolProxy.cc:302
zypp::ResPoolProxy::knownRepositories
Iterable< repository_iterator > knownRepositories() const
Definition: ResPoolProxy.h:142
zypp::ResPoolProxy::~ResPoolProxy
~ResPoolProxy()
Dtor.
Definition: ResPoolProxy.cc:266
zypp::ResPoolProxy::operator<<
friend std::ostream & operator<<(std::ostream &str, const ResPoolProxy &obj)
Definition: ResPoolProxy.cc:329
zypp::ResPoolProxy::begin
const_iterator begin() const
Definition: ResPoolProxy.cc:284
zypp::ResPoolProxy::repository_iterator
ResPool::repository_iterator repository_iterator
Definition: ResPoolProxy.h:47
zypp::ResPoolProxy::end
const_iterator end() const
Definition: ResPoolProxy.cc:287
zypp::ResPoolProxy::SelectablePool
std::multimap< ResKind, ui::Selectable::Ptr > SelectablePool
Definition: ResPoolProxy.h:38
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(const ResObject::constPtr &resolvable_r) const
Definition: ResPoolProxy.h:77
zypp::ResPoolProxy::empty
bool empty() const
Definition: ResPoolProxy.h:99
zypp::ResPoolProxy::ResPoolProxy
ResPoolProxy()
Default ctor: no pool Nonempty proxies are provided by ResPool.
Definition: ResPoolProxy.cc:248
zypp::ResPoolProxy::_pimpl
RW_pointer< Impl > _pimpl
Pointer to implementation.
Definition: ResPoolProxy.h:251
zypp::ResPoolProxy::empty
bool empty() const
Definition: ResPoolProxy.cc:278
zypp::ResPoolProxy::diffState
bool diffState() const
Definition: ResPoolProxy.cc:323
zypp::ResPoolProxy::dumpOn
friend std::ostream & dumpOn(std::ostream &str, const ResPoolProxy &obj)
Definition: ResPoolProxy.cc:332
zypp::ResPoolProxy::byKind
Iterable< const_iterator > byKind() const
Definition: ResPoolProxy.h:127
zypp::ResPoolProxy::byKind
Iterable< const_iterator > byKind(const ResKind &kind_r) const
Definition: ResPoolProxy.h:123
zypp::ResPoolProxy::restoreState
void restoreState() const
Definition: ResPoolProxy.cc:317
zypp::ResPoolProxy::knownRepositoriesBegin
repository_iterator knownRepositoriesBegin() const
Definition: ResPoolProxy.cc:305
zypp::ResPoolProxy::size_type
SelectablePool::size_type size_type
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:233
zypp::ResPoolProxy::lookup
ui::Selectable::Ptr lookup(const pool::ByIdent &ident_r) const
Definition: ResPoolProxy.cc:275
zypp::ResPoolProxy::restoreState
void restoreState() const
Definition: ResPoolProxy.h:184
zypp::ResPoolProxy::size
size_type size() const
Definition: ResPoolProxy.h:106
zypp::ResPoolProxy::knownRepositoriesEnd
repository_iterator knownRepositoriesEnd() const
Definition: ResPoolProxy.cc:308
zypp::ResPoolProxy::scopedSaveState
ScopedSaveState scopedSaveState() const
Definition: ResPoolProxy.h:301
zypp::ResPoolProxy::make_end
filter_iterator< TFilter, const_iterator > make_end(const ResKind &kind_r) const
Definition: ResPoolProxy.h:241
zypp::ResPoolProxy::byKindBegin
const_iterator byKindBegin() const
Definition: ResPoolProxy.h:112
zypp::ResPoolProxy::diffState
bool diffState() const
Definition: ResPoolProxy.h:192
zypp::ResPool
Global ResObject pool.
Definition: ResPool.h:61
zypp::detail::RepositoryIterator
Definition: Repository.h:460
zypp::pool::ByIdent
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:27
zypp::pool::PoolImpl
Definition: PoolImpl.h:168
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:57
str
String related utilities and Regular expression matching.
zypp::sat::detail::size_type
SolvableIdType size_type
Definition: PoolMember.h:126
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
zypp::operator<<
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:147
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
Definition: Capability.cc:444
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:223
zypp::RW_pointer
Wrapper for const correct access via Smart pointer types.
Definition: PtrTypes.h:286
zypp::ResPoolProxy::Impl
ResPoolProxy implementation.
Definition: ResPoolProxy.cc:92
zypp::ResPoolProxy::ScopedSaveState::Impl
Definition: ResPoolProxy.h:283
zypp::ResPoolProxy::ScopedSaveState::Impl::_pool
ResPoolProxy _pool
Definition: ResPoolProxy.h:294
zypp::ResPoolProxy::ScopedSaveState::Impl::_kind
scoped_ptr< ResKind > _kind
Definition: ResPoolProxy.h:295
zypp::ResPoolProxy::ScopedSaveState::Impl::saveState
void saveState()
Definition: ResPoolProxy.h:290
zypp::ResPoolProxy::ScopedSaveState::Impl::restoreState
void restoreState()
Definition: ResPoolProxy.h:292
zypp::ResPoolProxy::ScopedSaveState::Impl::Impl
Impl(const ResPoolProxy &pool_r, const ResKind &kind_r)
Definition: ResPoolProxy.h:287
zypp::ResPoolProxy::ScopedSaveState::Impl::Impl
Impl(const ResPoolProxy &pool_r)
Definition: ResPoolProxy.h:284
zypp::ResPoolProxy::ScopedSaveState
Exception safe scoped save/restore state.
Definition: ResPoolProxy.h:264
zypp::ResPoolProxy::ScopedSaveState::NON_COPYABLE_BUT_MOVE
NON_COPYABLE_BUT_MOVE(ScopedSaveState)
zypp::ResPoolProxy::ScopedSaveState::ScopedSaveState
ScopedSaveState(const ResPoolProxy &pool_r)
Definition: ResPoolProxy.h:267
zypp::ResPoolProxy::ScopedSaveState::~ScopedSaveState
~ScopedSaveState()
Definition: ResPoolProxy.h:275
zypp::ResPoolProxy::ScopedSaveState::acceptState
void acceptState()
Definition: ResPoolProxy.h:278
zypp::ResPoolProxy::ScopedSaveState::ScopedSaveState
ScopedSaveState(const ResPoolProxy &pool_r, const ResKind &kind_r)
Definition: ResPoolProxy.h:271
zypp::ResPoolProxy::ScopedSaveState::_pimpl
std::unique_ptr< Impl > _pimpl
Definition: ResPoolProxy.h:298
zypp::ResTraits
ResTraits.
Definition: ResTraits.h:80
zypp::sat::SolvableType::satSolvable
Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: SolvableType.h:57