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/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 &, const Arch & )> QueryInstalledCB; 00041 00043 PackageProviderPolicy & queryInstalledCB( QueryInstalledCB queryInstalledCB_r ) 00044 { _queryInstalledCB = queryInstalledCB_r; return *this; } 00045 00047 bool queryInstalled( const std::string & name_r, 00048 const Edition & ed_r, 00049 const Arch & arch_r ) const; 00050 00051 private: 00052 QueryInstalledCB _queryInstalledCB; 00053 }; 00055 00057 // 00058 // CLASS NAME : PackageProvider 00059 // 00063 class PackageProvider : private base::NonCopyable 00064 { 00065 typedef shared_ptr<void> ScopedGuard; 00066 typedef callback::SendReport<source::DownloadResolvableReport> Report; 00067 00068 typedef detail::ResImplTraits<Package::Impl>::constPtr PackageImpl_constPtr; 00069 typedef packagedelta::DeltaRpm DeltaRpm; 00070 typedef packagedelta::PatchRpm PatchRpm; 00071 00072 00073 public: 00075 PackageProvider( const Package::constPtr & package, 00076 const PackageProviderPolicy & policy_r = PackageProviderPolicy() ); 00077 ~PackageProvider(); 00078 00079 public: 00083 ManagedFile providePackage() const; 00084 00085 private: 00086 ManagedFile doProvidePackage() const; 00087 ManagedFile tryDelta( const DeltaRpm & delta_r ) const; 00088 ManagedFile tryPatch( const PatchRpm & patch_r ) const; 00089 00090 private: 00091 ScopedGuard newReport() const; 00092 Report & report() const; 00093 bool progressDeltaDownload( int value ) const; 00094 void progressDeltaApply( int value ) const; 00095 bool progressPatchDownload( int value ) const; 00096 bool progressPackageDownload( int value ) const; 00097 bool failOnChecksumError() const; 00098 bool queryInstalled( const Edition & ed_r = Edition() ) const; 00099 00100 private: 00101 PackageProviderPolicy _policy; 00102 Package::constPtr _package; 00103 PackageImpl_constPtr _implPtr; 00104 mutable bool _retry; 00105 mutable shared_ptr<Report> _report; 00106 00107 }; 00109 00111 } // namespace source 00114 } // namespace zypp 00116 #endif // ZYPP_SOURCE_PACKAGEPROVIDER_H
1.5.0