]> git.saurik.com Git - apt.git/blob - apt-pkg/cachefile.h
move ByHash into its own function
[apt.git] / apt-pkg / cachefile.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: cachefile.h,v 1.5 2002/04/27 04:28:04 jgg Exp $
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
12 This means it can rebuild caches from the source list and instantiates
13 and prepares the standard policy mechanism.
14
15 ##################################################################### */
16 /*}}}*/
17 #ifndef PKGLIB_CACHEFILE_H
18 #define PKGLIB_CACHEFILE_H
19
20 #include <stddef.h>
21
22 #include <apt-pkg/depcache.h>
23 #include <apt-pkg/macros.h>
24 #include <apt-pkg/pkgcache.h>
25 #include <apt-pkg/cacheiterators.h>
26
27 #ifndef APT_8_CLEANER_HEADERS
28 #include <apt-pkg/acquire.h>
29 #include <apt-pkg/policy.h>
30 #include <apt-pkg/sourcelist.h>
31 #endif
32
33 class MMap;
34 class pkgPolicy;
35 class pkgSourceList;
36 class OpProgress;
37
38 class pkgCacheFile
39 {
40 /** \brief dpointer placeholder (for later in case we need it) */
41 void *d;
42
43 protected:
44
45 MMap *Map;
46 pkgCache *Cache;
47 pkgDepCache *DCache;
48 pkgSourceList *SrcList;
49
50 public:
51 pkgPolicy *Policy;
52
53 // We look pretty much exactly like a pointer to a dep cache
54 inline operator pkgCache &() {return *Cache;};
55 inline operator pkgCache *() {return Cache;};
56 inline operator pkgDepCache &() {return *DCache;};
57 inline operator pkgDepCache *() {return DCache;};
58 inline operator pkgPolicy &() {return *Policy;};
59 inline operator pkgPolicy *() {return Policy;};
60 inline operator pkgSourceList &() {return *SrcList;};
61 inline operator pkgSourceList *() {return SrcList;};
62 inline pkgDepCache *operator ->() {return DCache;};
63 inline pkgDepCache &operator *() {return *DCache;};
64 inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) {return (*DCache)[I];};
65 inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];};
66
67 bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true);
68 APT_DEPRECATED bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); };
69 bool BuildSourceList(OpProgress *Progress = NULL);
70 bool BuildPolicy(OpProgress *Progress = NULL);
71 bool BuildDepCache(OpProgress *Progress = NULL);
72 bool Open(OpProgress *Progress = NULL, bool WithLock = true);
73 inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
74 APT_DEPRECATED bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
75 static void RemoveCaches();
76 void Close();
77
78 inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };
79 inline pkgDepCache* GetDepCache() { BuildDepCache(); return DCache; };
80 inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; };
81 inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; };
82
83 inline bool IsPkgCacheBuilt() const { return (Cache != NULL); };
84 inline bool IsDepCacheBuilt() const { return (DCache != NULL); };
85 inline bool IsPolicyBuilt() const { return (Policy != NULL); };
86 inline bool IsSrcListBuilt() const { return (SrcList != NULL); };
87
88 pkgCacheFile();
89 virtual ~pkgCacheFile();
90 };
91
92 #endif