]>
Commit | Line | Data |
---|---|---|
1 | #ifndef PKGLIB_METAINDEX_H | |
2 | #define PKGLIB_METAINDEX_H | |
3 | ||
4 | #include <apt-pkg/indexfile.h> | |
5 | #include <apt-pkg/init.h> | |
6 | ||
7 | #include <stddef.h> | |
8 | ||
9 | #include <string> | |
10 | #include <vector> | |
11 | ||
12 | #ifndef APT_10_CLEANER_HEADERS | |
13 | #include <apt-pkg/pkgcache.h> | |
14 | class pkgCacheGenerator; | |
15 | class OpProgress; | |
16 | #endif | |
17 | #ifndef APT_8_CLEANER_HEADERS | |
18 | #include <apt-pkg/srcrecords.h> | |
19 | #include <apt-pkg/pkgrecords.h> | |
20 | using std::string; | |
21 | #endif | |
22 | ||
23 | class pkgAcquire; | |
24 | class IndexTarget; | |
25 | class pkgCacheGenerator; | |
26 | class OpProgress; | |
27 | ||
28 | class metaIndex | |
29 | { | |
30 | public: | |
31 | APT_IGNORE_DEPRECATED_PUSH | |
32 | struct checkSum | |
33 | { | |
34 | std::string MetaKeyFilename; | |
35 | HashStringList Hashes; | |
36 | unsigned long long Size; | |
37 | ||
38 | APT_DEPRECATED HashString Hash; | |
39 | }; | |
40 | APT_IGNORE_DEPRECATED_POP | |
41 | ||
42 | enum APT_HIDDEN TriState { | |
43 | TRI_YES, TRI_DONTCARE, TRI_NO, TRI_UNSET | |
44 | }; | |
45 | private: | |
46 | void * const d; | |
47 | protected: | |
48 | std::vector <pkgIndexFile *> *Indexes; | |
49 | // parsed from the sources.list | |
50 | const char *Type; | |
51 | std::string URI; | |
52 | std::string Dist; | |
53 | TriState Trusted; | |
54 | std::string SignedBy; | |
55 | ||
56 | // parsed from a file | |
57 | std::string Suite; | |
58 | std::string Codename; | |
59 | time_t Date; | |
60 | time_t ValidUntil; | |
61 | bool SupportsAcquireByHash; | |
62 | std::map<std::string, checkSum *> Entries; | |
63 | TriState LoadedSuccessfully; | |
64 | ||
65 | public: | |
66 | // Various accessors | |
67 | std::string GetURI() const; | |
68 | std::string GetDist() const; | |
69 | const char* GetType() const; | |
70 | TriState GetTrusted() const; | |
71 | std::string GetSignedBy() const; | |
72 | ||
73 | std::string GetCodename() const; | |
74 | std::string GetSuite() const; | |
75 | bool GetSupportsAcquireByHash() const; | |
76 | time_t GetValidUntil() const; | |
77 | time_t GetDate() const; | |
78 | ||
79 | std::string GetExpectedDist() const; | |
80 | bool CheckDist(std::string const &MaybeDist) const; | |
81 | ||
82 | // Interface for acquire | |
83 | virtual std::string Describe() const; | |
84 | virtual std::string ArchiveURI(std::string const& File) const = 0; | |
85 | virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) = 0; | |
86 | virtual std::vector<IndexTarget> GetIndexTargets() const = 0; | |
87 | virtual std::vector<pkgIndexFile *> *GetIndexFiles() = 0; | |
88 | virtual bool IsTrusted() const = 0; | |
89 | virtual bool Load(std::string const &Filename, std::string * const ErrorText) = 0; | |
90 | /** @return a new metaIndex object based on this one, but without information from #Load */ | |
91 | virtual metaIndex * UnloadedClone() const = 0; | |
92 | // the given metaIndex is potentially invalid after this call and should be deleted | |
93 | void swapLoad(metaIndex * const OldMetaIndex); | |
94 | ||
95 | // Lookup functions for parsed Hashes | |
96 | checkSum *Lookup(std::string const &MetaKey) const; | |
97 | /** \brief tests if a checksum for this file is available */ | |
98 | bool Exists(std::string const &MetaKey) const; | |
99 | std::vector<std::string> MetaKeys() const; | |
100 | TriState GetLoadedSuccessfully() const; | |
101 | ||
102 | // Interfaces for pkgCacheGen | |
103 | virtual pkgCache::RlsFileIterator FindInCache(pkgCache &Cache, bool const ModifyCheck) const; | |
104 | virtual bool Merge(pkgCacheGenerator &Gen,OpProgress *Prog) const; | |
105 | ||
106 | ||
107 | metaIndex(std::string const &URI, std::string const &Dist, | |
108 | char const * const Type); | |
109 | virtual ~metaIndex(); | |
110 | }; | |
111 | ||
112 | #endif |