|
apt @VERSION@
|
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 class pkgPolicy; 00024 class pkgSourceList; 00025 class OpProgress; 00026 00027 class pkgCacheFile 00028 { 00030 void *d; 00031 00032 protected: 00033 00034 MMap *Map; 00035 pkgCache *Cache; 00036 pkgDepCache *DCache; 00037 pkgSourceList *SrcList; 00038 00039 public: 00040 pkgPolicy *Policy; 00041 00042 // We look pretty much exactly like a pointer to a dep cache 00043 inline operator pkgCache &() {return *Cache;}; 00044 inline operator pkgCache *() {return Cache;}; 00045 inline operator pkgDepCache &() {return *DCache;}; 00046 inline operator pkgDepCache *() {return DCache;}; 00047 inline operator pkgPolicy &() {return *Policy;}; 00048 inline operator pkgPolicy *() {return Policy;}; 00049 inline operator pkgSourceList &() {return *SrcList;}; 00050 inline operator pkgSourceList *() {return SrcList;}; 00051 inline pkgDepCache *operator ->() {return DCache;}; 00052 inline pkgDepCache &operator *() {return *DCache;}; 00053 inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) {return (*DCache)[I];}; 00054 inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];}; 00055 00056 bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true); 00057 __deprecated bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); }; 00058 bool BuildSourceList(OpProgress *Progress = NULL); 00059 bool BuildPolicy(OpProgress *Progress = NULL); 00060 bool BuildDepCache(OpProgress *Progress = NULL); 00061 bool Open(OpProgress *Progress = NULL, bool WithLock = true); 00062 inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); }; 00063 __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); }; 00064 static void RemoveCaches(); 00065 void Close(); 00066 00067 inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; }; 00068 inline pkgDepCache* GetDepCache() { BuildDepCache(); return DCache; }; 00069 inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; }; 00070 inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; }; 00071 00072 inline bool IsPkgCacheBuilt() const { return (Cache != NULL); }; 00073 inline bool IsDepCacheBuilt() const { return (DCache != NULL); }; 00074 inline bool IsPolicyBuilt() const { return (Policy != NULL); }; 00075 inline bool IsSrcListBuilt() const { return (SrcList != NULL); }; 00076 00077 pkgCacheFile(); 00078 virtual ~pkgCacheFile(); 00079 }; 00080 00081 #endif
1.7.4