libzypp
10.5.0
|
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 PoolItem & obj_r ) 00043 : _repo( obj_r->repository() ) 00044 , _mediaNr( obj_r->mediaNr() ) 00045 {} 00046 00047 explicit 00048 IMediaKey( const ResObject::constPtr & obj_r ) 00049 : _repo( obj_r->repository() ) 00050 , _mediaNr( obj_r->mediaNr() ) 00051 {} 00052 00053 IMediaKey( const Repository & repo, unsigned mediaNr_r ) 00054 : _repo( repo ) 00055 , _mediaNr( mediaNr_r ) 00056 {} 00057 00058 bool operator==( const IMediaKey & rhs ) const 00059 { return( _repo == rhs._repo && _mediaNr == rhs._mediaNr ); } 00060 00061 bool operator!=( const IMediaKey & rhs ) const 00062 { return ! operator==( rhs ); } 00063 00064 bool operator<( const IMediaKey & rhs ) const 00065 { 00066 return( _repo.id() < rhs._repo.id() 00067 || ( _repo.id() == rhs._repo.id() 00068 && _mediaNr < rhs._mediaNr ) ); 00069 } 00070 00071 Repository _repo; 00072 DefaultIntegral<unsigned,0> _mediaNr; 00073 }; 00075 00076 std::ostream & operator<<( std::ostream & str, const IMediaKey & obj ); 00077 00079 // 00080 // CLASS NAME : CommitPackageCacheReadAhead 00081 // 00083 class CommitPackageCacheReadAhead : public CommitPackageCache::Impl 00084 { 00085 typedef std::map<PoolItem,ManagedFile> CacheMap; 00086 00087 public: 00088 CommitPackageCacheReadAhead( const Pathname & rootDir_r, 00089 const PackageProvider & packageProvider_r ); 00090 00091 public: 00093 virtual ManagedFile get( const PoolItem & citem_r ); 00094 00095 private: 00097 bool onInteractiveMedia( const PoolItem & pi ) const; 00098 00099 private: 00105 void cacheLastInteractive( const PoolItem & citem_r ); 00106 00108 void doCacheLastInteractive( const PoolItem & citem_r ); 00109 00110 private: 00111 DefaultIntegral<unsigned,0> _dbgChanges; 00112 00113 IMediaKey _lastInteractive; 00114 00115 Pathname _rootDir; 00116 shared_ptr<filesystem::TmpDir> _cacheDir; 00117 CacheMap _cacheMap; 00118 }; 00120 00122 } // namespace target 00125 } // namespace zypp 00127 #endif // ZYPP_TARGET_COMMITPACKAGECACHEREADAHEAD_H