cachefile.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: cachefile.h,v 1.3 1999/06/27 03:18:28 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. ##################################################################### */
  10. /*}}}*/
  11. #ifndef PKGLIB_CACHEFILE_H
  12. #define PKGLIB_CACHEFILE_H
  13. #ifdef __GNUG__
  14. #pragma interface "apt-pkg/cachefile.h"
  15. #endif
  16. #include <apt-pkg/depcache.h>
  17. #include <apt-pkg/dpkginit.h>
  18. class pkgCacheFile
  19. {
  20. protected:
  21. MMap *Map;
  22. pkgDepCache *Cache;
  23. pkgDpkgLock *Lock;
  24. public:
  25. // We look pretty much exactly like a pointer to a dep cache
  26. inline operator pkgDepCache &() {return *Cache;};
  27. inline operator pkgDepCache *() {return Cache;};
  28. inline pkgDepCache *operator ->() {return Cache;};
  29. inline pkgDepCache &operator *() {return *Cache;};
  30. inline pkgDepCache::StateCache &operator [](pkgCache::PkgIterator const &I) {return (*Cache)[I];};
  31. inline unsigned char &operator [](pkgCache::DepIterator const &I) {return (*Cache)[I];};
  32. // Release the dpkg status lock
  33. inline void ReleaseLock() {Lock->Close();};
  34. bool Open(OpProgress &Progress,bool WithLock = true);
  35. pkgCacheFile();
  36. ~pkgCacheFile();
  37. };
  38. #endif