CommitPackageCacheReadAhead.h

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                          ____ _   __ __ ___                          |
00003 |                         |__  / \ / / . \ . \                         |
00004 |                           / / \ V /|  _/  _/                         |
00005 |                          / /__ | | | | | |                           |
00006 |                         /_____||_| |_| |_|                           |
00007 |                                                                      |
00008 \---------------------------------------------------------------------*/
00012 #ifndef ZYPP_TARGET_COMMITPACKAGECACHEREADAHEAD_H
00013 #define ZYPP_TARGET_COMMITPACKAGECACHEREADAHEAD_H
00014 
00015 #include <map>
00016 
00017 #include "zypp/base/Logger.h"
00018 #include "zypp/base/Exception.h"
00019 #include "zypp/base/DefaultIntegral.h"
00020 #include "zypp/Repository.h"
00021 #include "zypp/TmpPath.h"
00022 #include "zypp/target/CommitPackageCacheImpl.h"
00023 
00025 namespace zypp
00026 { 
00027 
00028   namespace target
00029   { 
00030 
00032     //
00033     //  CLASS NAME : IMediaKey
00034     //
00036     struct IMediaKey
00037     {
00038       IMediaKey()
00039       {}
00040 
00041       explicit
00042       IMediaKey( const ResObject::constPtr & obj_r )
00043       : _repo( obj_r->repository() )
00044       , _mediaNr( obj_r->mediaNr() )
00045       {}
00046 
00047       IMediaKey( const Repository & repo, unsigned mediaNr_r )
00048       : _repo( repo )
00049       , _mediaNr( mediaNr_r )
00050       {}
00051 
00052       bool operator==( const IMediaKey & rhs ) const
00053       { return( _repo == rhs._repo && _mediaNr == rhs._mediaNr ); }
00054 
00055       bool operator!=( const IMediaKey & rhs ) const
00056       { return ! operator==( rhs ); }
00057 
00058       bool operator<( const IMediaKey & rhs ) const
00059       {
00060         return( _repo.id() < rhs._repo.id()
00061                 || ( _repo.id() == rhs._repo.id()
00062                      && _mediaNr < rhs._mediaNr ) );
00063       }
00064 
00065       Repository                  _repo;
00066       DefaultIntegral<unsigned,0> _mediaNr;
00067     };
00069 
00070     std::ostream & operator<<( std::ostream & str, const IMediaKey & obj );
00071 
00073     //
00074     //  CLASS NAME : CommitPackageCacheReadAhead
00075     //
00077     class CommitPackageCacheReadAhead : public CommitPackageCache::Impl
00078     {
00079       typedef std::map<PoolItem,ManagedFile>     CacheMap;
00080 
00081     public:
00082       CommitPackageCacheReadAhead( const_iterator          begin_r,
00083                                    const_iterator          end_r,
00084                                    const Pathname &        rootDir_r,
00085                                    const PackageProvider & packageProvider_r );
00086 
00087     public:
00089       virtual ManagedFile get( const_iterator citem_r );
00090 
00091     private:
00093       bool onInteractiveMedia( const PoolItem & pi ) const;
00094 
00095     private:
00101       void cacheLastInteractive( const_iterator citem_r );
00102 
00104       void doCacheLastInteractive( const_iterator citem_r );
00105 
00106     private:
00107       DefaultIntegral<unsigned,0> _dbgChanges;
00108 
00109       const_iterator       _commitListEnd;
00110       IMediaKey            _lastInteractive;
00111 
00112       Pathname                       _rootDir;
00113       shared_ptr<filesystem::TmpDir> _cacheDir;
00114       CacheMap                       _cacheMap;
00115     };
00117 
00119   } // namespace target
00122 } // namespace zypp
00124 #endif // ZYPP_TARGET_COMMITPACKAGECACHEREADAHEAD_H

doxygen