libzypp 17.37.17
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 void setCommitList( std::vector<sat::Solvable> commitList_r )
63 { _commitList = std::move(commitList_r); }
64
65 const std::vector<sat::Solvable> & commitList() const
66 { return _commitList; }
67
68 bool preloaded() const
69 { return _preloaded; }
70
71 void preloaded( bool newval_r )
72 { _preloaded = newval_r; }
73
74 protected:
76 virtual ManagedFile sourceProvidePackage( const PoolItem & pi ) const
77 {
78 if ( ! _packageProvider )
79 {
80 ZYPP_THROW( Exception("No package provider configured.") );
81 }
82
83 ManagedFile ret( _packageProvider( pi, /*cached only*/false ) );
84 if ( ret.value().empty() )
85 {
86 ZYPP_THROW( Exception("Package provider failed.") );
87 }
88
89 return ret;
90 }
91
94 {
95 if ( ! _packageProvider )
96 {
97 ZYPP_THROW( Exception("No package provider configured.") );
98 }
99
100 return _packageProvider( pi, /*cached only*/true );
101 }
102
103 private:
104 std::vector<sat::Solvable> _commitList;
107 };
108
109
111 inline std::ostream & operator<<( std::ostream & str, const CommitPackageCache::Impl & obj )
112 {
113 return str << "CommitPackageCache::Impl";
114 }
115
117 } // namespace target
120} // namespace zypp
122#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:153
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 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.
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459