libzypp: zypp/target/CommitPackageCacheImpl.h Source File

libzypp 17.25.10

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
17 #include <zypp/base/Logger.h>
18 #include <zypp/base/Exception.h>
19
20 #include <zypp/target/CommitPackageCache.h>
21
23 namespace zypp
24 {
26 namespace target
27 {
28
30 //
31 // CLASS NAME : CommitPackageCache::Impl
32 //
39 class CommitPackageCache::Impl
40 {
41 public:
42 typedef CommitPackageCache::PackageProvider PackageProvider;
43
44 public:
45 Impl( const PackageProvider & packageProvider_r )
46 : _packageProvider( packageProvider_r )
47 {}
48
49 virtual ~Impl()
50 {}
51
52 public:
56 virtual ManagedFile get( const PoolItem & citem_r )
57 {
58 return sourceProvidePackage( citem_r );
59 }
60
61 void setCommitList( std::vector<sat::Solvable> commitList_r )
62 { _commitList = commitList_r; }
63
64 const std::vector<sat::Solvable> & commitList() const
65 { return _commitList; }
66
67 bool preloaded() const
68 { return _preloaded; }
69
70 void preloaded( bool newval_r )
71 { _preloaded = newval_r; }
72
73 protected:
75 virtual ManagedFile sourceProvidePackage( const PoolItem & pi ) const
76 {
77 if ( ! _packageProvider )
78 {
79 ZYPP_THROW( Exception("No package provider configured.") );
80 }
81
82 ManagedFile ret( _packageProvider( pi, /*cached only*/false ) );
83 if ( ret.value().empty() )
84 {
85 ZYPP_THROW( Exception("Package provider failed.") );
86 }
87
88 return ret;
89 }
90
92 virtual ManagedFile sourceProvideCachedPackage( const PoolItem & pi ) const
93 {
94 if ( ! _packageProvider )
95 {
96 ZYPP_THROW( Exception("No package provider configured.") );
97 }
98
99 return _packageProvider( pi, /*cached only*/true );
100 }
101
102 private:
103 std::vector<sat::Solvable> _commitList;
104 PackageProvider _packageProvider;
105 DefaultIntegral<bool,false> _preloaded;
106 };
108
110 inline std::ostream & operator<<( std::ostream & str, const CommitPackageCache::Impl & obj )
111 {
112 return str << "CommitPackageCache::Impl";
113 }
114
116 } // namespace target
119 } // namespace zypp
121 #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:392
Logger.h
zypp::AutoDispose
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:93
zypp::AutoDispose::value
reference value() const
Reference to the Tp object.
Definition: AutoDispose.h:133
zypp::DefaultIntegral
Integral type with defined initial value when default constructed.
Definition: DefaultIntegral.h:42
zypp::Exception
Base class for Exception.
Definition: Exception.h:146
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:40
zypp::target::CommitPackageCache::Impl::preloaded
void preloaded(bool newval_r)
Definition: CommitPackageCacheImpl.h:70
zypp::target::CommitPackageCache::Impl::_preloaded
DefaultIntegral< bool, false > _preloaded
Definition: CommitPackageCacheImpl.h:105
zypp::target::CommitPackageCache::Impl::sourceProvidePackage
virtual ManagedFile sourceProvidePackage(const PoolItem &pi) const
Let the Source provide the package.
Definition: CommitPackageCacheImpl.h:75
zypp::target::CommitPackageCache::Impl::get
virtual ManagedFile get(const PoolItem &citem_r)
Provide the package.
Definition: CommitPackageCacheImpl.h:56
zypp::target::CommitPackageCache::Impl::Impl
Impl(const PackageProvider &packageProvider_r)
Definition: CommitPackageCacheImpl.h:45
zypp::target::CommitPackageCache::Impl::sourceProvideCachedPackage
virtual ManagedFile sourceProvideCachedPackage(const PoolItem &pi) const
Let the Source provide an already cached package.
Definition: CommitPackageCacheImpl.h:92
zypp::target::CommitPackageCache::Impl::_commitList
std::vector< sat::Solvable > _commitList
Definition: CommitPackageCacheImpl.h:103
zypp::target::CommitPackageCache::Impl::operator<<
std::ostream & operator<<(std::ostream &str, const CommitPackageCache::Impl &obj)
Stream output.
Definition: CommitPackageCacheImpl.h:110
zypp::target::CommitPackageCache::Impl::setCommitList
void setCommitList(std::vector< sat::Solvable > commitList_r)
Definition: CommitPackageCacheImpl.h:61
zypp::target::CommitPackageCache::Impl::_packageProvider
PackageProvider _packageProvider
Definition: CommitPackageCacheImpl.h:104
zypp::target::CommitPackageCache::Impl::commitList
const std::vector< sat::Solvable > & commitList() const
Definition: CommitPackageCacheImpl.h:64
zypp::target::CommitPackageCache::Impl::PackageProvider
CommitPackageCache::PackageProvider PackageProvider
Definition: CommitPackageCacheImpl.h:42
zypp::target::CommitPackageCache::Impl::preloaded
bool preloaded() const
Definition: CommitPackageCacheImpl.h:67
zypp::target::CommitPackageCache::Impl::~Impl
virtual ~Impl()
Definition: CommitPackageCacheImpl.h:49
zypp::target::CommitPackageCache::PackageProvider
function< ManagedFile(const PoolItem &pi, bool fromCache_r)> PackageProvider
Definition: CommitPackageCache.h:63
str
String related utilities and Regular expression matching.
zypp
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2