]> git.saurik.com Git - apt.git/blame - apt-pkg/policy.h
add specialisations for std::vector
[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
b2e465d6 36#include <apt-pkg/depcache.h>
453b82a3
DK
37#include <apt-pkg/pkgcache.h>
38#include <apt-pkg/cacheiterators.h>
b2e465d6 39#include <apt-pkg/versionmatch.h>
453b82a3 40
b2e465d6 41#include <vector>
453b82a3 42#include <string>
b2e465d6 43
a4f6bdc8
DK
44#ifndef APT_8_CLEANER_HEADERS
45using std::vector;
46#endif
47
b2e465d6
AL
48class pkgPolicy : public pkgDepCache::Policy
49{
13e8426f
MV
50 protected:
51
b2e465d6
AL
52 struct Pin
53 {
54 pkgVersionMatch::MatchType Type;
8f3ba4e8 55 std::string Data;
b2e465d6
AL
56 signed short Priority;
57 Pin() : Type(pkgVersionMatch::None), Priority(0) {};
58 };
59
60 struct PkgPin : Pin
61 {
8f3ba4e8
DK
62 std::string Pkg;
63 PkgPin(std::string const &Pkg) : Pin(), Pkg(Pkg) {};
b2e465d6
AL
64 };
65
b2e465d6
AL
66 Pin *Pins;
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.
9ee8287e 81 virtual pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator const &Pkg);
6d38011b
DK
82 virtual signed short GetPriority(pkgCache::PkgIterator const &Pkg);
83 virtual signed short GetPriority(pkgCache::PkgFileIterator const &File);
84
b2e465d6
AL
85 bool InitDefaults();
86
87 pkgPolicy(pkgCache *Owner);
88 virtual ~pkgPolicy() {delete [] PFPriority; delete [] Pins;};
89};
90
8f3ba4e8
DK
91bool ReadPinFile(pkgPolicy &Plcy, std::string File = "");
92bool ReadPinDir(pkgPolicy &Plcy, std::string Dir = "");
b2e465d6
AL
93
94#endif