1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/repo/PackageProvider.h
12 #ifndef ZYPP_REPO_PACKAGEPROVIDER_H
13 #define ZYPP_REPO_PACKAGEPROVIDER_H
17 #include "zypp/ZYppCallbacks.h"
18 #include "zypp/Package.h"
19 #include "zypp/ManagedFile.h"
20 #include "zypp/repo/DeltaCandidates.h"
21 #include "zypp/repo/RepoProvideFile.h"
23 ///////////////////////////////////////////////////////////////////
26 ///////////////////////////////////////////////////////////////////
30 ///////////////////////////////////////////////////////////////////
31 /// \class PackageProviderPolicy
32 /// \brief Policies and options for \ref PackageProvider
33 ///////////////////////////////////////////////////////////////////
34 class PackageProviderPolicy
37 /** Get installed Editions callback signature. */
38 typedef function<bool ( const std::string &, const Edition &, const Arch & )> QueryInstalledCB;
41 PackageProviderPolicy & queryInstalledCB( QueryInstalledCB queryInstalledCB_r )
42 { _queryInstalledCB = queryInstalledCB_r; return *this; }
44 /** Evaluate callback. */
45 bool queryInstalled( const std::string & name_r,
47 const Arch & arch_r ) const;
50 QueryInstalledCB _queryInstalledCB;
52 ///////////////////////////////////////////////////////////////////
54 ///////////////////////////////////////////////////////////////////
55 /// \class PackageProvider
56 /// \brief Provide a package from a Repo.
58 /// Use available deltarpm if apropriate.
59 ///////////////////////////////////////////////////////////////////
63 /** Ctor taking the Package to provide. */
64 PackageProvider( RepoMediaAccess & access,
65 const Package::constPtr & package,
66 const DeltaCandidates & deltas,
67 const PackageProviderPolicy & policy_r = PackageProviderPolicy() );
71 /** Provide the package.
74 ManagedFile providePackage() const;
76 /** Provide the package if it is cached. */
77 ManagedFile providePackageFromCache() const;
79 /** Whether the package is cached. */
80 bool isCached() const;
83 class Impl; ///< Implementation class.
85 RW_pointer<Impl> _pimpl; ///< Pointer to implementation.
87 ///////////////////////////////////////////////////////////////////
90 ///////////////////////////////////////////////////////////////////
92 ///////////////////////////////////////////////////////////////////
93 #endif // ZYPP_SOURCE_PACKAGEPROVIDER_H