cachefile.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. class pkgPolicy;
  17. class pkgCacheFile
  18. {
  19. protected:
  20. MMap *Map;
  21. pkgCache *Cache;
  22. pkgDepCache *DCache;
  23. public:
  24. pkgPolicy *Policy;
  25. // We look pretty much exactly like a pointer to a dep cache
  26. inline operator pkgCache &() {return *Cache;};
  27. inline operator pkgCache *() {return Cache;};
  28. inline operator pkgDepCache &() {return *DCache;};
  29. inline operator pkgDepCache *() {return DCache;};
  30. inline pkgDepCache *operator ->() {return DCache;};
  31. inline pkgDepCache &operator *() {return *DCache;};
  32. inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) {return (*DCache)[I];};
  33. inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*DCache)[I];};
  34. bool BuildCaches(OpProgress &Progress,bool WithLock = true);
  35. bool Open(OpProgress &Progress,bool WithLock = true);
  36. void Close();
  37. pkgCacheFile();
  38. ~pkgCacheFile();
  39. };
  40. #endif