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 * \throws Exception If pi_r refers to neither a \c Package nor a \c SrcPackage.
66 PackageProvider( RepoMediaAccess & access, const PoolItem & pi_r,
67 const PackageProviderPolicy & policy_r = PackageProviderPolicy() );
69 /** \overload Ctor taking additional hint to deltarpms (not used for SrcPackages)
70 * \throws Exception If pi_r refers to neither a \c Package nor a \c SrcPackage.
72 PackageProvider( RepoMediaAccess & access, const PoolItem & pi_r,
73 const DeltaCandidates & deltas,
74 const PackageProviderPolicy & policy_r = PackageProviderPolicy() );
76 /** Legacy Ctor taking a \c Package::constPtr to provide. */
77 PackageProvider( RepoMediaAccess & access,
78 const Package::constPtr & package,
79 const DeltaCandidates & deltas,
80 const PackageProviderPolicy & policy_r = PackageProviderPolicy() );
85 /** Provide the package.
88 ManagedFile providePackage() const;
90 /** Provide the package if it is cached. */
91 ManagedFile providePackageFromCache() const;
93 /** Whether the package is cached. */
94 bool isCached() const;
97 class Impl; ///< Implementation class.
99 RW_pointer<Impl> _pimpl; ///< Pointer to implementation.
101 ///////////////////////////////////////////////////////////////////
104 ///////////////////////////////////////////////////////////////////
106 ///////////////////////////////////////////////////////////////////
107 #endif // ZYPP_SOURCE_PACKAGEPROVIDER_H