apt
1.5
|
00001 // -*- mode: cpp; mode: fold -*- 00002 // Description /*{{{*/ 00003 // $Id: cachefile.h,v 1.5 2002/04/27 04:28:04 jgg Exp $ 00004 /* ###################################################################### 00005 00006 CacheFile - Simple wrapper class for opening, generating and whatnot 00007 00008 This class implements a simple 2 line mechanism to open various sorts 00009 of caches. It can operate as root, as not root, show progress and so on, 00010 it transparently handles everything necessary. 00011 00012 This means it can rebuild caches from the source list and instantiates 00013 and prepares the standard policy mechanism. 00014 00015 ##################################################################### */ 00016 /*}}}*/ 00017 #ifndef PKGLIB_CACHEFILE_H 00018 #define PKGLIB_CACHEFILE_H 00019 00020 #include <apt-pkg/depcache.h> 00021 #include <apt-pkg/macros.h> 00022 00023 #ifndef APT_8_CLEANER_HEADERS 00024 #include <apt-pkg/acquire.h> 00025 #include <apt-pkg/policy.h> 00026 #include <apt-pkg/sourcelist.h> 00027 #endif 00028 00029 class pkgPolicy; 00030 class pkgSourceList; 00031 class OpProgress; 00032 00033 class pkgCacheFile 00034 { 00036 void *d; 00037 00038 protected: 00039 00040 MMap *Map; 00041 pkgCache *Cache; 00042 pkgDepCache *DCache; 00043 pkgSourceList *SrcList; 00044 00045 public: 00046 pkgPolicy *Policy; 00047 00048 // We look pretty much exactly like a pointer to a dep cache 00049 inline operator pkgCache &() {return *Cache;}; 00050 inline operator pkgCache *() {return Cache;}; 00051 inline operator pkgDepCache &() {return *DCache;}; 00052 inline operator pkgDepCache *() {return DCache;}; 00053 inline operator pkgPolicy &() {return *Policy;}; 00054 inline operator pkgPolicy *() {return Policy;}; 00055 inline operator pkgSourceList &() {return *SrcList;}; 00056 inline operator pkgSourceList *() {return SrcList;}; 00057 inline pkgDepCache *operator ->() {return DCache;}; 00058 inline pkgDepCache &operator *() {return *DCache;}; 00059 inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) {return (*DCache)[I];}; 00060 inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];}; 00061 00062 bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true); 00063 __deprecated bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); }; 00064 bool BuildSourceList(OpProgress *Progress = NULL); 00065 bool BuildPolicy(OpProgress *Progress = NULL); 00066 bool BuildDepCache(OpProgress *Progress = NULL); 00067 bool Open(OpProgress *Progress = NULL, bool WithLock = true); 00068 inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); }; 00069 __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); }; 00070 static void RemoveCaches(); 00071 void Close(); 00072 00073 inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; }; 00074 inline pkgDepCache* GetDepCache() { BuildDepCache(); return DCache; }; 00075 inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; }; 00076 inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; }; 00077 00078 inline bool IsPkgCacheBuilt() const { return (Cache != NULL); }; 00079 inline bool IsDepCacheBuilt() const { return (DCache != NULL); }; 00080 inline bool IsPolicyBuilt() const { return (Policy != NULL); }; 00081 inline bool IsSrcListBuilt() const { return (SrcList != NULL); }; 00082 00083 pkgCacheFile(); 00084 virtual ~pkgCacheFile(); 00085 }; 00086 00087 #endif