]>
Commit | Line | Data |
---|---|---|
578bfd0a AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
45415543 | 3 | // $Id: pkgcachegen.h,v 1.19 2002/07/08 03:13:30 jgg Exp $ |
578bfd0a AL |
4 | /* ###################################################################### |
5 | ||
6 | Package Cache Generator - Generator for the cache structure. | |
7 | ||
8 | This builds the cache structure from the abstract package list parser. | |
6fc33863 AL |
9 | Each archive source has it's own list parser that is instantiated by |
10 | the caller to provide data for the generator. | |
11 | ||
12 | Parts of the cache are created by this generator class while other | |
13 | parts are created by the list parser. The list parser is responsible | |
14 | for creating version, depends and provides structures, and some of | |
15 | their contents | |
578bfd0a AL |
16 | |
17 | ##################################################################### */ | |
18 | /*}}}*/ | |
578bfd0a AL |
19 | #ifndef PKGLIB_PKGCACHEGEN_H |
20 | #define PKGLIB_PKGCACHEGEN_H | |
21 | ||
6c139d6e | 22 | #ifdef __GNUG__ |
094a497d | 23 | #pragma interface "apt-pkg/pkgcachegen.h" |
6c139d6e AL |
24 | #endif |
25 | ||
094a497d | 26 | #include <apt-pkg/pkgcache.h> |
a52f938b | 27 | #include <apt-pkg/md5.h> |
b35d2f5f AL |
28 | |
29 | class pkgSourceList; | |
30 | class OpProgress; | |
2d11135a | 31 | class MMap; |
b2e465d6 | 32 | class pkgIndexFile; |
578bfd0a AL |
33 | |
34 | class pkgCacheGenerator | |
35 | { | |
f9eec0e7 AL |
36 | private: |
37 | ||
38 | pkgCache::StringItem *UniqHash[26]; | |
39 | ||
578bfd0a AL |
40 | public: |
41 | ||
42 | class ListParser; | |
b2e465d6 | 43 | friend class ListParser; |
578bfd0a AL |
44 | |
45 | protected: | |
46 | ||
47 | DynamicMMap ⤅ | |
48 | pkgCache Cache; | |
ddc1d8d0 | 49 | OpProgress *Progress; |
404ec98e | 50 | |
578bfd0a AL |
51 | string PkgFileName; |
52 | pkgCache::PackageFile *CurrentFile; | |
45415543 AL |
53 | |
54 | // Flag file dependencies | |
55 | bool FoundFileDeps; | |
578bfd0a | 56 | |
f55a958f AL |
57 | bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg); |
58 | bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List); | |
a52f938b | 59 | bool NewFileDesc(pkgCache::DescIterator &Desc,ListParser &List); |
f55a958f | 60 | unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next); |
a52f938b | 61 | map_ptrloc NewDescription(pkgCache::DescIterator &Desc,const string &Lang,const MD5SumValue &md5sum,map_ptrloc Next); |
578bfd0a | 62 | |
b2e465d6 AL |
63 | public: |
64 | ||
f55a958f | 65 | unsigned long WriteUniqString(const char *S,unsigned int Size); |
813c8eea AL |
66 | inline unsigned long WriteUniqString(string S) {return WriteUniqString(S.c_str(),S.length());}; |
67 | ||
ddc1d8d0 | 68 | void DropProgress() {Progress = 0;}; |
b2e465d6 AL |
69 | bool SelectFile(string File,string Site,pkgIndexFile const &Index, |
70 | unsigned long Flags = 0); | |
ddc1d8d0 | 71 | bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0); |
ad00ae81 | 72 | inline pkgCache &GetCache() {return Cache;}; |
b0b4efb9 AL |
73 | inline pkgCache::PkgFileIterator GetCurFile() |
74 | {return pkgCache::PkgFileIterator(Cache,CurrentFile);}; | |
45415543 AL |
75 | |
76 | bool HasFileDeps() {return FoundFileDeps;}; | |
77 | bool MergeFileProvides(ListParser &List); | |
b0b4efb9 | 78 | |
b2e465d6 | 79 | pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress); |
578bfd0a AL |
80 | ~pkgCacheGenerator(); |
81 | }; | |
82 | ||
f55ece0e AL |
83 | // This is the abstract package list parser class. |
84 | class pkgCacheGenerator::ListParser | |
85 | { | |
86 | pkgCacheGenerator *Owner; | |
b2e465d6 | 87 | friend class pkgCacheGenerator; |
f55ece0e | 88 | |
f9eec0e7 AL |
89 | // Some cache items |
90 | pkgCache::VerIterator OldDepVer; | |
349cd3b8 | 91 | map_ptrloc *OldDepLast; |
45415543 AL |
92 | |
93 | // Flag file dependencies | |
94 | bool FoundFileDeps; | |
f9eec0e7 | 95 | |
f55ece0e | 96 | protected: |
813c8eea | 97 | |
f55ece0e AL |
98 | inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);}; |
99 | inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);}; | |
100 | inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);}; | |
101 | inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);}; | |
102 | bool NewDepends(pkgCache::VerIterator Ver,string Package, | |
103 | string Version,unsigned int Op, | |
104 | unsigned int Type); | |
105 | bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version); | |
106 | ||
107 | public: | |
108 | ||
109 | // These all operate against the current section | |
110 | virtual string Package() = 0; | |
111 | virtual string Version() = 0; | |
112 | virtual bool NewVersion(pkgCache::VerIterator Ver) = 0; | |
a52f938b OS |
113 | virtual string Description() = 0; |
114 | virtual string DescriptionLanguage() = 0; | |
115 | virtual MD5SumValue Description_md5() = 0; | |
204fbdcc | 116 | virtual unsigned short VersionHash() = 0; |
f55ece0e AL |
117 | virtual bool UsePackage(pkgCache::PkgIterator Pkg, |
118 | pkgCache::VerIterator Ver) = 0; | |
119 | virtual unsigned long Offset() = 0; | |
120 | virtual unsigned long Size() = 0; | |
121 | ||
122 | virtual bool Step() = 0; | |
123 | ||
45415543 AL |
124 | inline bool HasFileDeps() {return FoundFileDeps;}; |
125 | virtual bool CollectFileProvides(pkgCache &Cache, | |
126 | pkgCache::VerIterator Ver) {return true;}; | |
127 | ||
128 | ListParser() : FoundFileDeps(false) {}; | |
f55ece0e AL |
129 | virtual ~ListParser() {}; |
130 | }; | |
131 | ||
b2e465d6 AL |
132 | bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress, |
133 | MMap **OutMap = 0,bool AllowMem = false); | |
134 | bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap); | |
135 | ||
136 | #ifdef APT_COMPATIBILITY | |
137 | #if APT_COMPATIBILITY != 986 | |
138 | #warning "Using APT_COMPATIBILITY" | |
139 | #endif | |
140 | MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress) | |
141 | { | |
142 | MMap *Map = 0; | |
143 | if (pkgMakeStatusCache(List,Progress,&Map,true) == false) | |
144 | return 0; | |
145 | return Map; | |
146 | } | |
147 | #endif | |
ddc1d8d0 | 148 | |
578bfd0a | 149 | #endif |