]>
Commit | Line | Data |
---|---|---|
b2e465d6 AL |
1 | // -*- mode: cpp; mode: fold -*- |
2 | // Description /*{{{*/ | |
0a843901 | 3 | // $Id: policy.h,v 1.4 2001/05/07 04:24:08 jgg Exp $ |
b2e465d6 AL |
4 | /* ###################################################################### |
5 | ||
6 | Package Version Policy implementation | |
7 | ||
8 | This implements the more advanced 'Version 4' APT policy engine. The | |
9 | standard 'Version 0' engine is included inside the DepCache which is | |
10 | it's historical location. | |
11 | ||
12 | The V4 engine allows the user to completly control all aspects of | |
13 | version selection. There are three primary means to choose a version | |
14 | * Selection by version match | |
15 | * Selection by Release file match | |
16 | * Selection by origin server | |
17 | ||
18 | Each package may be 'pinned' with a single criteria, which will ultimately | |
19 | result in the selection of a single version, or no version, for each | |
20 | package. | |
21 | ||
22 | Furthermore, the default selection can be influenced by specifying | |
23 | the ordering of package files. The order is derived by reading the | |
24 | package file preferences and assigning a priority to each package | |
25 | file. | |
26 | ||
27 | A special flag may be set to indicate if no version should be returned | |
28 | if no matching versions are found, otherwise the default matching | |
29 | rules are used to locate a hit. | |
30 | ||
31 | ##################################################################### */ | |
32 | /*}}}*/ | |
33 | #ifndef PKGLIB_POLICY_H | |
34 | #define PKGLIB_POLICY_H | |
35 | ||
b2e465d6 AL |
36 | |
37 | #include <apt-pkg/depcache.h> | |
38 | #include <apt-pkg/versionmatch.h> | |
39 | #include <vector> | |
40 | ||
0a843901 AL |
41 | using std::vector; |
42 | ||
b2e465d6 AL |
43 | class pkgPolicy : public pkgDepCache::Policy |
44 | { | |
13e8426f MV |
45 | protected: |
46 | ||
b2e465d6 AL |
47 | struct Pin |
48 | { | |
49 | pkgVersionMatch::MatchType Type; | |
50 | string Data; | |
51 | signed short Priority; | |
52 | Pin() : Type(pkgVersionMatch::None), Priority(0) {}; | |
53 | }; | |
54 | ||
55 | struct PkgPin : Pin | |
56 | { | |
57 | string Pkg; | |
00c6e1a3 | 58 | PkgPin(string const &Pkg) : Pin(), Pkg(Pkg) {}; |
b2e465d6 AL |
59 | }; |
60 | ||
b2e465d6 AL |
61 | Pin *Pins; |
62 | signed short *PFPriority; | |
63 | vector<Pin> Defaults; | |
64 | vector<PkgPin> Unmatched; | |
65 | pkgCache *Cache; | |
66 | bool StatusOverride; | |
67 | ||
68 | public: | |
69 | ||
af87ab54 | 70 | // Things for manipulating pins |
b2e465d6 AL |
71 | void CreatePin(pkgVersionMatch::MatchType Type,string Pkg, |
72 | string Data,signed short Priority); | |
af87ab54 AL |
73 | inline signed short GetPriority(pkgCache::PkgFileIterator const &File) |
74 | {return PFPriority[File->ID];}; | |
75 | signed short GetPriority(pkgCache::PkgIterator const &Pkg); | |
9ee8287e | 76 | pkgCache::VerIterator GetMatch(pkgCache::PkgIterator const &Pkg); |
af87ab54 AL |
77 | |
78 | // Things for the cache interface. | |
9ee8287e | 79 | virtual pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator const &Pkg); |
e841200b | 80 | virtual bool IsImportantDep(pkgCache::DepIterator const &Dep) {return pkgDepCache::Policy::IsImportantDep(Dep);}; |
b2e465d6 AL |
81 | bool InitDefaults(); |
82 | ||
83 | pkgPolicy(pkgCache *Owner); | |
84 | virtual ~pkgPolicy() {delete [] PFPriority; delete [] Pins;}; | |
85 | }; | |
86 | ||
87 | bool ReadPinFile(pkgPolicy &Plcy,string File = ""); | |
e68ca100 | 88 | bool ReadPinDir(pkgPolicy &Plcy,string Dir = ""); |
b2e465d6 AL |
89 | |
90 | #endif |