libzypp  17.35.19
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 
24 namespace zypp
25 {
26  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 
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;
107  };
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
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:424
virtual ManagedFile sourceProvideCachedPackage(const PoolItem &pi) const
Let the Source provide an already cached package.
String related utilities and Regular expression matching.
Definition: Arch.h:363
const std::vector< sat::Solvable > & commitList() const
Impl(PackageProvider &&packageProvider_r)
void setCommitList(std::vector< sat::Solvable > commitList_r)
DefaultIntegral< bool, false > _preloaded
Base for CommitPackageCache implementations (implements no chache).
Base class for Exception.
Definition: Exception.h:146
reference value() const
Reference to the Tp object.
Definition: AutoDispose.h:138
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
CommitPackageCache::PackageProvider PackageProvider
function< ManagedFile(const PoolItem &, bool)> PackageProvider
Easy-to use interface to the ZYPP dependency resolver.
Definition: Application.cc:19
virtual ManagedFile sourceProvidePackage(const PoolItem &pi) const
Let the Source provide the package.
std::ostream & operator<<(std::ostream &str, const CommitPackageCache::Impl &obj)