libzypp  15.28.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 
17 #include "zypp/base/Logger.h"
18 #include "zypp/base/Exception.h"
19 
21 
23 namespace zypp
24 {
25  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 
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;
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
Impl(const PackageProvider &packageProvider_r)
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:321
function< ManagedFile(const PoolItem &pi, bool fromCache_r)> PackageProvider
virtual ManagedFile sourceProvidePackage(const PoolItem &pi) const
Let the Source provide the package.
CommitPackageCache::PackageProvider PackageProvider
void setCommitList(std::vector< sat::Solvable > commitList_r)
const std::vector< sat::Solvable > & commitList() const
reference value() const
Reference to the Tp object.
Definition: AutoDispose.h:133
DefaultIntegral< bool, false > _preloaded
Base for CommitPackageCache implementations (implements no chache).
virtual ManagedFile sourceProvideCachedPackage(const PoolItem &pi) const
Let the Source provide an already cached package.
Base class for Exception.
Definition: Exception.h:143
Reference counted access to a Tp object calling a custom Dispose function when the last AutoDispose h...
Definition: AutoDispose.h:92
Combining sat::Solvable and ResStatus.
Definition: PoolItem.h:50
std::ostream & operator<<(std::ostream &str, const CommitPackageCache::Impl &obj)