indexfile.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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. #ifdef __GNUG__
  19. #pragma interface "apt-pkg/indexfile.h"
  20. #endif
  21. #include <string>
  22. #include <apt-pkg/pkgcache.h>
  23. #include <apt-pkg/srcrecords.h>
  24. #include <apt-pkg/pkgrecords.h>
  25. using std::string;
  26. class pkgAcquire;
  27. class pkgCacheGenerator;
  28. class OpProgress;
  29. class pkgIndexFile
  30. {
  31. protected:
  32. bool Trusted;
  33. public:
  34. class Type
  35. {
  36. public:
  37. // Global list of Items supported
  38. static Type **GlobalList;
  39. static unsigned long GlobalListLen;
  40. static Type *GetType(const char *Type);
  41. const char *Label;
  42. virtual pkgRecords::Parser *CreatePkgParser(pkgCache::PkgFileIterator /*File*/) const {return 0;};
  43. Type();
  44. virtual ~Type() {};
  45. };
  46. virtual const Type *GetType() const = 0;
  47. // Return descriptive strings of various sorts
  48. virtual string ArchiveInfo(pkgCache::VerIterator Ver) const;
  49. virtual string SourceInfo(pkgSrcRecords::Parser const &Record,
  50. pkgSrcRecords::File const &File) const;
  51. virtual string Describe(bool Short = false) const = 0;
  52. // Interface for acquire
  53. virtual string ArchiveURI(string /*File*/) const {return string();};
  54. // Interface for the record parsers
  55. virtual pkgSrcRecords::Parser *CreateSrcParser() const {return 0;};
  56. // Interface for the Cache Generator
  57. virtual bool Exists() const = 0;
  58. virtual bool HasPackages() const = 0;
  59. virtual unsigned long Size() const = 0;
  60. virtual bool Merge(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return false;};
  61. virtual bool MergeFileProvides(pkgCacheGenerator &/*Gen*/,OpProgress &/*Prog*/) const {return true;};
  62. virtual pkgCache::PkgFileIterator FindInCache(pkgCache &Cache) const;
  63. bool IsTrusted() const { return Trusted; };
  64. pkgIndexFile(bool Trusted): Trusted(Trusted) {};
  65. virtual ~pkgIndexFile() {};
  66. };
  67. #endif