libzypp
10.5.0
|
00001 /*---------------------------------------------------------------------\ 00002 | ____ _ __ __ ___ | 00003 | |__ / \ / / . \ . \ | 00004 | / / \ V /| _/ _/ | 00005 | / /__ | | | | | | | 00006 | /_____||_| |_| |_| | 00007 | | 00008 \---------------------------------------------------------------------*/ 00012 #ifndef ZYPP_SAT_REPOSITORY_H 00013 #define ZYPP_SAT_REPOSITORY_H 00014 00015 #include <iosfwd> 00016 #include "zypp/base/SafeBool.h" 00017 #include "zypp/Pathname.h" 00018 #include "zypp/sat/detail/PoolMember.h" 00019 #include "zypp/sat/LookupAttr.h" // LookupAttrTools.h included at EOF 00020 #include "zypp/sat/Solvable.h" 00021 #include "zypp/RepoInfo.h" 00022 #include "zypp/Date.h" 00023 00025 namespace zypp 00026 { 00027 00028 namespace detail 00029 { 00030 struct ByRepository; 00031 } 00032 00034 // 00035 // CLASS NAME : Repository 00036 // 00038 class Repository : protected sat::detail::PoolMember, 00039 private base::SafeBool<Repository> 00040 { 00041 public: 00042 typedef filter_iterator<detail::ByRepository, sat::detail::SolvableIterator> SolvableIterator; 00043 typedef sat::detail::size_type size_type; 00044 typedef sat::detail::RepoIdType IdType; 00045 00046 typedef sat::ArrayAttr<std::string,std::string> Keywords; 00047 00048 public: 00050 Repository() 00051 : _id( sat::detail::noRepoId ) {} 00052 00054 explicit Repository( IdType id_r ) 00055 : _id( id_r ) {} 00056 00057 public: 00059 static const Repository noRepository; 00060 00061 #ifndef SWIG // Swig treats it as syntax error 00062 00063 using base::SafeBool<Repository>::operator bool_type; 00064 #endif 00065 00066 static const std::string & systemRepoAlias(); 00067 00069 bool isSystemRepo() const; 00070 00071 public: 00081 std::string alias() const; 00082 00084 std::string name() const; 00085 00102 Date generatedTimestamp() const; 00103 00120 Date suggestedExpirationTimestamp() const; 00121 00125 Keywords keywords() const; 00126 00135 bool maybeOutdated() const; 00136 00145 bool isUpdateRepo() const; 00146 00156 bool providesUpdatesFor( const std::string &cpeid ) const; 00157 00159 bool solvablesEmpty() const; 00160 00162 size_type solvablesSize() const; 00163 00165 SolvableIterator solvablesBegin() const; 00166 00168 SolvableIterator solvablesEnd() const; 00169 00170 public: 00171 00173 class ProductInfoIterator; 00174 00182 ProductInfoIterator compatibleWithProductBegin() const; 00183 00189 ProductInfoIterator compatibleWithProductEnd() const; 00190 00196 ProductInfoIterator updatesProductBegin() const; 00197 00203 ProductInfoIterator updatesProductEnd() const; 00204 00205 public: 00207 RepoInfo info() const; 00208 00214 void setInfo( const RepoInfo & info_r ); 00215 00217 void clearInfo(); 00218 00219 public: 00221 void eraseFromPool(); 00222 00224 struct EraseFromPool; 00225 00226 public: 00228 Repository nextInPool() const; 00229 00230 public: 00242 void addSolv( const Pathname & file_r ); 00243 00251 void addHelix( const Pathname & file_r ); 00252 00254 sat::Solvable::IdType addSolvables( unsigned count_r ); 00256 sat::Solvable::IdType addSolvable() 00257 { return addSolvables( 1 ); } 00259 00260 public: 00262 ::_Repo * get() const; 00264 IdType id() const { return _id; } 00273 int satInternalPriority() const; 00274 int satInternalSubPriority() const; 00276 private: 00277 #ifndef SWIG // Swig treats it as syntax error 00278 friend base::SafeBool<Repository>::operator bool_type() const; 00279 #endif 00280 bool boolTest() const { return get(); } 00281 private: 00282 IdType _id; 00283 }; 00285 00287 std::ostream & operator<<( std::ostream & str, const Repository & obj ); 00288 00290 inline bool operator==( const Repository & lhs, const Repository & rhs ) 00291 { return lhs.get() == rhs.get(); } 00292 00294 inline bool operator!=( const Repository & lhs, const Repository & rhs ) 00295 { return lhs.get() != rhs.get(); } 00296 00298 inline bool operator<( const Repository & lhs, const Repository & rhs ) 00299 { return lhs.get() < rhs.get(); } 00300 00302 00318 class Repository::ProductInfoIterator : public boost::iterator_adaptor< 00319 Repository::ProductInfoIterator // Derived 00320 , sat::LookupAttr::iterator // Base 00321 , int // Value 00322 , boost::forward_traversal_tag // CategoryOrTraversal 00323 , int // Reference 00324 > 00325 { 00326 public: 00327 ProductInfoIterator() 00328 {} 00329 00333 std::string label() const; 00334 00341 std::string cpeId() const; 00342 00343 private: 00344 friend class Repository; 00346 explicit ProductInfoIterator( sat::SolvAttr attr_r, Repository repo_r ); 00347 00348 private: 00349 friend class boost::iterator_core_access; 00350 int dereference() const { return 0; } 00351 }; 00353 00355 // 00356 // CLASS NAME : Repository::EraseFromPool 00357 // 00384 struct Repository::EraseFromPool 00385 { 00386 void operator()( Repository repository_r ) const 00387 { repository_r.eraseFromPool(); } 00388 }; 00390 00392 namespace detail 00393 { 00394 00395 // 00396 // CLASS NAME : RepositoryIterator 00397 // 00399 class RepositoryIterator : public boost::iterator_adaptor< 00400 RepositoryIterator // Derived 00401 , ::_Repo ** // Base 00402 , Repository // Value 00403 , boost::forward_traversal_tag // CategoryOrTraversal 00404 , Repository // Reference 00405 > 00406 { 00407 public: 00408 RepositoryIterator() 00409 : RepositoryIterator::iterator_adaptor_( 0 ) 00410 {} 00411 00412 explicit RepositoryIterator( ::_Repo ** p ) 00413 : RepositoryIterator::iterator_adaptor_( p ) 00414 {} 00415 00416 private: 00417 friend class boost::iterator_core_access; 00418 00419 Repository dereference() const 00420 { return Repository( *base() ); } 00421 }; 00424 // 00425 // CLASS NAME : ByRepository 00426 // 00428 struct ByRepository 00429 { 00430 public: 00431 ByRepository( const Repository & repository_r ) : _repository( repository_r ) {} 00432 ByRepository( sat::detail::RepoIdType id_r ) : _repository( id_r ) {} 00433 ByRepository() {} 00434 00435 bool operator()( const sat::Solvable & slv_r ) const 00436 { return slv_r.repository() == _repository; } 00437 00438 private: 00439 Repository _repository; 00440 }; 00443 } // namespace detail 00446 } // namespace zypp 00448 00449 // Late include as sat::ArrayAttr requires Repository.h 00450 #include "zypp/sat/LookupAttrTools.h" 00451 00452 #endif // ZYPP_SAT_REPOSITORY_H