apt @VERSION@
|
00001 // -*- mode: cpp; mode: fold -*- 00002 // Description /*{{{*/ 00003 // $Id: orderlist.h,v 1.9 2001/02/20 07:03:17 jgg Exp $ 00004 /* ###################################################################### 00005 00006 Order List - Represents and Manipulates an ordered list of packages. 00007 00008 A list of packages can be ordered by a number of conflicting criteria 00009 each given a specific priority. Each package also has a set of flags 00010 indicating some useful things about it that are derived in the 00011 course of sorting. The pkgPackageManager class uses this class for 00012 all of it's installation ordering needs. 00013 00014 ##################################################################### */ 00015 /*}}}*/ 00016 #ifndef PKGLIB_ORDERLIST_H 00017 #define PKGLIB_ORDERLIST_H 00018 00019 00020 #include <apt-pkg/pkgcache.h> 00021 00022 class pkgDepCache; 00023 class pkgOrderList : protected pkgCache::Namespace 00024 { 00025 protected: 00026 00027 pkgDepCache &Cache; 00028 typedef bool (pkgOrderList::*DepFunc)(DepIterator D); 00029 00030 // These are the currently selected ordering functions 00031 DepFunc Primary; 00032 DepFunc Secondary; 00033 DepFunc RevDepends; 00034 DepFunc Remove; 00035 00036 // State 00037 Package **End; 00038 Package **List; 00039 Package **AfterEnd; 00040 string *FileList; 00041 DepIterator Loops[20]; 00042 int LoopCount; 00043 int Depth; 00044 unsigned short *Flags; 00045 bool Debug; 00046 00047 // Main visit function 00048 bool VisitNode(PkgIterator Pkg); 00049 bool VisitDeps(DepFunc F,PkgIterator Pkg); 00050 bool VisitRDeps(DepFunc F,PkgIterator Pkg); 00051 bool VisitRProvides(DepFunc F,VerIterator Ver); 00052 bool VisitProvides(DepIterator Pkg,bool Critical); 00053 00054 // Dependency checking functions. 00055 bool DepUnPackCrit(DepIterator D); 00056 bool DepUnPackPreD(DepIterator D); 00057 bool DepUnPackPre(DepIterator D); 00058 bool DepUnPackDep(DepIterator D); 00059 bool DepConfigure(DepIterator D); 00060 bool DepRemove(DepIterator D); 00061 00062 // Analysis helpers 00063 bool AddLoop(DepIterator D); 00064 bool CheckDep(DepIterator D); 00065 bool DoRun(); 00066 00067 // For pre sorting 00068 static pkgOrderList *Me; 00069 static int OrderCompareA(const void *a, const void *b); 00070 static int OrderCompareB(const void *a, const void *b); 00071 int FileCmp(PkgIterator A,PkgIterator B); 00072 00073 public: 00074 00075 typedef Package **iterator; 00076 00077 // State flags 00078 enum Flags {Added = (1 << 0), AddPending = (1 << 1), 00079 Immediate = (1 << 2), Loop = (1 << 3), 00080 UnPacked = (1 << 4), Configured = (1 << 5), 00081 Removed = (1 << 6), // Early Remove 00082 InList = (1 << 7), 00083 After = (1 << 8), 00084 States = (UnPacked | Configured | Removed)}; 00085 00086 // Flag manipulators 00087 inline bool IsFlag(PkgIterator Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;}; 00088 inline bool IsFlag(Package *Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;}; 00089 void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~F)) | State;}; 00090 inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;}; 00091 inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;}; 00092 inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & (States & (~Removed))) == 0;}; 00093 bool IsMissing(PkgIterator Pkg); 00094 void WipeFlags(unsigned long F); 00095 void SetFileList(string *FileList) {this->FileList = FileList;}; 00096 00097 // Accessors 00098 inline iterator begin() {return List;}; 00099 inline iterator end() {return End;}; 00100 inline void push_back(Package *Pkg) {*(End++) = Pkg;}; 00101 inline void push_back(PkgIterator Pkg) {*(End++) = Pkg;}; 00102 inline void pop_back() {End--;}; 00103 inline bool empty() {return End == List;}; 00104 inline unsigned int size() {return End - List;}; 00105 00106 // Ordering modes 00107 bool OrderCritical(); 00108 bool OrderUnpack(string *FileList = 0); 00109 bool OrderConfigure(); 00110 00111 int Score(PkgIterator Pkg); 00112 00113 pkgOrderList(pkgDepCache *Cache); 00114 ~pkgOrderList(); 00115 }; 00116 00117 #endif