]> git.saurik.com Git - apt.git/blame - apt-pkg/cachefile.h
edsp: if logging is requested, do it for internal, too
[apt.git] / apt-pkg / cachefile.h
CommitLineData
2d11135a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
2d11135a
AL
3/* ######################################################################
4
5 CacheFile - Simple wrapper class for opening, generating and whatnot
6
7 This class implements a simple 2 line mechanism to open various sorts
8 of caches. It can operate as root, as not root, show progress and so on,
9 it transparently handles everything necessary.
10
b2e465d6
AL
11 This means it can rebuild caches from the source list and instantiates
12 and prepares the standard policy mechanism.
13
2d11135a
AL
14 ##################################################################### */
15 /*}}}*/
16#ifndef PKGLIB_CACHEFILE_H
17#define PKGLIB_CACHEFILE_H
18
453b82a3
DK
19#include <stddef.h>
20
2d11135a 21#include <apt-pkg/depcache.h>
472ff00e 22#include <apt-pkg/macros.h>
453b82a3
DK
23#include <apt-pkg/pkgcache.h>
24#include <apt-pkg/cacheiterators.h>
472ff00e 25
b9dadc24
DK
26#ifndef APT_8_CLEANER_HEADERS
27#include <apt-pkg/acquire.h>
28#include <apt-pkg/policy.h>
29#include <apt-pkg/sourcelist.h>
30#endif
31
453b82a3 32class MMap;
472ff00e
DK
33class pkgPolicy;
34class pkgSourceList;
a249b3e6 35class pkgIndexFile;
472ff00e 36class OpProgress;
2d11135a
AL
37
38class pkgCacheFile
39{
be9b62f7 40 /** \brief dpointer placeholder (for later in case we need it) */
6c55f07a 41 void * const d;
9112f777 42 bool ExternOwner;
be9b62f7 43
2d11135a 44 protected:
2d11135a 45 MMap *Map;
b2e465d6
AL
46 pkgCache *Cache;
47 pkgDepCache *DCache;
3f8621c5 48 pkgSourceList *SrcList;
2e5f4e45 49
2d11135a 50 public:
6b2f7a60 51 pkgPolicy *Policy;
b2e465d6 52
2d11135a 53 // We look pretty much exactly like a pointer to a dep cache
9112f777
DK
54 inline operator pkgCache &() const {return *Cache;};
55 inline operator pkgCache *() const {return Cache;};
56 inline operator pkgDepCache &() const {return *DCache;};
57 inline operator pkgDepCache *() const {return DCache;};
58 inline operator pkgPolicy &() const {return *Policy;};
59 inline operator pkgPolicy *() const {return Policy;};
60 inline operator pkgSourceList &() const {return *SrcList;};
61 inline operator pkgSourceList *() const {return SrcList;};
62 inline pkgDepCache *operator ->() const {return DCache;};
63 inline pkgDepCache &operator *() const {return *DCache;};
64 inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) const {return (*DCache)[I];};
65 inline unsigned char &operator [](pkgCache::DepIterator const &I) const {return (*DCache)[I];};
099a4759 66
2e5f4e45 67 bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true);
5dd00edb 68 APT_DEPRECATED_MSG("Pass Progress in as a pointer") bool BuildCaches(OpProgress &Progress,bool const &WithLock = true) { return BuildCaches(&Progress, WithLock); };
3f8621c5 69 bool BuildSourceList(OpProgress *Progress = NULL);
2e5f4e45
DK
70 bool BuildPolicy(OpProgress *Progress = NULL);
71 bool BuildDepCache(OpProgress *Progress = NULL);
72 bool Open(OpProgress *Progress = NULL, bool WithLock = true);
3f8621c5 73 inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
5dd00edb 74 APT_DEPRECATED_MSG("Pass Progress in as a pointer") bool Open(OpProgress &Progress,bool const &WithLock = true) { return Open(&Progress, WithLock); };
8de79b68 75 static void RemoveCaches();
b2e465d6 76 void Close();
3f8621c5 77
a249b3e6
DK
78 bool AddIndexFile(pkgIndexFile * const File);
79
3f8621c5
DK
80 inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };
81 inline pkgDepCache* GetDepCache() { BuildDepCache(); return DCache; };
82 inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; };
83 inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; };
84
a8ef7efd
DK
85 inline bool IsPkgCacheBuilt() const { return (Cache != NULL); };
86 inline bool IsDepCacheBuilt() const { return (DCache != NULL); };
87 inline bool IsPolicyBuilt() const { return (Policy != NULL); };
88 inline bool IsSrcListBuilt() const { return (SrcList != NULL); };
89
2d11135a 90 pkgCacheFile();
9112f777 91 explicit pkgCacheFile(pkgDepCache * const Owner);
2e5f4e45 92 virtual ~pkgCacheFile();
2d11135a
AL
93};
94
95#endif