libzypp  13.10.6
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 
20 #include "zypp/pool/PoolTraits.h"
21 #include "zypp/PoolItem.h"
22 #include "zypp/Filter.h"
23 
25 namespace zypp
26 {
27 
28  class SerialNumber;
29  class ResPoolProxy;
30  class Resolver;
31 
33  //
34  // CLASS NAME : ResPool
35  //
48  class ResPool
49  {
50  friend std::ostream & operator<<( std::ostream & str, const ResPool & obj );
51 
52  public:
58 
59  public:
61  static ResPool instance();
62 
64  ResPoolProxy proxy() const;
65 
67  Resolver & resolver() const;
68 
69  public:
74  const SerialNumber & serial() const;
75 
76  public:
78  bool empty() const;
80  size_type size() const;
81 
86  { return make_filter_begin( pool::ByPoolItem(), store() ); }
89  { return make_filter_end( pool::ByPoolItem(), store() ); }
91 
92  public:
98  PoolItem find( const sat::Solvable & slv_r ) const;
100  PoolItem find( const ResObject::constPtr & resolvable_r ) const
101  { return( resolvable_r ? find( resolvable_r->satSolvable() ) : PoolItem() ); }
102 
103  public:
106  template<class _Filter>
107  filter_iterator<_Filter,const_iterator> filterBegin( const _Filter & filter_r ) const
108  { return make_filter_begin( filter_r, *this ); }
109 
110  template<class _Filter>
111  filter_iterator<_Filter,const_iterator> filterEnd( const _Filter & filter_r ) const
112  { return make_filter_end( filter_r, *this ); }
114 
134  filter_iterator<filter::ByStatus,const_iterator> byStatusBegin( const filter::ByStatus & filter_r ) const
135  { return make_filter_begin( filter_r, *this ); }
136 
137  filter_iterator<filter::ByStatus,const_iterator> byStatusEnd( const filter::ByStatus & filter_r ) const
138  { return make_filter_end( filter_r, *this ); }
140 
141  public:
146 
147  byIdent_iterator byIdentBegin( const ByIdent & ident_r ) const
148  {
149  return make_transform_iterator( id2item().equal_range( ident_r.get() ).first,
151  }
152 
154  { return byIdentBegin( ByIdent(kind_r,name_r) ); }
155 
156  byIdent_iterator byIdentBegin( ResKind kind_r, const C_Str & name_r ) const
157  { return byIdentBegin( ByIdent(kind_r,name_r) ); }
158 
159  template<class _Res>
161  { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r) ); }
162 
163  template<class _Res>
164  byIdent_iterator byIdentBegin( const C_Str & name_r ) const
165  { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r) ); }
166 
168  byIdent_iterator byIdentBegin( const PoolItem & pi_r ) const
169  { return byIdentBegin( ByIdent(pi_r.satSolvable()) ); }
172  { return byIdentBegin( ByIdent(slv_r) ); }
175  { return byIdentBegin( ByIdent(ident_r) ); }
176 
177 
178  byIdent_iterator byIdentEnd( const ByIdent & ident_r ) const
179  {
180  return make_transform_iterator( id2item().equal_range( ident_r.get() ).second,
182  }
183 
184  byIdent_iterator byIdentEnd( ResKind kind_r, IdString name_r ) const
185  { return byIdentEnd( ByIdent(kind_r,name_r) ); }
186 
187  byIdent_iterator byIdentEnd( ResKind kind_r, const C_Str & name_r ) const
188  { return byIdentEnd( ByIdent(kind_r,name_r) ); }
189 
190  template<class _Res>
192  { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r) ); }
193 
194  template<class _Res>
195  byIdent_iterator byIdentEnd( const C_Str & name_r ) const
196  { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r) ); }
197 
199  byIdent_iterator byIdentEnd( const PoolItem & pi_r ) const
200  { return byIdentEnd( ByIdent(pi_r.satSolvable()) ); }
203  { return byIdentEnd( ByIdent(slv_r) ); }
206  { return byIdentEnd( ByIdent(ident_r) ); }
208 
209  public:
213  typedef filter_iterator<ByKind,const_iterator> byKind_iterator;
214 
215  byKind_iterator byKindBegin( const ResKind & kind_r ) const
216  { return make_filter_begin( ByKind(kind_r), *this ); }
217 
218  template<class _Res>
220  { return make_filter_begin( resfilter::byKind<_Res>(), *this ); }
221 
222  byKind_iterator byKindEnd( const ResKind & kind_r ) const
223  { return make_filter_end( ByKind(kind_r), *this ); }
224 
225  template<class _Res>
227  { return make_filter_end( resfilter::byKind<_Res>(), *this ); }
229 
230  public:
234  typedef filter_iterator<ByName,const_iterator> byName_iterator;
235 
236  byName_iterator byNameBegin( const std::string & name_r ) const
237  { return make_filter_begin( ByName(name_r), *this ); }
238 
239  byName_iterator byNameEnd( const std::string & name_r ) const
240  { return make_filter_end( ByName(name_r), *this ); }
242 
243  public:
246 
248  public:
253 
255 
257 
261  Repository reposFind( const std::string & alias_r ) const;
263 
264  public:
293  void setRequestedLocales( const LocaleSet & locales_r );
294 
298  bool addRequestedLocale( const Locale & locale_r );
299 
303  bool eraseRequestedLocale( const Locale & locale_r );
304 
308  const LocaleSet & getRequestedLocales() const;
309 
311  bool isRequestedLocale( const Locale & locale_r ) const;
312 
317  const LocaleSet & getAvailableLocales() const;
318 
320  bool isAvailableLocale( const Locale & locale_r ) const;
322 
323  public:
338 
339  bool autoSoftLocksEmpty() const;
343 
348  void setAutoSoftLocks( const AutoSoftLocks & newLocks_r );
349 
355  void getActiveSoftLocks( AutoSoftLocks & activeLocks_r );
357 
358  public:
368 
369  bool hardLockQueriesEmpty() const;
373 
378  void setHardLockQueries( const HardLockQueries & newLocks_r );
379 
383  void getHardLockQueries( HardLockQueries & activeLocks_r );
385 
386  private:
387  const pool::PoolTraits::ItemContainerT & store() const;
388  const pool::PoolTraits::Id2ItemT & id2item() const;
389 
390  private:
395  };
397 
399  std::ostream & operator<<( std::ostream & str, const ResPool & obj );
400 
402 } // namespace zypp
404 
405 #include "zypp/ResPoolProxy.h"
406 
407 #endif // ZYPP_RESPOOL_H
transform_iterator< Id2ItemValueSelector, Id2ItemT::const_iterator > byIdent_iterator
Definition: PoolTraits.h:82
autoSoftLocks_iterator autoSoftLocksEnd() const
Definition: ResPool.cc:95
void getActiveSoftLocks(AutoSoftLocks &activeLocks_r)
Suggest a new soft-lock list based on the current selection.
Definition: ResPool.cc:101
ItemContainerT::size_type size_type
Definition: PoolTraits.h:75
A Solvable object within the sat Pool.
Definition: Solvable.h:55
const_iterator begin() const
Definition: ResPool.h:85
byIdent_iterator byIdentBegin(sat::Solvable slv_r) const
Derive name and kind from sat::Solvable.
Definition: ResPool.h:171
zypp::resfilter::ByName ByName
Definition: ResPool.h:233
byName_iterator byNameBegin(const std::string &name_r) const
Definition: ResPool.h:236
byIdent_iterator byIdentBegin(const PoolItem &pi_r) const
Derive name and kind from PoolItem.
Definition: ResPool.h:168
byIdent_iterator byIdentBegin(ResKind kind_r, IdString name_r) const
Definition: ResPool.h:153
byIdent_iterator byIdentEnd(const PoolItem &pi_r) const
Derive name and kind from PoolItem.
Definition: ResPool.h:199
byKind_iterator byKindBegin(const ResKind &kind_r) const
Definition: ResPool.h:215
std::vector< PoolItem > ItemContainerT
pure items
Definition: PoolTraits.h:71
Filter solvables according to their status.
Definition: Filter.h:138
pool::PoolTraits::repository_iterator repository_iterator
Definition: ResPool.h:57
byName_iterator byNameEnd(const std::string &name_r) const
Definition: ResPool.h:239
pool::PoolTraits::size_type size_type
Definition: ResPool.h:55
friend std::ostream & operator<<(std::ostream &str, const ResPool &obj)
Definition: ResPool.cc:161
bool isRequestedLocale(const Locale &locale_r) const
Whether this Locale is in the set of requested locales.
Definition: ResPool.cc:147
const pool::PoolTraits::Id2ItemT & id2item() const
Definition: ResPool.cc:127
byIdent_iterator byIdentBegin(IdString name_r) const
Definition: ResPool.h:160
filter_iterator< _Filter, const_iterator > filterBegin(const _Filter &filter_r) const
Definition: ResPool.h:107
In CXX0X std::_Select2nd does no longer derive from std::unary_function.
Definition: PoolTraits.h:49
filter_iterator< _Filter, const_iterator > filterEnd(const _Filter &filter_r) const
Definition: ResPool.h:111
Access to the sat-pools string space.
Definition: IdString.h:39
void setAutoSoftLocks(const AutoSoftLocks &newLocks_r)
Set a new soft-lock list.
Definition: ResPool.cc:98
pool::PoolTraits::HardLockQueries HardLockQueries
Definition: ResPool.h:366
ResTraits.
Definition: ResTraits.h:77
const_iterator end() const
Definition: ResPool.h:88
bool hardLockQueriesEmpty() const
Definition: ResPool.cc:105
filter_iterator< _Filter, typename _Container::const_iterator > make_filter_begin(_Filter f, const _Container &c)
Convenience to create filter_iterator from container::begin().
Definition: Iterator.h:99
TraitsType::constPtrType constPtr
Definition: ResObject.h:50
std::list< PoolQuery > HardLockQueries
hard locks from etc/zypp/locks
Definition: PoolTraits.h:92
byKind_iterator byKindEnd(const ResKind &kind_r) const
Definition: ResPool.h:222
byIdent_iterator byIdentEnd(const ByIdent &ident_r) const
Definition: ResPool.h:178
byKind_iterator byKindBegin() const
Definition: ResPool.h:219
Select ResObject by name.
Definition: ResFilters.h:160
ResPool::instance().proxy();.
Definition: ResPoolProxy.h:34
bool eraseRequestedLocale(const Locale &locale_r)
Erase one Locale from the set of requested locales.
Definition: ResPool.cc:141
filter_iterator< filter::ByStatus, const_iterator > byStatusEnd(const filter::ByStatus &filter_r) const
Definition: ResPool.h:137
Repository reposFind(const std::string &alias_r) const
Find a Repository named alias_r.
Definition: ResPool.cc:83
shared_ptr< PoolImpl > Impl_Ptr
Definition: PoolTraits.h:96
byIdent_iterator byIdentEnd(IdString name_r) const
Definition: ResPool.h:191
filter_iterator< ByKind, const_iterator > byKind_iterator
Definition: ResPool.h:213
byIdent_iterator byIdentEnd(const C_Str &name_r) const
Definition: ResPool.h:195
filter_iterator< ByName, const_iterator > byName_iterator
Definition: ResPool.h:234
pool::PoolTraits::autoSoftLocks_iterator autoSoftLocks_iterator
Definition: ResPool.h:337
repository_iterator knownRepositoriesEnd() const
Definition: ResPool.cc:80
ResPoolProxy proxy() const
preliminary
Definition: ResPool.cc:54
Dependency resolver interface.
Definition: Resolver.h:47
std::ostream & operator<<(std::ostream &str, const Exception &obj)
Definition: Exception.cc:120
pool::PoolTraits::byIdent_iterator byIdent_iterator
Definition: ResPool.h:145
Convenience char* constructible from std::string and char*, it maps (char*)0 to an empty string...
Definition: String.h:81
Provides API related macros.
void getHardLockQueries(HardLockQueries &activeLocks_r)
Suggest a new set of queries based on the current selection.
Definition: ResPool.cc:120
byIdent_iterator byIdentEnd(sat::Solvable slv_r) const
Derive name and kind from sat::Solvable.
Definition: ResPool.h:202
autoSoftLocks_iterator autoSoftLocksBegin() const
Definition: ResPool.cc:92
byIdent_iterator byIdentBegin(ResKind kind_r, const C_Str &name_r) const
Definition: ResPool.h:156
PoolItem value_type
PoolItem
Definition: ResPool.h:54
const LocaleSet & getRequestedLocales() const
Return the requested locales.
Definition: ResPool.cc:144
std::tr1::unordered_set< Locale > LocaleSet
Definition: Locale.h:28
filter_iterator< ByPoolItem, ItemContainerT::const_iterator > const_iterator
Definition: PoolTraits.h:74
hardLockQueries_iterator hardLockQueriesBegin() const
Definition: ResPool.cc:111
sat::detail::IdType get() const
Definition: ByIdent.h:88
byIdent_iterator byIdentEnd(ResKind kind_r, IdString name_r) const
Definition: ResPool.h:184
size_type autoSoftLocksSize() const
Definition: ResPool.cc:89
Simple serial number provider.
Definition: SerialNumber.h:44
void setHardLockQueries(const HardLockQueries &newLocks_r)
Set a new set of queries.
Definition: ResPool.cc:117
pool::PoolTraits::AutoSoftLocks AutoSoftLocks
Definition: ResPool.h:336
repository_iterator knownRepositoriesBegin() const
Definition: ResPool.cc:77
byIdent_iterator byIdentEnd(IdString ident_r) const
Takes a sat::Solvable::ident string.
Definition: ResPool.h:205
Global ResObject pool.
Definition: ResPool.h:48
size_type knownRepositoriesSize() const
Definition: ResPool.cc:74
hardLockQueries_iterator hardLockQueriesEnd() const
Definition: ResPool.cc:114
PoolItem find(const ResObject::constPtr &resolvable_r) const
Definition: ResPool.h:100
Resolver & resolver() const
The Resolver.
Definition: ResPool.cc:57
bool addRequestedLocale(const Locale &locale_r)
Add one Locale to the set of requested locales.
Definition: ResPool.cc:138
pool::PoolTraits::hardLockQueries_iterator hardLockQueries_iterator
Definition: ResPool.h:367
std::tr1::unordered_set< IdString > AutoSoftLocks
soft locks
Definition: PoolTraits.h:88
filter::ByKind ByKind
Definition: ResPool.h:212
sat::Solvable satSolvable() const
Return the corresponding sat::Solvable.
Definition: PoolItem.h:114
HardLockQueries::const_iterator hardLockQueries_iterator
Definition: PoolTraits.h:93
const SerialNumber & serial() const
The pools serial number.
Definition: ResPool.cc:60
pool::ByIdent ByIdent
Definition: ResPool.h:144
filter_iterator< _Filter, typename _Container::const_iterator > make_filter_end(_Filter f, const _Container &c)
Convenience to create filter_iterator from container::end().
Definition: Iterator.h:115
byIdent_iterator byIdentEnd(ResKind kind_r, const C_Str &name_r) const
Definition: ResPool.h:187
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
const LocaleSet & getAvailableLocales() const
Get the set of available locales.
Definition: ResPool.cc:150
pool::PoolTraits::const_iterator const_iterator
Definition: ResPool.h:56
size_type hardLockQueriesSize() const
Definition: ResPool.cc:108
PoolItem find(const sat::Solvable &slv_r) const
Return the corresponding PoolItem.
Definition: ResPool.cc:70
bool autoSoftLocksEmpty() const
Definition: ResPool.cc:86
byKind_iterator byKindEnd() const
Definition: ResPool.h:226
Pool internal filter skiping invalid/unwanted PoolItems.
Definition: PoolTraits.h:40
Resolvable kinds.
Definition: ResKind.h:35
RW_pointer< pool::PoolTraits::Impl > _pimpl
Access to implementation.
Definition: ResPool.h:394
std::tr1::unordered_multimap< sat::detail::IdType, PoolItem > Id2ItemT
ident index
Definition: PoolTraits.h:79
byIdent_iterator byIdentBegin(const ByIdent &ident_r) const
Definition: ResPool.h:147
ResPool(pool::PoolTraits::Impl_Ptr impl_r)
Ctor.
Definition: ResPool.cc:44
void setRequestedLocales(const LocaleSet &locales_r)
Set the requested locales.
Definition: ResPool.cc:135
const pool::PoolTraits::ItemContainerT & store() const
Definition: ResPool.cc:124
byIdent_iterator byIdentBegin(IdString ident_r) const
Takes a sat::Solvable::ident string.
Definition: ResPool.h:174
byIdent_iterator byIdentBegin(const C_Str &name_r) const
Definition: ResPool.h:164
size_type size() const
Definition: ResPool.cc:66
Main filter selecting PoolItems by name and kind.
Definition: ByIdent.h:26
bool empty() const
Definition: ResPool.cc:63
bool isAvailableLocale(const Locale &locale_r) const
Whether this Locale is in the set of available locales.
Definition: ResPool.cc:153
AutoSoftLocks::const_iterator autoSoftLocks_iterator
Definition: PoolTraits.h:89
Filter solvables according to their kind.
Definition: Filter.h:105
static ResPool instance()
Singleton ctor.
Definition: ResPool.cc:33
filter_iterator< filter::ByStatus, const_iterator > byStatusBegin(const filter::ByStatus &filter_r) const
Definition: ResPool.h:134