indexfile.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: indexfile.h,v 1.6.2.1 2003/12/24 23:09:17 mdz Exp $
  4. /* ######################################################################
  5. Index File - Abstraction for an index of archive/source file.
  6. There are 3 primary sorts of index files, all represented by this
  7. class:
  8. Binary index files
  9. Bianry index files decribing the local system
  10. Source index files
  11. They are all bundled together here, and the interfaces for
  12. sources.list, acquire, cache gen and record parsing all use this class
  13. to acess the underlying representation.
  14. ##################################################################### */
  15. /*}}}*/
  16. #ifndef PKGLIB_INDEXFILE_H
  17. #define PKGLIB_INDEXFILE_H
  18. #include <string>
  19. #include <apt-pkg/pkgcache.h>
  20. #include <apt-pkg/srcrecords.h>
  21. #include <apt-pkg/pkgrecords.h>
  22. using std::string;
  23. class pkgAcquire;
  24. class pkgCacheGenerator;
  25. class OpProgress;
  26. class pkgIndexFile
  27. {
  28. protected:
  29. bool Trusted;
  30. public:
  31. class Type
  32. {
  33. public:
  34. // Global list of Items supported
  35. static Type **GlobalList;
  36. static unsigned long GlobalListLen;
  37. static Type *GetType(const char *Type);
  38. const char *Label;
  39. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
  40. Type();
  41. virtual ~Type() {};
  42. };
  43. virtual const Type *GetType() const = 0;
  44. // Return descriptive strings of various sorts
  45. virtual string ArchiveInfo(pkgCache::VerIterator Ver) const;
  46. virtual string SourceInfo(pkgSrcRecords::Parser const &Record,
  47. pkgSrcRecords::File const &File) const;
  48. virtual string Describe(bool Short = false) const = 0;
  49. // Interface for acquire
  50. virtual string ArchiveURI(string /*File*/) const {return string();};
  51. // Interface for the record parsers
  52. virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
  53. // Interface for the Cache Generator
  54. virtual bool Exists() const = 0;
  55. virtual bool HasPackages() const = 0;
  56. virtual unsigned long Size() const = 0;
  57. virtual bool Merge(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return false;};
  58. virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return true;};
  59. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  60. bool IsTrusted() const { return Trusted; };
  61. pkgIndexFile(bool Trusted): Trusted(Trusted) {};
  62. virtual ~pkgIndexFile() {};
  63. };
  64. #endif