libzypp 17.35.14
CommitPackageCacheImpl.h
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8\---------------------------------------------------------------------*/
12#ifndef ZYPP_TARGET_COMMITPACKAGECACHEIMPL_H
13#define ZYPP_TARGET_COMMITPACKAGECACHEIMPL_H
14
15#include <iosfwd>
16#include <utility>
17
18#include <zypp/base/Logger.h>
19#include <zypp/base/Exception.h>
20
22
24namespace zypp
25{
27 namespace target
28 {
29
31 //
32 // CLASS NAME : CommitPackageCache::Impl
33 //
41 {
42 public:
44
45 public:
46 Impl( PackageProvider &&packageProvider_r )
47 : _packageProvider(std::move( packageProvider_r ))
48 {}
49
50 virtual ~Impl()
51 {}
52
53 public:
57 virtual ManagedFile get( const PoolItem & citem_r )
58 {
59 return sourceProvidePackage( citem_r );
60 }
61
62 virtual ManagedFile get_from_cache( const PoolItem & citem_r )
63 {
64 return sourceProvideCachedPackage( citem_r );
65 }
66
67 void setCommitList( std::vector<sat::Solvable> commitList_r )
68 { _commitList = std::move(commitList_r); }
69
70 const std::vector<sat::Solvable> & commitList() const
71 { return _commitList; }
72
73 bool preloaded() const
74 { return _preloaded; }
75
76 void preloaded( bool newval_r )
77 { _preloaded = newval_r; }
78
79 protected:
81 virtual ManagedFile sourceProvidePackage( const PoolItem & pi ) const
82 {
83 if ( ! _packageProvider )
84 {
85 ZYPP_THROW( Exception("No package provider configured.") );
86 }
87
88 ManagedFile ret( _packageProvider( pi, /*cached only*/false ) );
89 if ( ret.value().empty() )
90 {
91 ZYPP_THROW( Exception("Package provider failed.") );
92 }
93
94 return ret;
95 }
96
99 {
100 if ( ! _packageProvider )
101 {
102 ZYPP_THROW( Exception("No package provider configured.") );
103 }
104
105 return _packageProvider( pi, /*cached only*/true );
106 }
107
108 private:
109 std::vector<sat::Solvable> _commitList;
112 };
114
116 inline std::ostream & operator<<( std::ostream & str, const CommitPackageCache::Impl & obj )
117 {
118 return str << "CommitPackageCache::Impl";
119 }
120
122 } // namespace target
125} // namespace zypp
127#endif // ZYPP_TARGET_COMMITPACKAGECACHEIMPL_H
reference value() const
Reference to the Tp object.
Integral type with defined initial value when default constructed.
Base class for Exception.
Definition Exception.h:147
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
Base for CommitPackageCache implementations (implements no chache).
const std::vector< sat::Solvable > & commitList() const
DefaultIntegral< bool, false > _preloaded
virtual ManagedFile sourceProvidePackage(const PoolItem &pi) const
Let the Source provide the package.
virtual ManagedFile get(const PoolItem &citem_r)
Provide the package.
virtual ManagedFile get_from_cache(const PoolItem &citem_r)
virtual ManagedFile sourceProvideCachedPackage(const PoolItem &pi) const
Let the Source provide an already cached package.
Impl(PackageProvider &&packageProvider_r)
std::ostream & operator<<(std::ostream &str, const CommitPackageCache::Impl &obj)
Stream output.
void setCommitList(std::vector< sat::Solvable > commitList_r)
CommitPackageCache::PackageProvider PackageProvider
function< ManagedFile(const PoolItem &, bool)> PackageProvider
Definition Arch.h:364
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:424