RepoManager.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_REPOMANAGER_H
00013 #define ZYPP_REPOMANAGER_H
00014 
00015 #include <iosfwd>
00016 #include <list>
00017 
00018 #include "zypp/base/PtrTypes.h"
00019 //#include "zypp/base/ReferenceCounted.h"
00020 //#include "zypp/base/NonCopyable.h"
00021 #include "zypp/Pathname.h"
00022 #include "zypp/ZConfig.h"
00023 #include "zypp/Repository.h"
00024 #include "zypp/RepoInfo.h"
00025 #include "zypp/repo/RepoException.h"
00026 #include "zypp/repo/RepoType.h"
00027 #include "zypp/RepoStatus.h"
00028 #include "zypp/ProgressData.h"
00029 
00031 namespace zypp
00032 { 
00033 
00045    std::list<RepoInfo> readRepoFile(const Url & repo_file);
00046 
00051   struct RepoManagerOptions
00052   {
00053     RepoManagerOptions();
00054     
00055     Pathname repoCachePath;
00056     Pathname repoRawCachePath;
00057     Pathname knownReposPath;
00058   };
00059 
00064   class RepoManager
00065   {
00066     friend std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
00067 
00068   public:
00070     class Impl;
00071 
00072   public:
00073    RepoManager( const RepoManagerOptions &options = RepoManagerOptions() );
00075     ~RepoManager();
00076     
00077     enum RawMetadataRefreshPolicy
00078     {
00079       RefreshIfNeeded,
00080       RefreshForced
00081     };
00082     
00083     enum CacheBuildPolicy
00084     {
00085       BuildIfNeeded,
00086       BuildForced
00087     };
00088     
00089     enum RepoRemovePolicy
00090     {
00091       
00092     };
00093 
00102    std::list<RepoInfo> knownRepositories() const;
00103 
00107     RepoStatus metadataStatus( const RepoInfo &info ) const;
00108 
00161     bool checkIfToRefreshMetadata( const RepoInfo &info,
00162                                    const Url &url,
00163                                    RawMetadataRefreshPolicy policy = RefreshIfNeeded);
00164     
00175     Pathname metadataPath( const RepoInfo &info ) const;
00176     
00191    void refreshMetadata( const RepoInfo &info,
00192                          RawMetadataRefreshPolicy policy = RefreshIfNeeded,
00193                          const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00194    
00203    void cleanMetadata( const RepoInfo &info,
00204                        const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00205 
00209     RepoStatus cacheStatus( const RepoInfo &info ) const;
00210 
00229    void buildCache( const RepoInfo &info,
00230                     CacheBuildPolicy policy = BuildIfNeeded,
00231                     const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00232 
00245    void cleanCache( const RepoInfo &info,
00246                     const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00247    
00253     bool isCached( const RepoInfo &info ) const;
00254    
00264    Repository createFromCache( const RepoInfo &info,
00265                                const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00266 
00276    Repository createFromMetadata( const RepoInfo &info,
00277                                   const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00278 
00284    repo::RepoType probe( const Url &url ) const;
00285    
00286    
00298    void addRepository( const RepoInfo &info,
00299                        const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00300    
00315     void addRepositories( const Url &url,
00316                          const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00322     void removeRepository( const RepoInfo & info,
00323                            const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00324     
00332     void modifyRepository( const std::string &alias,
00333                            const RepoInfo & newinfo,
00334                            const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00335 
00349     RepoInfo getRepositoryInfo( const std::string &alias,
00350                                 const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00351     
00371     RepoInfo getRepositoryInfo( const Url & url,
00372                                 const url::ViewOption & urlview = url::ViewOption::DEFAULTS,
00373                                 const ProgressData::ReceiverFnc & progressrcv = ProgressData::ReceiverFnc() );
00374 
00375   protected:
00376     RepoStatus rawMetadataStatus( const RepoInfo &info );
00377     RepoStatus cacheStatus( const RepoInfo &info );
00378     
00383     void touchIndexFile(const RepoInfo & info);
00384 
00385   public:
00386 
00387   private:
00389     RWCOW_pointer<Impl> _pimpl;
00390   };
00392 
00394   std::ostream & operator<<( std::ostream & str, const RepoManager & obj );
00395 
00397 } // namespace zypp
00399 #endif // ZYPP2_REPOMANAGER_H

Generated on Tue Sep 25 19:23:06 2007 for libzypp by  doxygen 1.5.3