PackageProvider.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_REPO_PACKAGEPROVIDER_H
00013 #define ZYPP_REPO_PACKAGEPROVIDER_H
00014 
00015 #include <iosfwd>
00016 
00017 #include "zypp/base/NonCopyable.h"
00018 
00019 #include "zypp/ZYppCallbacks.h"
00020 #include "zypp/Repository.h"
00021 #include "zypp/Package.h"
00022 #include "zypp/ManagedFile.h"
00023 #include "zypp/repo/RepoProvideFile.h"
00024 #include "zypp/repo/DeltaCandidates.h"
00025 
00027 namespace zypp
00028 { 
00029 
00030   namespace repo
00031   { 
00032 
00034     //
00035     //  CLASS NAME : PackageProviderPolicy
00036     //
00038     class PackageProviderPolicy
00039     {
00040     public:
00042       typedef function<bool ( const std::string &, const Edition &, const Arch & )> QueryInstalledCB;
00043 
00045       PackageProviderPolicy & queryInstalledCB( QueryInstalledCB queryInstalledCB_r )
00046       { _queryInstalledCB = queryInstalledCB_r; return *this; }
00047 
00049       bool queryInstalled( const std::string & name_r,
00050                            const Edition &     ed_r,
00051                            const Arch &        arch_r ) const;
00052 
00053     private:
00054       QueryInstalledCB _queryInstalledCB;
00055     };
00057 
00059     //
00060     //  CLASS NAME : PackageProvider
00061     //
00065     class PackageProvider : private base::NonCopyable
00066     {
00067       typedef shared_ptr<void>                                       ScopedGuard;
00068       typedef callback::SendReport<repo::DownloadResolvableReport> Report;
00069 
00070       typedef detail::ResImplTraits<Package::Impl>::constPtr PackageImpl_constPtr;
00071       typedef packagedelta::DeltaRpm                         DeltaRpm;
00072       typedef packagedelta::PatchRpm                         PatchRpm;
00073 
00074 
00075     public:
00077       PackageProvider( RepoMediaAccess &access,
00078                        const Package::constPtr & package,
00079                        const DeltaCandidates & deltas,
00080                        const PackageProviderPolicy & policy_r = PackageProviderPolicy() );
00081       ~PackageProvider();
00082 
00083     public:
00087       ManagedFile providePackage() const;
00088 
00089     private:
00090       ManagedFile doProvidePackage() const;
00091       ManagedFile tryDelta( const DeltaRpm & delta_r ) const;
00092       ManagedFile tryPatch( const PatchRpm & patch_r ) const;
00093 
00094     private:
00095       ScopedGuard newReport() const;
00096       Report & report() const;
00097       bool progressDeltaDownload( int value ) const;
00098       void progressDeltaApply( int value ) const;
00099       bool progressPatchDownload( int value ) const;
00100       bool progressPackageDownload( int value ) const;
00101       bool failOnChecksumError() const;
00102       bool queryInstalled( const Edition & ed_r = Edition() ) const;
00103 
00104     private:
00105       PackageProviderPolicy      _policy;
00106       Package::constPtr          _package;
00107       PackageImpl_constPtr       _implPtr;
00108       mutable bool               _retry;
00109       mutable shared_ptr<Report> _report;
00110       DeltaCandidates _deltas;
00111       RepoMediaAccess &_access;
00112     };
00114 
00116   } // namespace repo
00119 } // namespace zypp
00121 #endif // ZYPP_SOURCE_PACKAGEPROVIDER_H

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