]>
Commit | Line | Data |
---|---|---|
2d11135a AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
0077d829 | 3 | // $Id: cachefile.h,v 1.5 2002/04/27 04:28:04 jgg Exp $ |
2d11135a AL |
4 | /* ###################################################################### |
5 | ||
6 | CacheFile - Simple wrapper class for opening, generating and whatnot | |
7 | ||
8 | This class implements a simple 2 line mechanism to open various sorts | |
9 | of caches. It can operate as root, as not root, show progress and so on, | |
10 | it transparently handles everything necessary. | |
11 | ||
b2e465d6 AL |
12 | This means it can rebuild caches from the source list and instantiates |
13 | and prepares the standard policy mechanism. | |
14 | ||
2d11135a AL |
15 | ##################################################################### */ |
16 | /*}}}*/ | |
17 | #ifndef PKGLIB_CACHEFILE_H | |
18 | #define PKGLIB_CACHEFILE_H | |
19 | ||
2d11135a AL |
20 | |
21 | #include <apt-pkg/depcache.h> | |
89b70b5a MV |
22 | #include <apt-pkg/acquire.h> |
23 | #include <apt-pkg/sourcelist.h> | |
2d11135a | 24 | |
b2e465d6 | 25 | class pkgPolicy; |
3f8621c5 | 26 | class pkgSourceList; |
2d11135a AL |
27 | class pkgCacheFile |
28 | { | |
29 | protected: | |
30 | ||
31 | MMap *Map; | |
b2e465d6 AL |
32 | pkgCache *Cache; |
33 | pkgDepCache *DCache; | |
2e5f4e45 | 34 | pkgPolicy *Policy; |
3f8621c5 | 35 | pkgSourceList *SrcList; |
2e5f4e45 | 36 | |
2d11135a | 37 | public: |
b2e465d6 | 38 | |
2d11135a | 39 | // We look pretty much exactly like a pointer to a dep cache |
b2e465d6 AL |
40 | inline operator pkgCache &() {return *Cache;}; |
41 | inline operator pkgCache *() {return Cache;}; | |
42 | inline operator pkgDepCache &() {return *DCache;}; | |
43 | inline operator pkgDepCache *() {return DCache;}; | |
3f8621c5 DK |
44 | inline operator pkgPolicy &() {return *Policy;}; |
45 | inline operator pkgPolicy *() {return Policy;}; | |
46 | inline operator pkgSourceList &() {return *SrcList;}; | |
47 | inline operator pkgSourceList *() {return SrcList;}; | |
b2e465d6 AL |
48 | inline pkgDepCache *operator ->() {return DCache;}; |
49 | inline pkgDepCache &operator *() {return *DCache;}; | |
50 | inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) {return (*DCache)[I];}; | |
51 | inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];}; | |
099a4759 | 52 | |
2e5f4e45 DK |
53 | bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true); |
54 | __deprecated bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); }; | |
3f8621c5 | 55 | bool BuildSourceList(OpProgress *Progress = NULL); |
2e5f4e45 DK |
56 | bool BuildPolicy(OpProgress *Progress = NULL); |
57 | bool BuildDepCache(OpProgress *Progress = NULL); | |
58 | bool Open(OpProgress *Progress = NULL, bool WithLock = true); | |
3f8621c5 | 59 | inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); }; |
2e5f4e45 | 60 | __deprecated bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); }; |
b2e465d6 | 61 | void Close(); |
3f8621c5 DK |
62 | |
63 | inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; }; | |
64 | inline pkgDepCache* GetDepCache() { BuildDepCache(); return DCache; }; | |
65 | inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; }; | |
66 | inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; }; | |
67 | ||
2d11135a | 68 | pkgCacheFile(); |
2e5f4e45 | 69 | virtual ~pkgCacheFile(); |
2d11135a AL |
70 | }; |
71 | ||
72 | #endif |