]> git.saurik.com Git - apt.git/blame - apt-pkg/pkgcachegen.h
* cmdline/apt-mark:
[apt.git] / apt-pkg / pkgcachegen.h
CommitLineData
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>
b35d2f5f
AL
27
28class pkgSourceList;
29class OpProgress;
2d11135a 30class MMap;
b2e465d6 31class pkgIndexFile;
578bfd0a
AL
32
33class pkgCacheGenerator
34{
f9eec0e7
AL
35 private:
36
37 pkgCache::StringItem *UniqHash[26];
38
578bfd0a
AL
39 public:
40
41 class ListParser;
b2e465d6 42 friend class ListParser;
578bfd0a
AL
43
44 protected:
45
46 DynamicMMap &Map;
47 pkgCache Cache;
ddc1d8d0 48 OpProgress *Progress;
404ec98e 49
578bfd0a
AL
50 string PkgFileName;
51 pkgCache::PackageFile *CurrentFile;
45415543
AL
52
53 // Flag file dependencies
54 bool FoundFileDeps;
578bfd0a 55
171c75f1 56 bool NewPackage(pkgCache::PkgIterator &Pkg,const string &Pkg);
f55a958f 57 bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
171c75f1 58 unsigned long NewVersion(pkgCache::VerIterator &Ver,const string &VerStr,unsigned long Next);
578bfd0a 59
b2e465d6
AL
60 public:
61
f55a958f 62 unsigned long WriteUniqString(const char *S,unsigned int Size);
171c75f1 63 inline unsigned long WriteUniqString(const string &S) {return WriteUniqString(S.c_str(),S.length());};
813c8eea 64
ddc1d8d0 65 void DropProgress() {Progress = 0;};
171c75f1 66 bool SelectFile(const string &File,const string &Site,pkgIndexFile const &Index,
b2e465d6 67 unsigned long Flags = 0);
ddc1d8d0 68 bool MergeList(ListParser &List,pkgCache::VerIterator *Ver = 0);
ad00ae81 69 inline pkgCache &GetCache() {return Cache;};
b0b4efb9
AL
70 inline pkgCache::PkgFileIterator GetCurFile()
71 {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
45415543
AL
72
73 bool HasFileDeps() {return FoundFileDeps;};
74 bool MergeFileProvides(ListParser &List);
b0b4efb9 75
b2e465d6 76 pkgCacheGenerator(DynamicMMap *Map,OpProgress *Progress);
578bfd0a
AL
77 ~pkgCacheGenerator();
78};
79
f55ece0e
AL
80// This is the abstract package list parser class.
81class pkgCacheGenerator::ListParser
82{
83 pkgCacheGenerator *Owner;
b2e465d6 84 friend class pkgCacheGenerator;
f55ece0e 85
f9eec0e7
AL
86 // Some cache items
87 pkgCache::VerIterator OldDepVer;
349cd3b8 88 map_ptrloc *OldDepLast;
45415543
AL
89
90 // Flag file dependencies
91 bool FoundFileDeps;
f9eec0e7 92
f55ece0e 93 protected:
813c8eea 94
f55ece0e
AL
95 inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
96 inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
171c75f1 97 inline unsigned long WriteString(const string &S) {return Owner->Map.WriteString(S);};
f55ece0e 98 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
171c75f1
MV
99 bool NewDepends(pkgCache::VerIterator Ver,const string &Package,
100 const string &Version,unsigned int Op,
f55ece0e 101 unsigned int Type);
171c75f1
MV
102 bool NewProvides(pkgCache::VerIterator Ver,const string &Package,
103 const string &Version);
f55ece0e
AL
104
105 public:
106
107 // These all operate against the current section
108 virtual string Package() = 0;
109 virtual string Version() = 0;
110 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
204fbdcc 111 virtual unsigned short VersionHash() = 0;
f55ece0e
AL
112 virtual bool UsePackage(pkgCache::PkgIterator Pkg,
113 pkgCache::VerIterator Ver) = 0;
114 virtual unsigned long Offset() = 0;
115 virtual unsigned long Size() = 0;
116
117 virtual bool Step() = 0;
118
45415543
AL
119 inline bool HasFileDeps() {return FoundFileDeps;};
120 virtual bool CollectFileProvides(pkgCache &Cache,
121 pkgCache::VerIterator Ver) {return true;};
122
123 ListParser() : FoundFileDeps(false) {};
f55ece0e
AL
124 virtual ~ListParser() {};
125};
126
b2e465d6
AL
127bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
128 MMap **OutMap = 0,bool AllowMem = false);
129bool pkgMakeOnlyStatusCache(OpProgress &Progress,DynamicMMap **OutMap);
130
131#ifdef APT_COMPATIBILITY
132#if APT_COMPATIBILITY != 986
133#warning "Using APT_COMPATIBILITY"
134#endif
135MMap *pkgMakeStatusCacheMem(pkgSourceList &List,OpProgress &Progress)
136{
137 MMap *Map = 0;
138 if (pkgMakeStatusCache(List,Progress,&Map,true) == false)
139 return 0;
140 return Map;
141}
142#endif
ddc1d8d0 143
578bfd0a 144#endif