libzypp  13.10.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  protected:
69  virtual ManagedFile sourceProvidePackage( const PoolItem & pi ) const
70  {
71  if ( ! _packageProvider )
72  {
73  ZYPP_THROW( Exception("No package provider configured.") );
74  }
75 
76  ManagedFile ret( _packageProvider( pi, /*cached only*/false ) );
77  if ( ret.value().empty() )
78  {
79  ZYPP_THROW( Exception("Package provider failed.") );
80  }
81 
82  return ret;
83  }
84 
86  virtual ManagedFile sourceProvideCachedPackage( const PoolItem & pi ) const
87  {
88  if ( ! _packageProvider )
89  {
90  ZYPP_THROW( Exception("No package provider configured.") );
91  }
92 
93  return _packageProvider( pi, /*cached only*/true );
94  }
95 
96  private:
97  std::vector<sat::Solvable> _commitList;
99  };
101 
103  inline std::ostream & operator<<( std::ostream & str, const CommitPackageCache::Impl & obj )
104  {
105  return str << "CommitPackageCache::Impl";
106  }
107 
109  } // namespace target
112 } // namespace zypp
114 #endif // ZYPP_TARGET_COMMITPACKAGECACHEIMPL_H
Impl(const PackageProvider &packageProvider_r)
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
Definition: Exception.h:320
function< ManagedFile(const PoolItem &pi, bool fromCache_r)> PackageProvider
reference value() const
Reference to the _Tp object.
Definition: AutoDispose.h:133
std::vector< sat::Solvable > _commitList
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
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 ...
Definition: AutoDispose.h:92
Reference to a PoolItem connecting ResObject and ResStatus.
Definition: PoolItem.h:50
std::ostream & operator<<(std::ostream &str, const CommitPackageCache::Impl &obj)