metaindex.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef PKGLIB_METAINDEX_H
  2. #define PKGLIB_METAINDEX_H
  3. #include <apt-pkg/indexfile.h>
  4. #include <apt-pkg/init.h>
  5. #include <stddef.h>
  6. #include <string>
  7. #include <vector>
  8. #ifndef APT_10_CLEANER_HEADERS
  9. #include <apt-pkg/pkgcache.h>
  10. class pkgCacheGenerator;
  11. class OpProgress;
  12. #endif
  13. #ifndef APT_8_CLEANER_HEADERS
  14. #include <apt-pkg/srcrecords.h>
  15. #include <apt-pkg/pkgrecords.h>
  16. #include <apt-pkg/vendor.h>
  17. using std::string;
  18. #endif
  19. class pkgAcquire;
  20. class metaIndex
  21. {
  22. protected:
  23. std::vector <pkgIndexFile *> *Indexes;
  24. const char *Type;
  25. std::string URI;
  26. std::string Dist;
  27. bool Trusted;
  28. public:
  29. // Various accessors
  30. virtual std::string GetURI() const {return URI;}
  31. virtual std::string GetDist() const {return Dist;}
  32. virtual const char* GetType() const {return Type;}
  33. // interface to to query it
  34. #if (APT_PKG_MAJOR >= 4 && APT_PKG_MINOR >= 13)
  35. // returns the path of the local file (or "" if its not available)
  36. virtual std::string LocalFileName() const {return "";};
  37. #endif
  38. // Interface for acquire
  39. virtual std::string ArchiveURI(std::string const& File) const = 0;
  40. virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const = 0;
  41. virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0;
  42. virtual bool IsTrusted() const = 0;
  43. metaIndex(std::string const &URI, std::string const &Dist,
  44. char const * const Type)
  45. : Indexes(NULL), Type(Type), URI(URI), Dist(Dist)
  46. {
  47. /* nothing */
  48. }
  49. virtual ~metaIndex()
  50. {
  51. if (Indexes == 0)
  52. return;
  53. for (std::vector<pkgIndexFile *>::iterator I = (*Indexes).begin();
  54. I != (*Indexes).end(); ++I)
  55. delete *I;
  56. delete Indexes;
  57. }
  58. };
  59. #endif