Little more robust timeout behavoir
[ntk/apt.git] / apt-pkg / pkgcachegen.h
CommitLineData
578bfd0a
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
f9eec0e7 3// $Id: pkgcachegen.h,v 1.12 1999/02/23 06:46:24 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 /*}}}*/
19// Header section: pkglib
20#ifndef PKGLIB_PKGCACHEGEN_H
21#define PKGLIB_PKGCACHEGEN_H
22
6c139d6e 23#ifdef __GNUG__
094a497d 24#pragma interface "apt-pkg/pkgcachegen.h"
6c139d6e
AL
25#endif
26
094a497d 27#include <apt-pkg/pkgcache.h>
b35d2f5f
AL
28
29class pkgSourceList;
30class OpProgress;
578bfd0a
AL
31
32class pkgCacheGenerator
33{
f9eec0e7
AL
34 private:
35
36 pkgCache::StringItem *UniqHash[26];
37
578bfd0a
AL
38 public:
39
40 class ListParser;
f55ece0e 41 friend ListParser;
578bfd0a
AL
42
43 protected:
44
45 DynamicMMap &Map;
46 pkgCache Cache;
404ec98e
AL
47 OpProgress &Progress;
48
578bfd0a
AL
49 string PkgFileName;
50 pkgCache::PackageFile *CurrentFile;
51
f55a958f
AL
52 bool NewPackage(pkgCache::PkgIterator &Pkg,string Pkg);
53 bool NewFileVer(pkgCache::VerIterator &Ver,ListParser &List);
54 unsigned long NewVersion(pkgCache::VerIterator &Ver,string VerStr,unsigned long Next);
578bfd0a 55
f55a958f
AL
56 unsigned long WriteUniqString(const char *S,unsigned int Size);
57 inline unsigned long WriteUniqString(string S) {return WriteUniqString(S);};
58
f55ece0e 59 public:
578bfd0a
AL
60
61 bool SelectFile(string File,unsigned long Flags = 0);
62 bool MergeList(ListParser &List);
ad00ae81 63 inline pkgCache &GetCache() {return Cache;};
b0b4efb9
AL
64 inline pkgCache::PkgFileIterator GetCurFile()
65 {return pkgCache::PkgFileIterator(Cache,CurrentFile);};
66
404ec98e 67 pkgCacheGenerator(DynamicMMap &Map,OpProgress &Progress);
578bfd0a
AL
68 ~pkgCacheGenerator();
69};
70
b35d2f5f
AL
71bool pkgSrcCacheCheck(pkgSourceList &List);
72bool pkgPkgCacheCheck(string CacheFile);
73bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress);
74
f55ece0e
AL
75// This is the abstract package list parser class.
76class pkgCacheGenerator::ListParser
77{
78 pkgCacheGenerator *Owner;
79 friend pkgCacheGenerator;
80
f9eec0e7
AL
81 // Some cache items
82 pkgCache::VerIterator OldDepVer;
83 __apt_ptrloc *OldDepLast;
84
f55ece0e
AL
85 protected:
86
87 inline unsigned long WriteUniqString(string S) {return Owner->WriteUniqString(S);};
88 inline unsigned long WriteUniqString(const char *S,unsigned int Size) {return Owner->WriteUniqString(S,Size);};
89 inline unsigned long WriteString(string S) {return Owner->Map.WriteString(S);};
90 inline unsigned long WriteString(const char *S,unsigned int Size) {return Owner->Map.WriteString(S,Size);};
91 bool NewDepends(pkgCache::VerIterator Ver,string Package,
92 string Version,unsigned int Op,
93 unsigned int Type);
94 bool NewProvides(pkgCache::VerIterator Ver,string Package,string Version);
95
96 public:
97
98 // These all operate against the current section
99 virtual string Package() = 0;
100 virtual string Version() = 0;
101 virtual bool NewVersion(pkgCache::VerIterator Ver) = 0;
102 virtual bool UsePackage(pkgCache::PkgIterator Pkg,
103 pkgCache::VerIterator Ver) = 0;
104 virtual unsigned long Offset() = 0;
105 virtual unsigned long Size() = 0;
106
107 virtual bool Step() = 0;
108
109 virtual ~ListParser() {};
110};
111
578bfd0a 112#endif