apt  2.2.4
About: Apt (Advanced Package Tool) is a management system for software packages (Debian/Ubuntu). Release series 2.2.
  Fossies Dox: apt-2.2.4.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

policy.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
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 completely 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 
35 #include <apt-pkg/depcache.h>
36 #include <apt-pkg/pkgcache.h>
37 #include <apt-pkg/versionmatch.h>
38 
39 #include <string>
40 #include <vector>
41 
42 
44 {
45  protected:
46 
47  struct Pin
48  {
50  std::string Data;
51  signed short Priority;
52  Pin() : Type(pkgVersionMatch::None), Priority(0) {};
53  };
54 
55  struct PkgPin : Pin
56  {
57  std::string Pkg;
58  explicit PkgPin(std::string const &Pkg) : Pin(), Pkg(Pkg) {};
59  };
60 
62  signed short *PFPriority;
63  std::vector<Pin> Defaults;
64  std::vector<PkgPin> Unmatched;
67 
68  public:
69 
70  // Things for manipulating pins
71  void CreatePin(pkgVersionMatch::MatchType Type,std::string Pkg,
72  std::string Data,signed short Priority);
73 
74  // Things for the cache interface.
76  virtual signed short GetPriority(pkgCache::VerIterator const &Ver, bool ConsiderFiles = true) APT_OVERRIDE;
77  virtual signed short GetPriority(pkgCache::PkgFileIterator const &File) APT_OVERRIDE;
78 
79  void SetPriority(pkgCache::VerIterator const &Ver, signed short Priority);
80  void SetPriority(pkgCache::PkgFileIterator const &File, signed short Priority);
81  bool InitDefaults();
82 
83  explicit pkgPolicy(pkgCache *Owner);
84  virtual ~pkgPolicy();
85  private:
86  struct Private;
87  Private *const d;
88 };
89 
90 APT_PUBLIC bool ReadPinFile(pkgPolicy &Plcy, std::string File = "");
91 APT_PUBLIC bool ReadPinDir(pkgPolicy &Plcy, std::string Dir = "");
92 
93 #endif
virtual signed short GetPriority(PkgIterator const &Pkg)
Definition: depcache.cc:2168
virtual VerIterator GetCandidateVer(PkgIterator const &Pkg)
Definition: depcache.cc:2109
pkgCache * Cache
Definition: policy.h:65
std::vector< Pin > Defaults
Definition: policy.h:63
Pin * VerPins
Definition: policy.h:61
bool StatusOverride
Definition: policy.h:66
std::vector< PkgPin > Unmatched
Definition: policy.h:64
signed short * PFPriority
Definition: policy.h:62
#define APT_OVERRIDE
Definition: macros.h:111
#define APT_PUBLIC
Definition: macros.h:77
pkgCache - Structure definitions for the cache file
APT_PUBLIC bool ReadPinFile(pkgPolicy &Plcy, std::string File="")
Definition: policy.cc:405
APT_PUBLIC bool ReadPinDir(pkgPolicy &Plcy, std::string Dir="")
Definition: policy.cc:373
signed short Priority
Definition: policy.h:51
std::string Data
Definition: policy.h:50
pkgVersionMatch::MatchType Type
Definition: policy.h:49
std::string Pkg
Definition: policy.h:57
PkgPin(std::string const &Pkg)
Definition: policy.h:58