libzypp 17.31.23
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
21
23namespace zypp
24{
26 namespace target
27 {
28
30 //
31 // CLASS NAME : CommitPackageCache::Impl
32 //
40 {
41 public:
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
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;
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
reference value() const
Reference to the Tp object.
Definition: AutoDispose.h:147
Integral type with defined initial value when default constructed.
Base class for Exception.
Definition: Exception.h:146
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.
Impl(const PackageProvider &packageProvider_r)
virtual ManagedFile sourceProvideCachedPackage(const PoolItem &pi) const
Let the Source provide an already cached package.
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 &pi, bool fromCache_r)> PackageProvider
String related utilities and Regular expression matching.
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:2
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:428