You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

78 lines
3.1 KiB

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