//
///////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CommitPackageCache::CommitPackageCache
- // METHOD TYPE : Ctor
- //
CommitPackageCache::CommitPackageCache( Impl * pimpl_r )
: _pimpl( pimpl_r )
{
assert( _pimpl );
}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CommitPackageCache::CommitPackageCache
- // METHOD TYPE : Ctor
- //
- CommitPackageCache::CommitPackageCache( const_iterator begin_r,
- const_iterator end_r,
- const Pathname & rootDir_r,
+ CommitPackageCache::CommitPackageCache( const Pathname & rootDir_r,
const PackageProvider & packageProvider_r )
{
if ( getenv("ZYPP_COMMIT_NO_PACKAGE_CACHE") )
}
else
{
- _pimpl.reset( new CommitPackageCacheReadAhead( begin_r, end_r,
- rootDir_r, packageProvider_r ) );
+ _pimpl.reset( new CommitPackageCacheReadAhead( rootDir_r, packageProvider_r ) );
}
assert( _pimpl );
}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CommitPackageCache::~CommitPackageCache
- // METHOD TYPE : Dtor
- //
CommitPackageCache::~CommitPackageCache()
{}
- ///////////////////////////////////////////////////////////////////
- //
- // METHOD NAME : CommitPackageCache::~CommitPackageCache
- // METHOD TYPE : Dtor
- //
- ManagedFile CommitPackageCache::get( const_iterator citem_r )
+ void CommitPackageCache::setCommitList( std::vector<sat::Solvable> commitList_r )
+ {
+ _pimpl->setCommitList( commitList_r );
+ }
+
+ ManagedFile CommitPackageCache::get( const PoolItem & citem_r )
{ return _pimpl->get( citem_r ); }
/******************************************************************
#define ZYPP_TARGET_COMMITPACKAGECACHE_H
#include <iosfwd>
-#include <list>
#include "zypp/base/PtrTypes.h"
#include "zypp/base/Function.h"
friend std::ostream & operator<<( std::ostream & str, const CommitPackageCache & obj );
public:
- typedef std::list<PoolItem>::const_iterator const_iterator;
typedef function<ManagedFile( const PoolItem & pi )> PackageProvider;
public:
/** Ctor */
- CommitPackageCache( const_iterator begin_r,
- const_iterator end_r,
- const Pathname & rootDir_r,
+ CommitPackageCache( const Pathname & rootDir_r,
const PackageProvider & packageProvider_r );
/** Dtor */
~CommitPackageCache();
public:
+ /** Download(commit) sequence of solvables to compute read ahead. */
+ void setCommitList( std::vector<sat::Solvable> commitList_r );
+ /** \overload */
+ template <class _Iterator>
+ void setCommitList( _Iterator begin_r, _Iterator end_r )
+ { setCommitList( std::vector<sat::Solvable>( begin_r, end_r ) ); }
+
/** Provide a package. */
- ManagedFile get( const_iterator citem_r );
+ ManagedFile get( const PoolItem & citem_r );
public:
/** Implementation. */
class CommitPackageCache::Impl
{
public:
- typedef CommitPackageCache::const_iterator const_iterator;
typedef CommitPackageCache::PackageProvider PackageProvider;
public:
/** Provide the package.
* Derived classes overload this.
*/
- virtual ManagedFile get( const_iterator citem_r )
+ virtual ManagedFile get( const PoolItem & citem_r )
{
- return sourceProvidePackage( *citem_r );
+ return sourceProvidePackage( citem_r );
}
+ void setCommitList( std::vector<sat::Solvable> commitList_r )
+ { _commitList = commitList_r; }
+
protected:
/** Let the Source provide the package. */
- ManagedFile sourceProvidePackage( const PoolItem & pi ) const
+ virtual ManagedFile sourceProvidePackage( const PoolItem & pi ) const
{
if ( ! _packageProvider )
{
return ret;
}
+ protected:
+ std::vector<sat::Solvable> _commitList;
+
private:
PackageProvider _packageProvider;
};
// METHOD NAME : CommitPackageCacheReadAhead::CommitPackageCacheReadAhead
// METHOD TYPE : Ctor
//
- CommitPackageCacheReadAhead::CommitPackageCacheReadAhead( const_iterator begin_r,
- const_iterator end_r,
- const Pathname & rootDir_r,
+ CommitPackageCacheReadAhead::CommitPackageCacheReadAhead( const Pathname & rootDir_r,
const PackageProvider & packageProvider_r )
: CommitPackageCache::Impl( packageProvider_r )
- , _commitListEnd( end_r )
, _rootDir( rootDir_r )
{}
// METHOD NAME : CommitPackageCacheReadAhead::cacheLastInteractive
// METHOD TYPE : void
//
- void CommitPackageCacheReadAhead::cacheLastInteractive( const_iterator citem_r )
+ void CommitPackageCacheReadAhead::cacheLastInteractive( const PoolItem & citem_r )
{
// Fill cache errors are never proagated.
try
// METHOD NAME : CommitPackageCacheReadAhead::doCacheLastInteractive
// METHOD TYPE : void
//
- void CommitPackageCacheReadAhead::doCacheLastInteractive( const_iterator citem_r )
+ void CommitPackageCacheReadAhead::doCacheLastInteractive( const PoolItem & citem_r )
{
CacheMap addToCache;
ByteCount addSize;
// Collect all remaining packages to install from
// _lastInteractive media. (just the PoolItem data)
- for ( const_iterator it = citem_r; it != _commitListEnd; ++it )
+ for_( it,_commitList.begin(), _commitList.end() )
{
- if ( IMediaKey( *it ) == _lastInteractive
- && isKind<Package>(it->resolvable())
- && it->status().isToBeInstalled() )
+ PoolItem pi( *it );
+ if ( IMediaKey( pi ) == _lastInteractive
+ && isKind<Package>(pi.resolvable())
+ && pi.status().isToBeInstalled() )
{
- if ( _cacheMap.find( *it ) == _cacheMap.end() )
+ if ( _cacheMap.find( pi ) == _cacheMap.end() )
{
- addToCache[*it];
- addSize += it->resolvable()->downloadSize();
+ addToCache[pi];
+ addSize += pi->downloadSize();
}
}
}
// METHOD NAME : CommitPackageCacheReadAhead::get
// METHOD TYPE : ManagedFile
//
- ManagedFile CommitPackageCacheReadAhead::get( const_iterator citem_r )
+ ManagedFile CommitPackageCacheReadAhead::get( const PoolItem & citem_r )
{
// Non CD/DVD media provide their packages without cache.
- if ( ! onInteractiveMedia( *citem_r ) )
+ if ( ! onInteractiveMedia( citem_r ) )
{
- return sourceProvidePackage( *citem_r );
+ return sourceProvidePackage( citem_r );
}
// Check whether it's cached.
- CacheMap::iterator it = _cacheMap.find( *citem_r );
+ CacheMap::iterator it = _cacheMap.find( citem_r );
if ( it != _cacheMap.end() )
{
// ManagedFile delivered to the application is removed
// In case we have to change the media to provide the requested
// file, try to cache files from the current media, that are
// required later.
- IMediaKey current( *citem_r );
+ IMediaKey current( citem_r );
if ( current != _lastInteractive )
{
if ( _lastInteractive != IMediaKey() )
}
// Provide and return the file from media.
- return sourceProvidePackage( *citem_r );
+ return sourceProvidePackage( citem_r );
}
{}
explicit
+ IMediaKey( const PoolItem & obj_r )
+ : _repo( obj_r->repository() )
+ , _mediaNr( obj_r->mediaNr() )
+ {}
+
+ explicit
IMediaKey( const ResObject::constPtr & obj_r )
: _repo( obj_r->repository() )
, _mediaNr( obj_r->mediaNr() )
typedef std::map<PoolItem,ManagedFile> CacheMap;
public:
- CommitPackageCacheReadAhead( const_iterator begin_r,
- const_iterator end_r,
- const Pathname & rootDir_r,
+ CommitPackageCacheReadAhead( const Pathname & rootDir_r,
const PackageProvider & packageProvider_r );
public:
/** Provide the package. Either from Source or from cache. */
- virtual ManagedFile get( const_iterator citem_r );
+ virtual ManagedFile get( const PoolItem & citem_r );
private:
/** Return whether \a pi is located on a CD/DVD */
* Performs the read ahead of packages trying to avoid the necessity
* of switching back to the current media later.
*/
- void cacheLastInteractive( const_iterator citem_r );
+ void cacheLastInteractive( const PoolItem & citem_r );
/** cacheLastInteractive helper . */
- void doCacheLastInteractive( const_iterator citem_r );
+ void doCacheLastInteractive( const PoolItem & citem_r );
private:
DefaultIntegral<unsigned,0> _dbgChanges;
- const_iterator _commitListEnd;
- IMediaKey _lastInteractive;
+ IMediaKey _lastInteractive;
Pathname _rootDir;
shared_ptr<filesystem::TmpDir> _cacheDir;