metaindex.h 1.6 KB

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