]>
Commit | Line | Data |
---|---|---|
6c139d6e AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
b3d44315 | 3 | // $Id: sourcelist.h,v 1.12.2.1 2003/12/24 23:09:17 mdz Exp $ |
6c139d6e AL |
4 | /* ###################################################################### |
5 | ||
6 | SourceList - Manage a list of sources | |
7 | ||
8 | The Source List class provides access to a list of sources. It | |
6fc33863 AL |
9 | can read them from a file and generate a list of all the distinct |
10 | sources. | |
11 | ||
12 | All sources have a type associated with them that defines the layout | |
13 | of the archive. The exact format of the file is documented in | |
14 | files.sgml. | |
b2e465d6 AL |
15 | |
16 | The types are mapped through a list of type definitions which handle | |
a7c835af AL |
17 | the actual construction of the back end type. After loading a source |
18 | list all you have is a list of package index files that have the ability | |
b2e465d6 | 19 | to be Acquired. |
6c139d6e | 20 | |
a7c835af AL |
21 | The vendor machanism is similar, except the vendor types are hard |
22 | wired. Before loading the source list the vendor list is loaded. | |
b3d44315 | 23 | This doesn't load key data, just the checks to perform. |
a7c835af | 24 | |
6c139d6e AL |
25 | ##################################################################### */ |
26 | /*}}}*/ | |
6c139d6e AL |
27 | #ifndef PKGLIB_SOURCELIST_H |
28 | #define PKGLIB_SOURCELIST_H | |
29 | ||
30 | #include <string> | |
31 | #include <vector> | |
5dd4c8b8 | 32 | #include <map> |
094a497d | 33 | #include <apt-pkg/pkgcache.h> |
0a843901 AL |
34 | |
35 | using std::string; | |
36 | using std::vector; | |
b2e465d6 | 37 | |
6c139d6e | 38 | |
472ff00e DK |
39 | class pkgAcquire; |
40 | class pkgIndexFile; | |
41 | class metaIndex; | |
42 | ||
6c139d6e AL |
43 | class pkgSourceList |
44 | { | |
45 | public: | |
46 | ||
b2e465d6 AL |
47 | // List of supported source list types |
48 | class Type | |
6c139d6e | 49 | { |
b2e465d6 | 50 | public: |
6c139d6e | 51 | |
b2e465d6 AL |
52 | // Global list of Items supported |
53 | static Type **GlobalList; | |
54 | static unsigned long GlobalListLen; | |
55 | static Type *GetType(const char *Type); | |
56 | ||
57 | const char *Name; | |
58 | const char *Label; | |
59 | ||
60 | bool FixupURI(string &URI) const; | |
b3d44315 | 61 | virtual bool ParseLine(vector<metaIndex *> &List, |
b2e465d6 | 62 | const char *Buffer, |
5dd4c8b8 DK |
63 | unsigned long const &CurLine,string const &File) const; |
64 | virtual bool CreateItem(vector<metaIndex *> &List,string const &URI, | |
65 | string const &Dist,string const &Section, | |
66 | std::map<string, string> const &Options) const = 0; | |
b2e465d6 AL |
67 | Type(); |
68 | virtual ~Type() {}; | |
6c139d6e | 69 | }; |
b2e465d6 | 70 | |
b3d44315 | 71 | typedef vector<metaIndex *>::const_iterator const_iterator; |
6c139d6e AL |
72 | |
73 | protected: | |
a7c835af | 74 | |
b3d44315 | 75 | vector<metaIndex *> SrcList; |
6c139d6e AL |
76 | |
77 | public: | |
78 | ||
79 | bool ReadMainList(); | |
80 | bool Read(string File); | |
34b53501 MV |
81 | |
82 | // CNC:2003-03-03 | |
83 | void Reset(); | |
84 | bool ReadAppend(string File); | |
85 | bool ReadSourceDir(string Dir); | |
6c139d6e AL |
86 | |
87 | // List accessors | |
a7c835af AL |
88 | inline const_iterator begin() const {return SrcList.begin();}; |
89 | inline const_iterator end() const {return SrcList.end();}; | |
90 | inline unsigned int size() const {return SrcList.size();}; | |
91 | inline bool empty() const {return SrcList.empty();}; | |
0118833a | 92 | |
b2e465d6 AL |
93 | bool FindIndex(pkgCache::PkgFileIterator File, |
94 | pkgIndexFile *&Found) const; | |
b3d44315 | 95 | bool GetIndexes(pkgAcquire *Owner, bool GetAll=false) const; |
b2e465d6 | 96 | |
2ec858bc MV |
97 | // query last-modified time |
98 | time_t GetLastModifiedTime(); | |
99 | ||
6c139d6e | 100 | pkgSourceList(); |
1c193e02 AL |
101 | pkgSourceList(string File); |
102 | ~pkgSourceList(); | |
6c139d6e AL |
103 | }; |
104 | ||
6c139d6e | 105 | #endif |