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