libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_SAT_DETAIL_POOLIMPL_H 00013 #define ZYPP_SAT_DETAIL_POOLIMPL_H 00014 extern "C" 00015 { 00016 #include <solv/pool.h> 00017 #include <solv/repo.h> 00018 #include <solv/solvable.h> 00019 #include <solv/poolarch.h> 00020 #include <solv/repo_solv.h> 00021 } 00022 #include <iosfwd> 00023 00024 #include "zypp/base/Tr1hash.h" 00025 #include "zypp/base/NonCopyable.h" 00026 #include "zypp/base/SerialNumber.h" 00027 #include "zypp/sat/detail/PoolMember.h" 00028 #include "zypp/RepoInfo.h" 00029 #include "zypp/Locale.h" 00030 #include "zypp/Capability.h" 00031 #include "zypp/IdString.h" 00032 00034 namespace zypp 00035 { 00036 00037 namespace sat 00038 { 00039 00040 namespace detail 00041 { 00042 00044 // 00045 // CLASS NAME : PoolImpl 00046 // 00048 class PoolImpl : private base::NonCopyable 00049 { 00050 public: 00052 PoolImpl(); 00053 00055 ~PoolImpl(); 00056 00058 ::_Pool * operator->() 00059 { return _pool; } 00060 00061 public: 00063 const SerialNumber & serial() const 00064 { return _serial; } 00065 00069 void prepare() const; 00071 void prepareForSolving() const; 00072 00073 private: 00077 void setDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 ); 00078 00081 void depSetDirty( const char * a1 = 0, const char * a2 = 0, const char * a3 = 0 ); 00082 00084 static detail::IdType nsCallback( ::_Pool *, void * data, detail::IdType lhs, detail::IdType rhs ); 00085 00086 public: 00088 static const std::string & systemRepoAlias(); 00089 00090 bool isSystemRepo( ::_Repo * repo_r ) const 00091 { return repo_r && _pool->installed == repo_r; } 00092 00093 ::_Repo * systemRepo() const 00094 { return _pool->installed; } 00095 00096 public: 00103 ::_Repo * _createRepo( const std::string & name_r ); 00104 00106 void _deleteRepo( ::_Repo * repo_r ); 00107 00112 int _addSolv( ::_Repo * repo_r, FILE * file_r ); 00113 00118 int _addHelix( ::_Repo * repo_r, FILE * file_r ); 00119 00121 detail::SolvableIdType _addSolvables( ::_Repo * repo_r, unsigned count_r ); 00123 00125 void _postRepoAdd( ::_Repo * repo_r ); 00126 00127 public: 00129 bool validSolvable( const ::_Solvable & slv_r ) const 00130 { return slv_r.repo; } 00132 bool validSolvable( SolvableIdType id_r ) const 00133 { return id_r < unsigned(_pool->nsolvables) && validSolvable( _pool->solvables[id_r] ); } 00135 bool validSolvable( const ::_Solvable * slv_r ) const 00136 { return _pool->solvables <= slv_r && slv_r <= _pool->solvables+_pool->nsolvables && validSolvable( *slv_r ); } 00137 00138 public: 00139 ::_Pool * getPool() const 00140 { return _pool; } 00141 00143 ::_Repo * getRepo( RepoIdType id_r ) const 00144 { return id_r; } 00145 00149 ::_Solvable * getSolvable( SolvableIdType id_r ) const 00150 { 00151 if ( validSolvable( id_r ) ) 00152 return &_pool->solvables[id_r]; 00153 return 0; 00154 } 00155 00156 public: 00160 SolvableIdType getFirstId() const 00161 { return getNextId( 1 ); } 00162 00168 SolvableIdType getNextId( SolvableIdType id_r ) const 00169 { 00170 for( ++id_r; id_r < unsigned(_pool->nsolvables); ++id_r ) 00171 { 00172 if ( validSolvable( _pool->solvables[id_r] ) ) 00173 return id_r; 00174 } 00175 return noSolvableId; 00176 } 00177 00178 public: 00180 const RepoInfo & repoInfo( RepoIdType id_r ) 00181 { return _repoinfos[id_r]; } 00183 void setRepoInfo( RepoIdType id_r, const RepoInfo & info_r ); 00185 void eraseRepoInfo( RepoIdType id_r ) 00186 { _repoinfos.erase( id_r ); } 00187 00188 public: 00192 const sat::detail::IdType whatProvidesData( unsigned offset_r ) 00193 { return _pool->whatprovidesdata[offset_r]; } 00194 00198 unsigned whatProvides( Capability cap_r ) 00199 { prepare(); return ::pool_whatprovides( _pool, cap_r.id() ); } 00200 00201 public: 00204 void setTextLocale( const Locale & locale_r ); 00205 void setRequestedLocales( const LocaleSet & locales_r ); 00206 bool addRequestedLocale( const Locale & locale_r ); 00207 bool eraseRequestedLocale( const Locale & locale_r ); 00208 00209 const LocaleSet & getRequestedLocales() const 00210 { return _requestedLocales; } 00211 00212 bool isRequestedLocale( const Locale & locale_r ) const 00213 { 00214 LocaleSet::const_iterator it( _requestedLocales.find( locale_r ) ); 00215 return it != _requestedLocales.end(); 00216 } 00217 00218 const LocaleSet & getAvailableLocales() const; 00219 00220 bool isAvailableLocale( const Locale & locale_r ) const 00221 { 00222 const LocaleSet & avl( getAvailableLocales() ); 00223 LocaleSet::const_iterator it( avl.find( locale_r ) ); 00224 return it != avl.end(); 00225 } 00227 00228 public: 00231 typedef IdStringSet MultiversionList; 00232 00233 const MultiversionList & multiversionList() const 00234 { 00235 if ( ! _multiversionListPtr ) 00236 multiversionListInit(); 00237 return *_multiversionListPtr; 00238 } 00239 00240 bool isMultiversion( IdString ident_r ) const 00241 { 00242 const MultiversionList & l( multiversionList() ); 00243 return l.find( ident_r ) != l.end(); 00244 } 00246 00247 public: 00250 typedef IdStringSet OnSystemByUserList; 00251 00252 const OnSystemByUserList & onSystemByUserList() const 00253 { 00254 if ( ! _onSystemByUserListPtr ) 00255 onSystemByUserListInit(); 00256 return *_onSystemByUserListPtr; 00257 } 00258 00259 bool isOnSystemByUser( IdString ident_r ) const 00260 { 00261 const OnSystemByUserList & l( onSystemByUserList() ); 00262 return l.find( ident_r ) != l.end(); 00263 } 00265 00266 public: 00268 const std::set<std::string> & requiredFilesystems() const; 00269 00270 private: 00272 ::_Pool * _pool; 00274 SerialNumber _serial; 00276 SerialNumberWatcher _watcher; 00278 std::map<RepoIdType,RepoInfo> _repoinfos; 00279 00281 LocaleSet _requestedLocales; 00282 mutable scoped_ptr<LocaleSet> _availableLocalesPtr; 00283 mutable std::tr1::unordered_set<IdString> _locale2Solver; 00284 00286 void multiversionListInit() const; 00287 mutable scoped_ptr<MultiversionList> _multiversionListPtr; 00288 00290 void onSystemByUserListInit() const; 00291 mutable scoped_ptr<OnSystemByUserList> _onSystemByUserListPtr; 00292 00294 mutable scoped_ptr<std::set<std::string> > _requiredFilesystemsPtr; 00295 }; 00297 00299 } // namespace detail 00302 } // namespace sat 00305 } // namespace zypp 00307 #define POOL_SETDIRTY 00308 #endif // ZYPP_SAT_DETAIL_POOLIMPL_H