ResPool.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00012 #ifndef ZYPP_RESPOOL_H
00013 #define ZYPP_RESPOOL_H
00014
00015 #include <iosfwd>
00016
00017 #include "zypp/base/Deprecated.h"
00018 #include "zypp/base/Iterator.h"
00019
00020 #include "zypp/pool/PoolTraits.h"
00021 #include "zypp/PoolItem.h"
00022 #include "zypp/Filter.h"
00023
00025 namespace zypp
00026 {
00027
00028 class SerialNumber;
00029 class ResPoolProxy;
00030
00032
00033
00034
00047 class ResPool
00048 {
00049 friend std::ostream & operator<<( std::ostream & str, const ResPool & obj );
00050
00051 public:
00053 typedef PoolItem value_type;
00054 typedef pool::PoolTraits::size_type size_type;
00055 typedef pool::PoolTraits::const_iterator const_iterator;
00056 typedef pool::PoolTraits::repository_iterator repository_iterator;
00057
00058 public:
00060 static ResPool instance();
00061
00063 ResPoolProxy proxy() const;
00064
00065 public:
00070 const SerialNumber & serial() const;
00071
00072 public:
00074 bool empty() const;
00076 size_type size() const;
00077
00081 const_iterator begin() const
00082 { return make_filter_begin( pool::ByPoolItem(), store() ); }
00084 const_iterator end() const
00085 { return make_filter_end( pool::ByPoolItem(), store() ); }
00087
00088 public:
00094 PoolItem find( const sat::Solvable & slv_r ) const;
00096 PoolItem find( const ResObject::constPtr & resolvable_r ) const
00097 { return( resolvable_r ? find( resolvable_r->satSolvable() ) : PoolItem() ); }
00098
00099 public:
00102 template<class _Filter>
00103 filter_iterator<_Filter,const_iterator> filterBegin( const _Filter & filter_r ) const
00104 { return make_filter_begin( filter_r, *this ); }
00105
00106 template<class _Filter>
00107 filter_iterator<_Filter,const_iterator> filterEnd( const _Filter & filter_r ) const
00108 { return make_filter_end( filter_r, *this ); }
00110
00130 filter_iterator<filter::ByStatus,const_iterator> byStatusBegin( const filter::ByStatus & filter_r ) const
00131 { return make_filter_begin( filter_r, *this ); }
00132
00133 filter_iterator<filter::ByStatus,const_iterator> byStatusEnd( const filter::ByStatus & filter_r ) const
00134 { return make_filter_end( filter_r, *this ); }
00136
00137 public:
00140 typedef pool::ByIdent ByIdent;
00141 typedef pool::PoolTraits::byIdent_iterator byIdent_iterator;
00142
00143 byIdent_iterator byIdentBegin( const ByIdent & ident_r ) const
00144 {
00145 return make_transform_iterator( id2item().equal_range( ident_r.get() ).first,
00146 pool::PoolTraits::Id2ItemValueSelector() );
00147 }
00148
00149 byIdent_iterator byIdentBegin( ResKind kind_r, IdString name_r ) const
00150 { return byIdentBegin( ByIdent(kind_r,name_r) ); }
00151
00152 byIdent_iterator byIdentBegin( ResKind kind_r, const C_Str & name_r ) const
00153 { return byIdentBegin( ByIdent(kind_r,name_r) ); }
00154
00155 template<class _Res>
00156 byIdent_iterator byIdentBegin( IdString name_r ) const
00157 { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r) ); }
00158
00159 template<class _Res>
00160 byIdent_iterator byIdentBegin( const C_Str & name_r ) const
00161 { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r) ); }
00162
00164 byIdent_iterator byIdentBegin( const PoolItem & pi_r ) const
00165 { return byIdentBegin( ByIdent(pi_r.satSolvable()) ); }
00167 byIdent_iterator byIdentBegin( sat::Solvable slv_r ) const
00168 { return byIdentBegin( ByIdent(slv_r) ); }
00170 byIdent_iterator byIdentBegin( IdString ident_r ) const
00171 { return byIdentBegin( ByIdent(ident_r) ); }
00172
00173
00174 byIdent_iterator byIdentEnd( const ByIdent & ident_r ) const
00175 {
00176 return make_transform_iterator( id2item().equal_range( ident_r.get() ).second,
00177 pool::PoolTraits::Id2ItemValueSelector() );
00178 }
00179
00180 byIdent_iterator byIdentEnd( ResKind kind_r, IdString name_r ) const
00181 { return byIdentEnd( ByIdent(kind_r,name_r) ); }
00182
00183 byIdent_iterator byIdentEnd( ResKind kind_r, const C_Str & name_r ) const
00184 { return byIdentEnd( ByIdent(kind_r,name_r) ); }
00185
00186 template<class _Res>
00187 byIdent_iterator byIdentEnd( IdString name_r ) const
00188 { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r) ); }
00189
00190 template<class _Res>
00191 byIdent_iterator byIdentEnd( const C_Str & name_r ) const
00192 { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r) ); }
00193
00195 byIdent_iterator byIdentEnd( const PoolItem & pi_r ) const
00196 { return byIdentEnd( ByIdent(pi_r.satSolvable()) ); }
00198 byIdent_iterator byIdentEnd( sat::Solvable slv_r ) const
00199 { return byIdentEnd( ByIdent(slv_r) ); }
00201 byIdent_iterator byIdentEnd( IdString ident_r ) const
00202 { return byIdentEnd( ByIdent(ident_r) ); }
00204
00205 public:
00208 typedef filter::ByKind ByKind;
00209 typedef filter_iterator<ByKind,const_iterator> byKind_iterator;
00210
00211 byKind_iterator byKindBegin( const ResKind & kind_r ) const
00212 { return make_filter_begin( ByKind(kind_r), *this ); }
00213
00214 template<class _Res>
00215 byKind_iterator byKindBegin() const
00216 { return make_filter_begin( resfilter::byKind<_Res>(), *this ); }
00217
00218 byKind_iterator byKindEnd( const ResKind & kind_r ) const
00219 { return make_filter_end( ByKind(kind_r), *this ); }
00220
00221 template<class _Res>
00222 byKind_iterator byKindEnd() const
00223 { return make_filter_end( resfilter::byKind<_Res>(), *this ); }
00225
00226 public:
00229 typedef zypp::resfilter::ByName ByName;
00230 typedef filter_iterator<ByName,const_iterator> byName_iterator;
00231
00232 byName_iterator byNameBegin( const std::string & name_r ) const
00233 { return make_filter_begin( ByName(name_r), *this ); }
00234
00235 byName_iterator byNameEnd( const std::string & name_r ) const
00236 { return make_filter_end( ByName(name_r), *this ); }
00238
00239 public:
00242
00244 public:
00248 size_type knownRepositoriesSize() const;
00249
00250 repository_iterator knownRepositoriesBegin() const;
00251
00252 repository_iterator knownRepositoriesEnd() const;
00253
00257 Repository reposFind( const std::string & alias_r ) const;
00259
00260 public:
00289 void setRequestedLocales( const LocaleSet & locales_r );
00290
00294 bool addRequestedLocale( const Locale & locale_r );
00295
00299 bool eraseRequestedLocale( const Locale & locale_r );
00300
00304 const LocaleSet & getRequestedLocales() const;
00305
00307 bool isRequestedLocale( const Locale & locale_r ) const;
00308
00313 const LocaleSet & getAvailableLocales() const;
00314
00316 bool isAvailableLocale( const Locale & locale_r ) const;
00318
00319 public:
00332 typedef pool::PoolTraits::AutoSoftLocks AutoSoftLocks;
00333 typedef pool::PoolTraits::autoSoftLocks_iterator autoSoftLocks_iterator;
00334
00335 bool autoSoftLocksEmpty() const;
00336 size_type autoSoftLocksSize() const;
00337 autoSoftLocks_iterator autoSoftLocksBegin() const;
00338 autoSoftLocks_iterator autoSoftLocksEnd() const;
00339
00344 void setAutoSoftLocks( const AutoSoftLocks & newLocks_r );
00345
00351 void getActiveSoftLocks( AutoSoftLocks & activeLocks_r );
00353
00354 public:
00362 typedef pool::PoolTraits::HardLockQueries HardLockQueries;
00363 typedef pool::PoolTraits::hardLockQueries_iterator hardLockQueries_iterator;
00364
00365 bool hardLockQueriesEmpty() const;
00366 size_type hardLockQueriesSize() const;
00367 hardLockQueries_iterator hardLockQueriesBegin() const;
00368 hardLockQueries_iterator hardLockQueriesEnd() const;
00369
00374 void setHardLockQueries( const HardLockQueries & newLocks_r );
00375
00379 void getHardLockQueries( HardLockQueries & activeLocks_r );
00381
00382 private:
00383 const pool::PoolTraits::ItemContainerT & store() const;
00384 const pool::PoolTraits::Id2ItemT & id2item() const;
00385
00386 private:
00388 ResPool( pool::PoolTraits::Impl_Ptr impl_r );
00390 RW_pointer<pool::PoolTraits::Impl> _pimpl;
00391 };
00393
00395 std::ostream & operator<<( std::ostream & str, const ResPool & obj );
00396
00398 }
00400
00401 #include "zypp/ResPoolProxy.h"
00402
00403 #endif // ZYPP_RESPOOL_H