]>
git.saurik.com Git - apt.git/blob - apt-pkg/cachefile.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: cachefile.h,v 1.5 2002/04/27 04:28:04 jgg Exp $
4 /* ######################################################################
6 CacheFile - Simple wrapper class for opening, generating and whatnot
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.
12 This means it can rebuild caches from the source list and instantiates
13 and prepares the standard policy mechanism.
15 ##################################################################### */
17 #ifndef PKGLIB_CACHEFILE_H
18 #define PKGLIB_CACHEFILE_H
22 #include <apt-pkg/depcache.h>
23 #include <apt-pkg/macros.h>
24 #include <apt-pkg/pkgcache.h>
25 #include <apt-pkg/cacheiterators.h>
27 #ifndef APT_8_CLEANER_HEADERS
28 #include <apt-pkg/acquire.h>
29 #include <apt-pkg/policy.h>
30 #include <apt-pkg/sourcelist.h>
40 /** \brief dpointer placeholder (for later in case we need it) */
48 pkgSourceList
*SrcList
;
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
];};
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();
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
; };
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
); };
89 virtual ~pkgCacheFile();