libzypp 8.13.6
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 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 class Resolver; 00031 00033 // 00034 // CLASS NAME : ResPool 00035 // 00048 class ResPool 00049 { 00050 friend std::ostream & operator<<( std::ostream & str, const ResPool & obj ); 00051 00052 public: 00054 typedef PoolItem value_type; 00055 typedef pool::PoolTraits::size_type size_type; 00056 typedef pool::PoolTraits::const_iterator const_iterator; 00057 typedef pool::PoolTraits::repository_iterator repository_iterator; 00058 00059 public: 00061 static ResPool instance(); 00062 00064 ResPoolProxy proxy() const; 00065 00067 Resolver & resolver() const; 00068 00069 public: 00074 const SerialNumber & serial() const; 00075 00076 public: 00078 bool empty() const; 00080 size_type size() const; 00081 00085 const_iterator begin() const 00086 { return make_filter_begin( pool::ByPoolItem(), store() ); } 00088 const_iterator end() const 00089 { return make_filter_end( pool::ByPoolItem(), store() ); } 00091 00092 public: 00098 PoolItem find( const sat::Solvable & slv_r ) const; 00100 PoolItem find( const ResObject::constPtr & resolvable_r ) const 00101 { return( resolvable_r ? find( resolvable_r->satSolvable() ) : PoolItem() ); } 00102 00103 public: 00106 template<class _Filter> 00107 filter_iterator<_Filter,const_iterator> filterBegin( const _Filter & filter_r ) const 00108 { return make_filter_begin( filter_r, *this ); } 00109 00110 template<class _Filter> 00111 filter_iterator<_Filter,const_iterator> filterEnd( const _Filter & filter_r ) const 00112 { return make_filter_end( filter_r, *this ); } 00114 00134 filter_iterator<filter::ByStatus,const_iterator> byStatusBegin( const filter::ByStatus & filter_r ) const 00135 { return make_filter_begin( filter_r, *this ); } 00136 00137 filter_iterator<filter::ByStatus,const_iterator> byStatusEnd( const filter::ByStatus & filter_r ) const 00138 { return make_filter_end( filter_r, *this ); } 00140 00141 public: 00144 typedef pool::ByIdent ByIdent; 00145 typedef pool::PoolTraits::byIdent_iterator byIdent_iterator; 00146 00147 byIdent_iterator byIdentBegin( const ByIdent & ident_r ) const 00148 { 00149 return make_transform_iterator( id2item().equal_range( ident_r.get() ).first, 00150 pool::PoolTraits::Id2ItemValueSelector() ); 00151 } 00152 00153 byIdent_iterator byIdentBegin( ResKind kind_r, IdString name_r ) const 00154 { return byIdentBegin( ByIdent(kind_r,name_r) ); } 00155 00156 byIdent_iterator byIdentBegin( ResKind kind_r, const C_Str & name_r ) const 00157 { return byIdentBegin( ByIdent(kind_r,name_r) ); } 00158 00159 template<class _Res> 00160 byIdent_iterator byIdentBegin( IdString name_r ) const 00161 { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r) ); } 00162 00163 template<class _Res> 00164 byIdent_iterator byIdentBegin( const C_Str & name_r ) const 00165 { return byIdentBegin( ByIdent(ResTraits<_Res>::kind,name_r) ); } 00166 00168 byIdent_iterator byIdentBegin( const PoolItem & pi_r ) const 00169 { return byIdentBegin( ByIdent(pi_r.satSolvable()) ); } 00171 byIdent_iterator byIdentBegin( sat::Solvable slv_r ) const 00172 { return byIdentBegin( ByIdent(slv_r) ); } 00174 byIdent_iterator byIdentBegin( IdString ident_r ) const 00175 { return byIdentBegin( ByIdent(ident_r) ); } 00176 00177 00178 byIdent_iterator byIdentEnd( const ByIdent & ident_r ) const 00179 { 00180 return make_transform_iterator( id2item().equal_range( ident_r.get() ).second, 00181 pool::PoolTraits::Id2ItemValueSelector() ); 00182 } 00183 00184 byIdent_iterator byIdentEnd( ResKind kind_r, IdString name_r ) const 00185 { return byIdentEnd( ByIdent(kind_r,name_r) ); } 00186 00187 byIdent_iterator byIdentEnd( ResKind kind_r, const C_Str & name_r ) const 00188 { return byIdentEnd( ByIdent(kind_r,name_r) ); } 00189 00190 template<class _Res> 00191 byIdent_iterator byIdentEnd( IdString name_r ) const 00192 { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r) ); } 00193 00194 template<class _Res> 00195 byIdent_iterator byIdentEnd( const C_Str & name_r ) const 00196 { return byIdentEnd( ByIdent(ResTraits<_Res>::kind,name_r) ); } 00197 00199 byIdent_iterator byIdentEnd( const PoolItem & pi_r ) const 00200 { return byIdentEnd( ByIdent(pi_r.satSolvable()) ); } 00202 byIdent_iterator byIdentEnd( sat::Solvable slv_r ) const 00203 { return byIdentEnd( ByIdent(slv_r) ); } 00205 byIdent_iterator byIdentEnd( IdString ident_r ) const 00206 { return byIdentEnd( ByIdent(ident_r) ); } 00208 00209 public: 00212 typedef filter::ByKind ByKind; 00213 typedef filter_iterator<ByKind,const_iterator> byKind_iterator; 00214 00215 byKind_iterator byKindBegin( const ResKind & kind_r ) const 00216 { return make_filter_begin( ByKind(kind_r), *this ); } 00217 00218 template<class _Res> 00219 byKind_iterator byKindBegin() const 00220 { return make_filter_begin( resfilter::byKind<_Res>(), *this ); } 00221 00222 byKind_iterator byKindEnd( const ResKind & kind_r ) const 00223 { return make_filter_end( ByKind(kind_r), *this ); } 00224 00225 template<class _Res> 00226 byKind_iterator byKindEnd() const 00227 { return make_filter_end( resfilter::byKind<_Res>(), *this ); } 00229 00230 public: 00233 typedef zypp::resfilter::ByName ByName; 00234 typedef filter_iterator<ByName,const_iterator> byName_iterator; 00235 00236 byName_iterator byNameBegin( const std::string & name_r ) const 00237 { return make_filter_begin( ByName(name_r), *this ); } 00238 00239 byName_iterator byNameEnd( const std::string & name_r ) const 00240 { return make_filter_end( ByName(name_r), *this ); } 00242 00243 public: 00246 00248 public: 00252 size_type knownRepositoriesSize() const; 00253 00254 repository_iterator knownRepositoriesBegin() const; 00255 00256 repository_iterator knownRepositoriesEnd() const; 00257 00261 Repository reposFind( const std::string & alias_r ) const; 00263 00264 public: 00293 void setRequestedLocales( const LocaleSet & locales_r ); 00294 00298 bool addRequestedLocale( const Locale & locale_r ); 00299 00303 bool eraseRequestedLocale( const Locale & locale_r ); 00304 00308 const LocaleSet & getRequestedLocales() const; 00309 00311 bool isRequestedLocale( const Locale & locale_r ) const; 00312 00317 const LocaleSet & getAvailableLocales() const; 00318 00320 bool isAvailableLocale( const Locale & locale_r ) const; 00322 00323 public: 00336 typedef pool::PoolTraits::AutoSoftLocks AutoSoftLocks; 00337 typedef pool::PoolTraits::autoSoftLocks_iterator autoSoftLocks_iterator; 00338 00339 bool autoSoftLocksEmpty() const; 00340 size_type autoSoftLocksSize() const; 00341 autoSoftLocks_iterator autoSoftLocksBegin() const; 00342 autoSoftLocks_iterator autoSoftLocksEnd() const; 00343 00348 void setAutoSoftLocks( const AutoSoftLocks & newLocks_r ); 00349 00355 void getActiveSoftLocks( AutoSoftLocks & activeLocks_r ); 00357 00358 public: 00366 typedef pool::PoolTraits::HardLockQueries HardLockQueries; 00367 typedef pool::PoolTraits::hardLockQueries_iterator hardLockQueries_iterator; 00368 00369 bool hardLockQueriesEmpty() const; 00370 size_type hardLockQueriesSize() const; 00371 hardLockQueries_iterator hardLockQueriesBegin() const; 00372 hardLockQueries_iterator hardLockQueriesEnd() const; 00373 00378 void setHardLockQueries( const HardLockQueries & newLocks_r ); 00379 00383 void getHardLockQueries( HardLockQueries & activeLocks_r ); 00385 00386 private: 00387 const pool::PoolTraits::ItemContainerT & store() const; 00388 const pool::PoolTraits::Id2ItemT & id2item() const; 00389 00390 private: 00392 ResPool( pool::PoolTraits::Impl_Ptr impl_r ); 00394 RW_pointer<pool::PoolTraits::Impl> _pimpl; 00395 }; 00397 00399 std::ostream & operator<<( std::ostream & str, const ResPool & obj ); 00400 00402 } // namespace zypp 00404 00405 #include "zypp/ResPoolProxy.h" 00406 00407 #endif // ZYPP_RESPOOL_H