apt: apt-pkg/cachefile.h Source File

apt 3.3.2 commandline package manager

cachefile.h
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
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
11 This means it can rebuild caches from the source list and instantiates
12 and prepares the standard policy mechanism.
13
14 ##################################################################### */
15 /*}}}*/
16#ifndef PKGLIB_CACHEFILE_H
17#define PKGLIB_CACHEFILE_H
18
19#include <cstddef>
20
21#include <apt-pkg/depcache.h>
22#include <apt-pkg/macros.h>
23#include <apt-pkg/pkgcache.h>
24
25
26class MMap;
27class pkgPolicy;
28class pkgSourceList;
29class pkgIndexFile;
30class OpProgress;
31
32 class APT_PUBLIC pkgCacheFile
33{
34 struct Private;
36 Private *const d;
37 bool ExternOwner;
38
39 protected:
40 MMap *Map;
41 pkgCache *Cache;
42 pkgDepCache *DCache;
43 pkgSourceList *SrcList;
44
45 public:
46 pkgPolicy *Policy;
47
48 // We look pretty much exactly like a pointer to a dep cache
49 inline operator pkgCache &() const {return *Cache;};
50 inline operator pkgCache *() const {return Cache;};
51 inline operator pkgDepCache &() const {return *DCache;};
52 inline operator pkgDepCache *() const {return DCache;};
53 inline operator pkgPolicy &() const {return *Policy;};
54 inline operator pkgPolicy *() const {return Policy;};
55 inline operator pkgSourceList &() const {return *SrcList;};
56 inline operator pkgSourceList *() const {return SrcList;};
57 inline pkgDepCache *operator ->() const {return DCache;};
58 inline pkgDepCache &operator *() const {return *DCache;};
59 inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) const {return (*DCache)[I];};
60 inline unsigned char &operator [](pkgCache::DepIterator const &I) const {return (*DCache)[I];};
61
62 bool BuildCaches(OpProgress *Progress = NULL,bool WithLock = true);
63 bool BuildSourceList(OpProgress *Progress = NULL);
64 bool BuildPolicy(OpProgress *Progress = NULL);
65 bool BuildDepCache(OpProgress *Progress = NULL);
66 bool Open(OpProgress *Progress = NULL, bool WithLock = true);
67 inline bool ReadOnlyOpen(OpProgress *Progress = NULL) { return Open(Progress, false); };
68 static void RemoveCaches();
69 void Close();
70
71 bool AddIndexFile(pkgIndexFile * const File);
72 // Starts DepCache with a claim of one ActionGroup already active
73 void InhibitActionGroups(bool yes);
74
75 inline pkgCache* GetPkgCache() { BuildCaches(NULL, false); return Cache; };
76 inline pkgDepCache* GetDepCache() { BuildDepCache(); return DCache; };
77 inline pkgPolicy* GetPolicy() { BuildPolicy(); return Policy; };
78 inline pkgSourceList* GetSourceList() { BuildSourceList(); return SrcList; };
79
80 inline bool IsPkgCacheBuilt() const { return (Cache != NULL); };
81 inline bool IsDepCacheBuilt() const { return (DCache != NULL); };
82 inline bool IsPolicyBuilt() const { return (Policy != NULL); };
83 inline bool IsSrcListBuilt() const { return (SrcList != NULL); };
84
85 pkgCacheFile();
86 explicit pkgCacheFile(pkgDepCache * const Owner);
87 virtual ~pkgCacheFile();
88};
89
90#endif
MMap
Definition mmap.h:45
OpProgress
Definition progress.h:30
pkgCache::DepIterator
Definition cacheiterators.h:337
pkgCache::PkgIterator
Definition cacheiterators.h:147
pkgCache
Definition pkgcache.h:126
pkgDepCache
Definition depcache.h:63
pkgIndexFile
Definition indexfile.h:103
pkgPolicy
Definition policy.h:45
pkgSourceList
Definition sourcelist.h:43
pkgcache.h
pkgCache - Structure definitions for the cache file
pkgCacheFile::Private
Definition cachefile.cc:43
pkgDepCache::StateCache
Definition depcache.h:188