1 /*---------------------------------------------------------------------\
3 | |__ / \ / / . \ . \ |
8 \---------------------------------------------------------------------*/
9 /** \file zypp/target/CommitPackageCache.h
12 #ifndef ZYPP_TARGET_COMMITPACKAGECACHE_H
13 #define ZYPP_TARGET_COMMITPACKAGECACHE_H
17 #include "zypp/base/PtrTypes.h"
18 #include "zypp/base/Function.h"
20 #include "zypp/PoolItem.h"
21 #include "zypp/Pathname.h"
22 #include "zypp/ManagedFile.h"
24 ///////////////////////////////////////////////////////////////////
26 { /////////////////////////////////////////////////////////////////
27 ///////////////////////////////////////////////////////////////////
29 { /////////////////////////////////////////////////////////////////
31 ///////////////////////////////////////////////////////////////////
32 /// \class RepoProvidePackage
33 /// \short Default PackageProvider for \ref CommitPackageCache
35 /// \p pool_r \ref ResPool used to get candidates
36 /// \p pi item to be commited
37 ///////////////////////////////////////////////////////////////////
38 class RepoProvidePackage
42 ~RepoProvidePackage();
44 /** Provide package optionally fron cache only. */
45 ManagedFile operator()( const PoolItem & pi, bool fromCache_r );
49 RW_pointer<Impl> _impl;
52 ///////////////////////////////////////////////////////////////////
54 // CLASS NAME : CommitPackageCache
56 /** Target::commit helper optimizing package provision.
58 class CommitPackageCache
60 friend std::ostream & operator<<( std::ostream & str, const CommitPackageCache & obj );
63 typedef function<ManagedFile( const PoolItem & pi, bool fromCache_r )> PackageProvider;
67 CommitPackageCache( const Pathname & rootDir_r,
68 const PackageProvider & packageProvider_r = RepoProvidePackage() );
71 ~CommitPackageCache();
74 /** Download(commit) sequence of solvables to compute read ahead. */
75 void setCommitList( std::vector<sat::Solvable> commitList_r );
77 template <class _Iterator>
78 void setCommitList( _Iterator begin_r, _Iterator end_r )
79 { setCommitList( std::vector<sat::Solvable>( begin_r, end_r ) ); }
81 /** Provide a package. */
82 ManagedFile get( const PoolItem & citem_r );
84 ManagedFile get( sat::Solvable citem_r )
85 { return get( PoolItem(citem_r) ); }
87 /** Whether preloaded hint is set.
88 * If preloaded the cache tries to avoid trigering the infoInCache CB,
89 * based on the assumption this was already done when preloading the cache.
91 bool preloaded() const;
92 /** Set preloaded hint. */
93 void preloaded( bool newval_r );
96 /** Implementation. */
98 /** Ctor taking an implementation. */
99 explicit CommitPackageCache( Impl * pimpl_r );
101 /** Pointer to implementation. */
102 RW_pointer<Impl> _pimpl;
104 ///////////////////////////////////////////////////////////////////
106 /** \relates CommitPackageCache Stream output */
107 std::ostream & operator<<( std::ostream & str, const CommitPackageCache & obj );
109 /////////////////////////////////////////////////////////////////
110 } // namespace target
111 ///////////////////////////////////////////////////////////////////
112 /////////////////////////////////////////////////////////////////
114 ///////////////////////////////////////////////////////////////////
115 #endif // ZYPP_TARGET_COMMITPACKAGECACHE_H