1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/repo/PackageProvider.h
12 #ifndef ZYPP_REPO_PACKAGEPROVIDER_H
13 #define ZYPP_REPO_PACKAGEPROVIDER_H
17 #include "zypp/base/NonCopyable.h"
19 #include "zypp/ZYppCallbacks.h"
20 #include "zypp/Repository.h"
21 #include "zypp/Package.h"
22 #include "zypp/ManagedFile.h"
24 #include "zypp/repo/DeltaCandidates.h"
26 ///////////////////////////////////////////////////////////////////
28 { /////////////////////////////////////////////////////////////////
29 ///////////////////////////////////////////////////////////////////
31 { /////////////////////////////////////////////////////////////////
33 ///////////////////////////////////////////////////////////////////
35 // CLASS NAME : PackageProviderPolicy
38 class PackageProviderPolicy
41 /** Get installed Editions callback signature. */
42 typedef function<bool ( const std::string &, const Edition &, const Arch & )> QueryInstalledCB;
45 PackageProviderPolicy & queryInstalledCB( QueryInstalledCB queryInstalledCB_r )
46 { _queryInstalledCB = queryInstalledCB_r; return *this; }
48 /** Evaluate callback. */
49 bool queryInstalled( const std::string & name_r,
51 const Arch & arch_r ) const;
54 QueryInstalledCB _queryInstalledCB;
56 ///////////////////////////////////////////////////////////////////
58 ///////////////////////////////////////////////////////////////////
60 // CLASS NAME : PackageProvider
62 /** Provide a package from a Source.
63 * Use available delta/patch-rpm if apropriate.
65 class PackageProvider : private base::NonCopyable
67 typedef shared_ptr<void> ScopedGuard;
68 typedef callback::SendReport<repo::DownloadResolvableReport> Report;
70 typedef detail::ResImplTraits<Package::Impl>::constPtr PackageImpl_constPtr;
71 typedef packagedelta::DeltaRpm DeltaRpm;
72 typedef packagedelta::PatchRpm PatchRpm;
76 /** Ctor taking the Package to provide. */
77 PackageProvider( const Package::constPtr & package,
78 const DeltaCandidates & deltas,
79 const PackageProviderPolicy & policy_r = PackageProviderPolicy() );
83 /** Provide the package.
86 ManagedFile providePackage() const;
89 ManagedFile doProvidePackage() const;
90 ManagedFile tryDelta( const DeltaRpm & delta_r ) const;
91 ManagedFile tryPatch( const PatchRpm & patch_r ) const;
94 ScopedGuard newReport() const;
95 Report & report() const;
96 bool progressDeltaDownload( int value ) const;
97 void progressDeltaApply( int value ) const;
98 bool progressPatchDownload( int value ) const;
99 bool progressPackageDownload( int value ) const;
100 bool failOnChecksumError() const;
101 bool queryInstalled( const Edition & ed_r = Edition() ) const;
104 PackageProviderPolicy _policy;
105 Package::constPtr _package;
106 PackageImpl_constPtr _implPtr;
108 mutable shared_ptr<Report> _report;
109 DeltaCandidates _deltas;
111 ///////////////////////////////////////////////////////////////////
113 /////////////////////////////////////////////////////////////////
115 ///////////////////////////////////////////////////////////////////
116 /////////////////////////////////////////////////////////////////
118 ///////////////////////////////////////////////////////////////////
119 #endif // ZYPP_SOURCE_PACKAGEPROVIDER_H