]>
Commit | Line | Data |
---|---|---|
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 | ||
6c139d6e | 19 | |
094a497d | 20 | #include <apt-pkg/pkgcache.h> |
3b8d1773 | 21 | #include <apt-pkg/macros.h> |
6c139d6e AL |
22 | |
23 | class pkgDepCache; | |
b2e465d6 | 24 | class pkgOrderList : protected pkgCache::Namespace |
6c139d6e AL |
25 | { |
26 | protected: | |
27 | ||
b2e465d6 | 28 | pkgDepCache &Cache; |
6c139d6e AL |
29 | typedef bool (pkgOrderList::*DepFunc)(DepIterator D); |
30 | ||
31 | // These are the currently selected ordering functions | |
32 | DepFunc Primary; | |
33 | DepFunc Secondary; | |
34 | DepFunc RevDepends; | |
35 | DepFunc Remove; | |
36 | ||
37 | // State | |
38 | Package **End; | |
39 | Package **List; | |
63d3141a | 40 | Package **AfterEnd; |
281daf46 | 41 | string *FileList; |
6c139d6e AL |
42 | DepIterator Loops[20]; |
43 | int LoopCount; | |
44 | int Depth; | |
63d3141a | 45 | unsigned short *Flags; |
b2e465d6 | 46 | bool Debug; |
6c139d6e AL |
47 | |
48 | // Main visit function | |
3b8d1773 DK |
49 | __deprecated bool VisitNode(PkgIterator Pkg) { return VisitNode(Pkg, "UNKNOWN"); }; |
50 | bool VisitNode(PkgIterator Pkg, char const* from); | |
6c139d6e AL |
51 | bool VisitDeps(DepFunc F,PkgIterator Pkg); |
52 | bool VisitRDeps(DepFunc F,PkgIterator Pkg); | |
53 | bool VisitRProvides(DepFunc F,VerIterator Ver); | |
3fb5f4e4 | 54 | bool VisitProvides(DepIterator Pkg,bool Critical); |
6c139d6e AL |
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 | static pkgOrderList *Me; | |
71 | static int OrderCompareA(const void *a, const void *b); | |
72 | static int OrderCompareB(const void *a, const void *b); | |
73 | int FileCmp(PkgIterator A,PkgIterator B); | |
74 | ||
75 | public: | |
76 | ||
77 | typedef Package **iterator; | |
78 | ||
79 | // State flags | |
80 | enum Flags {Added = (1 << 0), AddPending = (1 << 1), | |
81 | Immediate = (1 << 2), Loop = (1 << 3), | |
82 | UnPacked = (1 << 4), Configured = (1 << 5), | |
9d4c8f67 | 83 | Removed = (1 << 6), // Early Remove |
6c139d6e | 84 | InList = (1 << 7), |
63d3141a | 85 | After = (1 << 8), |
6c139d6e AL |
86 | States = (UnPacked | Configured | Removed)}; |
87 | ||
88 | // Flag manipulators | |
89 | inline bool IsFlag(PkgIterator Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;}; | |
90 | inline bool IsFlag(Package *Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;}; | |
91 | void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~F)) | State;}; | |
92 | inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;}; | |
93 | inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;}; | |
9d4c8f67 | 94 | inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;}; |
2fd65468 | 95 | bool IsMissing(PkgIterator Pkg); |
6c139d6e | 96 | void WipeFlags(unsigned long F); |
2fd65468 | 97 | void SetFileList(string *FileList) {this->FileList = FileList;}; |
bdae53f1 | 98 | |
6c139d6e AL |
99 | // Accessors |
100 | inline iterator begin() {return List;}; | |
101 | inline iterator end() {return End;}; | |
102 | inline void push_back(Package *Pkg) {*(End++) = Pkg;}; | |
103 | inline void push_back(PkgIterator Pkg) {*(End++) = Pkg;}; | |
104 | inline void pop_back() {End--;}; | |
105 | inline bool empty() {return End == List;}; | |
106 | inline unsigned int size() {return End - List;}; | |
107 | ||
108 | // Ordering modes | |
109 | bool OrderCritical(); | |
281daf46 | 110 | bool OrderUnpack(string *FileList = 0); |
6c139d6e AL |
111 | bool OrderConfigure(); |
112 | ||
113 | int Score(PkgIterator Pkg); | |
114 | ||
b2e465d6 | 115 | pkgOrderList(pkgDepCache *Cache); |
6c139d6e AL |
116 | ~pkgOrderList(); |
117 | }; | |
118 | ||
119 | #endif |