]>
git.saurik.com Git - apt.git/blob - apt-pkg/orderlist.h
1 // -*- mode: cpp; mode: fold -*-
3 // $Id: orderlist.h,v 1.2 1998/07/12 23:58:29 jgg Exp $
4 /* ######################################################################
6 Order List - Represents and Manipulates an ordered list of packages.
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
10 indicating some usefull things about it that are derived in the
11 course of sorting. The pkgPackageManager class uses this class for
12 all of it's installation ordering needs.
14 ##################################################################### */
16 // Header section: pkglib
17 #ifndef PKGLIB_ORDERLIST_H
18 #define PKGLIB_ORDERLIST_H
21 #pragma interface "apt-pkg/orderlist.h"
24 #include <apt-pkg/pkgcache.h>
33 // Bring some usefull types into the local scope
34 typedef pkgCache::PkgIterator PkgIterator
;
35 typedef pkgCache::VerIterator VerIterator
;
36 typedef pkgCache::DepIterator DepIterator
;
37 typedef pkgCache::PrvIterator PrvIterator
;
38 typedef pkgCache::Package Package
;
39 typedef pkgCache::Version Version
;
40 typedef bool (pkgOrderList::*DepFunc
)(DepIterator D
);
42 // These are the currently selected ordering functions
51 DepIterator Loops
[20];
56 // Main visit function
57 bool VisitNode(PkgIterator Pkg
);
58 bool VisitDeps(DepFunc F
,PkgIterator Pkg
);
59 bool VisitRDeps(DepFunc F
,PkgIterator Pkg
);
60 bool VisitRProvides(DepFunc F
,VerIterator Ver
);
61 bool VisitProvides(DepIterator Pkg
);
63 // Dependency checking functions.
64 bool DepUnPackCrit(DepIterator D
);
65 bool DepUnPackPreD(DepIterator D
);
66 bool DepUnPackPre(DepIterator D
);
67 bool DepUnPackDep(DepIterator D
);
68 bool DepConfigure(DepIterator D
);
69 bool DepRemove(DepIterator D
);
72 bool AddLoop(DepIterator D
);
73 bool CheckDep(DepIterator D
);
77 static pkgOrderList
*Me
;
78 static int OrderCompareA(const void *a
, const void *b
);
79 static int OrderCompareB(const void *a
, const void *b
);
80 int FileCmp(PkgIterator A
,PkgIterator B
);
84 typedef Package
**iterator
;
87 enum Flags
{Added
= (1 << 0), AddPending
= (1 << 1),
88 Immediate
= (1 << 2), Loop
= (1 << 3),
89 UnPacked
= (1 << 4), Configured
= (1 << 5),
92 States
= (UnPacked
| Configured
| Removed
)};
95 inline bool IsFlag(PkgIterator Pkg
,unsigned long F
) {return (Flags
[Pkg
->ID
] & F
) == F
;};
96 inline bool IsFlag(Package
*Pkg
,unsigned long F
) {return (Flags
[Pkg
->ID
] & F
) == F
;};
97 void Flag(PkgIterator Pkg
,unsigned long State
, unsigned long F
) {Flags
[Pkg
->ID
] = (Flags
[Pkg
->ID
] & (~F
)) | State
;};
98 inline void Flag(PkgIterator Pkg
,unsigned long F
) {Flags
[Pkg
->ID
] |= F
;};
99 inline void Flag(Package
*Pkg
,unsigned long F
) {Flags
[Pkg
->ID
] |= F
;};
100 inline bool IsNow(PkgIterator Pkg
) {return (Flags
[Pkg
->ID
] & States
) == 0;};
101 void WipeFlags(unsigned long F
);
104 inline iterator
begin() {return List
;};
105 inline iterator
end() {return End
;};
106 inline void push_back(Package
*Pkg
) {*(End
++) = Pkg
;};
107 inline void push_back(PkgIterator Pkg
) {*(End
++) = Pkg
;};
108 inline void pop_back() {End
--;};
109 inline bool empty() {return End
== List
;};
110 inline unsigned int size() {return End
- List
;};
113 bool OrderCritical();
115 bool OrderConfigure();
117 int Score(PkgIterator Pkg
);
119 pkgOrderList(pkgDepCache
&Cache
);