libzypp: zypp/target/CommitPackageCacheImpl.h Source File

libzypp 17.38.6

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-core/base/Logger.h>
19#include <zypp-core/base/Exception.h>
20
21#include <zypp/target/CommitPackageCache.h>
22
24namespace zypp
25{
27 namespace target
28 {
29
31 //
32 // CLASS NAME : CommitPackageCache::Impl
33 //
40 class CommitPackageCache::Impl
41 {
42 public:
43 using PackageProvider = CommitPackageCache::PackageProvider;
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
93 virtual ManagedFile sourceProvideCachedPackage( const PoolItem & pi ) const
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;
105 PackageProvider _packageProvider;
106 DefaultIntegral<bool,false> _preloaded;
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
CommitPackageCache.h
Exception.h
ZYPP_THROW
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition Exception.h:459
Logger.h
zypp::AutoDispose::value
reference value() const
Reference to the Tp object.
Definition AutoDispose.h:138
zypp::DefaultIntegral
Integral type with defined initial value when default constructed.
Definition defaultintegral.h:42
zypp::Exception
Base class for Exception.
Definition Exception.h:153
zypp::PoolItem
Combining sat::Solvable and ResStatus.
Definition PoolItem.h:51
zypp::target::CommitPackageCache::Impl
Base for CommitPackageCache implementations (implements no chache).
Definition CommitPackageCacheImpl.h:41
zypp::target::CommitPackageCache::Impl::commitList
const std::vector< sat::Solvable > & commitList() const
Definition CommitPackageCacheImpl.h:65
zypp::target::CommitPackageCache::Impl::preloaded
void preloaded(bool newval_r)
Definition CommitPackageCacheImpl.h:71
zypp::target::CommitPackageCache::Impl::_preloaded
DefaultIntegral< bool, false > _preloaded
Definition CommitPackageCacheImpl.h:106
zypp::target::CommitPackageCache::Impl::sourceProvidePackage
virtual ManagedFile sourceProvidePackage(const PoolItem &pi) const
Let the Source provide the package.
Definition CommitPackageCacheImpl.h:76
zypp::target::CommitPackageCache::Impl::get
virtual ManagedFile get(const PoolItem &citem_r)
Provide the package.
Definition CommitPackageCacheImpl.h:57
zypp::target::CommitPackageCache::Impl::sourceProvideCachedPackage
virtual ManagedFile sourceProvideCachedPackage(const PoolItem &pi) const
Let the Source provide an already cached package.
Definition CommitPackageCacheImpl.h:93
zypp::target::CommitPackageCache::Impl::_commitList
std::vector< sat::Solvable > _commitList
Definition CommitPackageCacheImpl.h:104
zypp::target::CommitPackageCache::Impl::Impl
Impl(PackageProvider &&packageProvider_r)
Definition CommitPackageCacheImpl.h:46
zypp::target::CommitPackageCache::Impl::setCommitList
void setCommitList(std::vector< sat::Solvable > commitList_r)
Definition CommitPackageCacheImpl.h:62
zypp::target::CommitPackageCache::Impl::_packageProvider
PackageProvider _packageProvider
Definition CommitPackageCacheImpl.h:105
zypp::target::CommitPackageCache::Impl::PackageProvider
CommitPackageCache::PackageProvider PackageProvider
Definition CommitPackageCacheImpl.h:43
zypp::target::CommitPackageCache::Impl::preloaded
bool preloaded() const
Definition CommitPackageCacheImpl.h:68
zypp::target::CommitPackageCache::Impl::~Impl
virtual ~Impl()
Definition CommitPackageCacheImpl.h:50
zypp::target::CommitPackageCache::PackageProvider
function< ManagedFile(const PoolItem &, bool)> PackageProvider
Definition CommitPackageCache.h:63
std
Definition ansi.h:855
str
String related utilities and Regular expression matching.
zypp::target
Definition KeyRing.h:325
zypp::target::operator<<
std::ostream & operator<<(std::ostream &str, const CommitPackageCache &obj)
relates: CommitPackageCache Stream output
Definition CommitPackageCache.cc:155
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition CodePitfalls.doc:2
zypp::ManagedFile
AutoDispose< const Pathname > ManagedFile
A Pathname plus associated cleanup code to be executed when path is no longer needed.
Definition ManagedFile.h:27