PackageProvider.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_SOURCE_PACKAGEPROVIDER_H
00013 #define ZYPP_SOURCE_PACKAGEPROVIDER_H
00014 
00015 #include <iosfwd>
00016 
00017 #include "zypp/base/NonCopyable.h"
00018 
00019 #include "zypp/ZYppCallbacks.h"
00020 #include "zypp/Source.h"
00021 #include "zypp/Package.h"
00022 #include "zypp/source/ManagedFile.h"
00023 
00025 namespace zypp
00026 { 
00027 
00028   namespace source
00029   { 
00030 
00032     //
00033     //  CLASS NAME : PackageProviderPolicy
00034     //
00036     class PackageProviderPolicy
00037     {
00038     public:
00040       typedef function<bool ( const std::string &, const Edition & )> QueryInstalledCB;
00041 
00043       PackageProviderPolicy & queryInstalledCB( QueryInstalledCB queryInstalledCB_r )
00044       { _queryInstalledCB = queryInstalledCB_r; return *this; }
00045 
00047       bool queryInstalled( const std::string & name_r, const Edition & ed_r = Edition() ) const;
00048 
00049     private:
00050       QueryInstalledCB _queryInstalledCB;
00051     };
00053 
00055     //
00056     //  CLASS NAME : PackageProvider
00057     //
00061     class PackageProvider : private base::NonCopyable
00062     {
00063       typedef shared_ptr<void>                                       ScopedGuard;
00064       typedef callback::SendReport<source::DownloadResolvableReport> Report;
00065 
00066       typedef detail::ResImplTraits<Package::Impl>::constPtr PackageImpl_constPtr;
00067       typedef packagedelta::DeltaRpm                         DeltaRpm;
00068       typedef packagedelta::PatchRpm                         PatchRpm;
00069 
00070 
00071     public:
00073       PackageProvider( const Package::constPtr & package,
00074                        const PackageProviderPolicy & policy_r = PackageProviderPolicy() );
00075       ~PackageProvider();
00076 
00077     public:
00081       ManagedFile providePackage() const;
00082 
00083     private:
00084       ManagedFile doProvidePackage() const;
00085       ManagedFile tryDelta( const DeltaRpm & delta_r ) const;
00086       ManagedFile tryPatch( const PatchRpm & patch_r ) const;
00087 
00088     private:
00089       ScopedGuard newReport() const;
00090       Report & report() const;
00091       bool progressDeltaDownload( int value ) const;
00092       void progressDeltaApply( int value ) const;
00093       bool progressPatchDownload( int value ) const;
00094       bool progressPackageDownload( int value ) const;
00095       bool failOnChecksumError() const;
00096       bool queryInstalled( const Edition & ed_r = Edition() ) const;
00097 
00098     private:
00099       PackageProviderPolicy      _policy;
00100       Package::constPtr          _package;
00101       PackageImpl_constPtr       _implPtr;
00102       mutable bool               _retry;
00103       mutable shared_ptr<Report> _report;
00104 
00105     };
00107 
00109   } // namespace source
00112 } // namespace zypp
00114 #endif // ZYPP_SOURCE_PACKAGEPROVIDER_H

Generated on Thu Sep 14 15:38:44 2006 for zypp by  doxygen 1.4.6