]> git.saurik.com Git - apt.git/blame - apt-pkg/policy.h
* doc/examples/configure-index:
[apt.git] / apt-pkg / policy.h
CommitLineData
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
36#ifdef __GNUG__
37#pragma interface "apt-pkg/policy.h"
38#endif
39
40#include <apt-pkg/depcache.h>
41#include <apt-pkg/versionmatch.h>
42#include <vector>
43
0a843901
AL
44using std::vector;
45
b2e465d6
AL
46class pkgPolicy : public pkgDepCache::Policy
47{
13e8426f
MV
48 protected:
49
b2e465d6
AL
50 struct Pin
51 {
52 pkgVersionMatch::MatchType Type;
53 string Data;
54 signed short Priority;
55 Pin() : Type(pkgVersionMatch::None), Priority(0) {};
56 };
57
58 struct PkgPin : Pin
59 {
60 string Pkg;
61 };
62
b2e465d6
AL
63 Pin *Pins;
64 signed short *PFPriority;
65 vector<Pin> Defaults;
66 vector<PkgPin> Unmatched;
67 pkgCache *Cache;
68 bool StatusOverride;
69
70 public:
71
af87ab54 72 // Things for manipulating pins
b2e465d6
AL
73 void CreatePin(pkgVersionMatch::MatchType Type,string Pkg,
74 string Data,signed short Priority);
af87ab54
AL
75 inline signed short GetPriority(pkgCache::PkgFileIterator const &File)
76 {return PFPriority[File->ID];};
77 signed short GetPriority(pkgCache::PkgIterator const &Pkg);
78 pkgCache::VerIterator GetMatch(pkgCache::PkgIterator Pkg);
79
80 // Things for the cache interface.
b2e465d6
AL
81 virtual pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator Pkg);
82 virtual bool IsImportantDep(pkgCache::DepIterator Dep) {return pkgDepCache::Policy::IsImportantDep(Dep);};
83 bool InitDefaults();
84
85 pkgPolicy(pkgCache *Owner);
86 virtual ~pkgPolicy() {delete [] PFPriority; delete [] Pins;};
87};
88
89bool ReadPinFile(pkgPolicy &Plcy,string File = "");
90
91#endif