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)  

orderlist.h
Go to the documentation of this file.
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 /* ######################################################################
4 
5  Order List - Represents and Manipulates an ordered list of packages.
6 
7  A list of packages can be ordered by a number of conflicting criteria
8  each given a specific priority. Each package also has a set of flags
9  indicating some useful things about it that are derived in the
10  course of sorting. The pkgPackageManager class uses this class for
11  all of it's installation ordering needs.
12 
13  ##################################################################### */
14  /*}}}*/
15 #ifndef PKGLIB_ORDERLIST_H
16 #define PKGLIB_ORDERLIST_H
17 
18 #include <apt-pkg/macros.h>
19 #include <apt-pkg/pkgcache.h>
20 
21 #include <string>
22 
23 class pkgDepCache;
25 {
26  void * const d;
27  protected:
28 
30  typedef bool (pkgOrderList::*DepFunc)(DepIterator D);
31 
32  // These are the currently selected ordering functions
33  DepFunc Primary;
34  DepFunc Secondary;
35  DepFunc RevDepends;
36  DepFunc Remove;
37 
38  // State
42  std::string *FileList;
43  DepIterator Loops[20];
44  int LoopCount;
45  int Depth;
46  unsigned short *Flags;
47  bool Debug;
48 
49  // Main visit function
50  bool VisitNode(PkgIterator Pkg, char const* from);
51  bool VisitDeps(DepFunc F,PkgIterator Pkg);
52  bool VisitRDeps(DepFunc F,PkgIterator Pkg);
53  bool VisitRProvides(DepFunc F,VerIterator Ver);
54  bool VisitProvides(DepIterator Pkg,bool Critical);
55 
56  // Dependency checking functions.
57  bool DepUnPackCrit(DepIterator D);
58  bool DepUnPackPreD(DepIterator D);
59  bool DepUnPackPre(DepIterator D);
60  bool DepUnPackDep(DepIterator D);
61  bool DepConfigure(DepIterator D);
62  bool DepRemove(DepIterator D);
63 
64  // Analysis helpers
65  bool AddLoop(DepIterator D);
66  bool CheckDep(DepIterator D);
67  bool DoRun();
68 
69  // For pre sorting
70  int OrderCompareA(Package *a, Package *b) APT_PURE;
71  int OrderCompareB(Package *a, Package *b) APT_PURE;
72  int FileCmp(PkgIterator A,PkgIterator B) APT_PURE;
73 
74  public:
75 
76  typedef Package **iterator;
77 
78  /* State flags
79  The Loop flag can be set on a package that is currently being processed by either SmartConfigure or
80  SmartUnPack. This allows the package manager to tell when a loop has been formed as it will try to
81  SmartUnPack or SmartConfigure a package with the Loop flag set. It will then either stop (as it knows
82  that the operation is unnecessary as its already in process), or in the case of the conflicts resolution
83  in SmartUnPack, use EarlyRemove to resolve the situation. */
84  enum Flags {Added = (1 << 0), AddPending = (1 << 1),
85  Immediate = (1 << 2), Loop = (1 << 3),
86  UnPacked = (1 << 4), Configured = (1 << 5),
87  Removed = (1 << 6), // Early Remove
88  InList = (1 << 7),
89  After = (1 << 8),
90  States = (UnPacked | Configured | Removed)};
91 
92  // Flag manipulators
93  inline bool IsFlag(PkgIterator Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;};
94  inline bool IsFlag(Package *Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;};
95  void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~~F)) | State;};
96  inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
97  inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
98  // RmFlag removes a flag from a package
99  inline void RmFlag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] &= ~~F;};
100  // IsNow will return true if the Pkg has been not been either configured or unpacked
101  inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;};
102  bool IsMissing(PkgIterator Pkg) APT_PURE;
103  void WipeFlags(unsigned long F);
104  void SetFileList(std::string *FileList) {this->FileList = FileList;};
105 
106  // Accessors
107  inline iterator begin() {return List;};
108  inline iterator end() {return End;};
109  inline void push_back(Package *Pkg) {*(End++) = Pkg;};
110  inline void push_back(PkgIterator Pkg) {*(End++) = Pkg;};
111  inline void pop_back() {End--;};
112  inline bool empty() {return End == List;};
113  inline unsigned int size() {return End - List;};
114 
115  // Ordering modes
116  bool OrderCritical();
117  bool OrderUnpack(std::string *FileList = 0);
118  bool OrderConfigure();
119 
120  int Score(PkgIterator Pkg);
121 
122  explicit pkgOrderList(pkgDepCache *Cache);
123  virtual ~~pkgOrderList();
124 };
125 
126 #endif
pkgCache::PkgIterator PkgIterator
Definition: pkgcache.h:829
pkgCache::VerIterator VerIterator
Definition: pkgcache.h:830
pkgCache::DepIterator DepIterator
Definition: pkgcache.h:832
OkState State() const APT_PURE
VerFileIterator FileList() const
void pop_back()
Definition: orderlist.h:111
void Flag(PkgIterator Pkg, unsigned long F)
Definition: orderlist.h:96
bool IsNow(PkgIterator Pkg)
Definition: orderlist.h:101
bool empty()
Definition: orderlist.h:112
void push_back(PkgIterator Pkg)
Definition: orderlist.h:110
DepFunc Primary
Definition: orderlist.h:33
pkgDepCache & Cache
Definition: orderlist.h:29
void Flag(PkgIterator Pkg, unsigned long State, unsigned long F)
Definition: orderlist.h:95
void Flag(Package *Pkg, unsigned long F)
Definition: orderlist.h:97
std::string * FileList
Definition: orderlist.h:42
bool IsFlag(Package *Pkg, unsigned long F)
Definition: orderlist.h:94
DepFunc RevDepends
Definition: orderlist.h:35
bool IsFlag(PkgIterator Pkg, unsigned long F)
Definition: orderlist.h:93
unsigned short * Flags
Definition: orderlist.h:46
unsigned int size()
Definition: orderlist.h:113
void push_back(Package *Pkg)
Definition: orderlist.h:109
Package ** iterator
Definition: orderlist.h:76
void RmFlag(Package *Pkg, unsigned long F)
Definition: orderlist.h:99
int LoopCount
Definition: orderlist.h:44
Package ** End
Definition: orderlist.h:39
DepFunc Remove
Definition: orderlist.h:36
iterator end()
Definition: orderlist.h:108
bool Debug
Definition: orderlist.h:47
Package ** List
Definition: orderlist.h:40
Package ** AfterEnd
Definition: orderlist.h:41
iterator begin()
Definition: orderlist.h:107
void *const d
Definition: orderlist.h:26
void SetFileList(std::string *FileList)
Definition: orderlist.h:104
DepFunc Secondary
Definition: orderlist.h:34
#define APT_PURE
Definition: macros.h:56
#define APT_PUBLIC
Definition: macros.h:77
pkgCache - Structure definitions for the cache file
contains information for a single unique package
Definition: pkgcache.h:450
map_id_t ID
unique sequel ID
Definition: pkgcache.h:494