]> git.saurik.com Git - apt.git/blame - apt-pkg/orderlist.h
Merge bzip2-debs branch
[apt.git] / apt-pkg / orderlist.h
CommitLineData
6c139d6e
AL
1// -*- mode: cpp; mode: fold -*-
2// Description /*{{{*/
b2e465d6 3// $Id: orderlist.h,v 1.9 2001/02/20 07:03:17 jgg Exp $
6c139d6e
AL
4/* ######################################################################
5
6 Order List - Represents and Manipulates an ordered list of packages.
7
8 A list of packages can be ordered by a number of conflicting criteria
9 each given a specific priority. Each package also has a set of flags
b2e465d6 10 indicating some useful things about it that are derived in the
6c139d6e
AL
11 course of sorting. The pkgPackageManager class uses this class for
12 all of it's installation ordering needs.
13
14 ##################################################################### */
15 /*}}}*/
6c139d6e
AL
16#ifndef PKGLIB_ORDERLIST_H
17#define PKGLIB_ORDERLIST_H
18
19#ifdef __GNUG__
094a497d 20#pragma interface "apt-pkg/orderlist.h"
6c139d6e
AL
21#endif
22
094a497d 23#include <apt-pkg/pkgcache.h>
6c139d6e
AL
24
25class pkgDepCache;
b2e465d6 26class pkgOrderList : protected pkgCache::Namespace
6c139d6e
AL
27{
28 protected:
29
b2e465d6 30 pkgDepCache &Cache;
6c139d6e
AL
31 typedef bool (pkgOrderList::*DepFunc)(DepIterator D);
32
33 // These are the currently selected ordering functions
34 DepFunc Primary;
35 DepFunc Secondary;
36 DepFunc RevDepends;
37 DepFunc Remove;
38
39 // State
40 Package **End;
41 Package **List;
63d3141a 42 Package **AfterEnd;
281daf46 43 string *FileList;
6c139d6e
AL
44 DepIterator Loops[20];
45 int LoopCount;
46 int Depth;
63d3141a 47 unsigned short *Flags;
b2e465d6 48 bool Debug;
6c139d6e
AL
49
50 // Main visit function
51 bool VisitNode(PkgIterator Pkg);
52 bool VisitDeps(DepFunc F,PkgIterator Pkg);
53 bool VisitRDeps(DepFunc F,PkgIterator Pkg);
54 bool VisitRProvides(DepFunc F,VerIterator Ver);
3fb5f4e4 55 bool VisitProvides(DepIterator Pkg,bool Critical);
6c139d6e
AL
56
57 // Dependency checking functions.
58 bool DepUnPackCrit(DepIterator D);
59 bool DepUnPackPreD(DepIterator D);
60 bool DepUnPackPre(DepIterator D);
61 bool DepUnPackDep(DepIterator D);
62 bool DepConfigure(DepIterator D);
63 bool DepRemove(DepIterator D);
64
65 // Analysis helpers
66 bool AddLoop(DepIterator D);
67 bool CheckDep(DepIterator D);
68 bool DoRun();
69
70 // For pre sorting
71 static pkgOrderList *Me;
72 static int OrderCompareA(const void *a, const void *b);
73 static int OrderCompareB(const void *a, const void *b);
74 int FileCmp(PkgIterator A,PkgIterator B);
75
76 public:
77
78 typedef Package **iterator;
79
80 // State flags
81 enum Flags {Added = (1 << 0), AddPending = (1 << 1),
82 Immediate = (1 << 2), Loop = (1 << 3),
83 UnPacked = (1 << 4), Configured = (1 << 5),
9d4c8f67 84 Removed = (1 << 6), // Early Remove
6c139d6e 85 InList = (1 << 7),
63d3141a 86 After = (1 << 8),
6c139d6e
AL
87 States = (UnPacked | Configured | Removed)};
88
89 // Flag manipulators
90 inline bool IsFlag(PkgIterator Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;};
91 inline bool IsFlag(Package *Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;};
92 void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~F)) | State;};
93 inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
94 inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
9d4c8f67 95 inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;};
2fd65468 96 bool IsMissing(PkgIterator Pkg);
6c139d6e 97 void WipeFlags(unsigned long F);
2fd65468 98 void SetFileList(string *FileList) {this->FileList = FileList;};
bdae53f1 99
6c139d6e
AL
100 // Accessors
101 inline iterator begin() {return List;};
102 inline iterator end() {return End;};
103 inline void push_back(Package *Pkg) {*(End++) = Pkg;};
104 inline void push_back(PkgIterator Pkg) {*(End++) = Pkg;};
105 inline void pop_back() {End--;};
106 inline bool empty() {return End == List;};
107 inline unsigned int size() {return End - List;};
108
109 // Ordering modes
110 bool OrderCritical();
281daf46 111 bool OrderUnpack(string *FileList = 0);
6c139d6e
AL
112 bool OrderConfigure();
113
114 int Score(PkgIterator Pkg);
115
b2e465d6 116 pkgOrderList(pkgDepCache *Cache);
6c139d6e
AL
117 ~pkgOrderList();
118};
119
120#endif