summaryrefslogtreecommitdiff
path: root/apt-pkg/orderlist.h
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:50:41 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:50:41 +0000
commit6c139d6e362f04a1582e8a8f511f8aeab031fecf (patch)
treec200b8f51da9bcfe612b7ceb645e6eec9ebac9f1 /apt-pkg/orderlist.h
parent2246928b428c3ece2c2743da5b0bb63257e37a85 (diff)
Sync
Author: jgg Date: 1998-07-07 04:17:00 GMT Sync
Diffstat (limited to 'apt-pkg/orderlist.h')
-rw-r--r--apt-pkg/orderlist.h123
1 files changed, 123 insertions, 0 deletions
diff --git a/apt-pkg/orderlist.h b/apt-pkg/orderlist.h
new file mode 100644
index 000000000..0dc8a5038
--- /dev/null
+++ b/apt-pkg/orderlist.h
@@ -0,0 +1,123 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: orderlist.h,v 1.1 1998/07/07 04:17:01 jgg Exp $
+/* ######################################################################
+
+ Order List - Represents and Manipulates an ordered list of packages.
+
+ A list of packages can be ordered by a number of conflicting criteria
+ each given a specific priority. Each package also has a set of flags
+ indicating some usefull things about it that are derived in the
+ course of sorting. The pkgPackageManager class uses this class for
+ all of it's installation ordering needs.
+
+ ##################################################################### */
+ /*}}}*/
+// Header section: pkglib
+#ifndef PKGLIB_ORDERLIST_H
+#define PKGLIB_ORDERLIST_H
+
+#ifdef __GNUG__
+#pragma interface "pkglib/orderlist.h"
+#endif
+
+#include <pkglib/pkgcache.h>
+
+class pkgDepCache;
+class pkgOrderList
+{
+ protected:
+
+ pkgDepCache &Cache;
+
+ // Bring some usefull types into the local scope
+ typedef pkgCache::PkgIterator PkgIterator;
+ typedef pkgCache::VerIterator VerIterator;
+ typedef pkgCache::DepIterator DepIterator;
+ typedef pkgCache::PrvIterator PrvIterator;
+ typedef pkgCache::Package Package;
+ typedef pkgCache::Version Version;
+ typedef bool (pkgOrderList::*DepFunc)(DepIterator D);
+
+ // These are the currently selected ordering functions
+ DepFunc Primary;
+ DepFunc Secondary;
+ DepFunc RevDepends;
+ DepFunc Remove;
+
+ // State
+ Package **End;
+ Package **List;
+ DepIterator Loops[20];
+ int LoopCount;
+ int Depth;
+ unsigned char *Flags;
+
+ // Main visit function
+ bool VisitNode(PkgIterator Pkg);
+ bool VisitDeps(DepFunc F,PkgIterator Pkg);
+ bool VisitRDeps(DepFunc F,PkgIterator Pkg);
+ bool VisitRProvides(DepFunc F,VerIterator Ver);
+ bool VisitProvides(DepIterator Pkg);
+
+ // Dependency checking functions.
+ bool DepUnPackCrit(DepIterator D);
+ bool DepUnPackPreD(DepIterator D);
+ bool DepUnPackPre(DepIterator D);
+ bool DepUnPackDep(DepIterator D);
+ bool DepConfigure(DepIterator D);
+ bool DepRemove(DepIterator D);
+
+ // Analysis helpers
+ bool AddLoop(DepIterator D);
+ bool CheckDep(DepIterator D);
+ bool DoRun();
+
+ // For pre sorting
+ static pkgOrderList *Me;
+ static int OrderCompareA(const void *a, const void *b);
+ static int OrderCompareB(const void *a, const void *b);
+ int FileCmp(PkgIterator A,PkgIterator B);
+
+ public:
+
+ typedef Package **iterator;
+
+ // State flags
+ enum Flags {Added = (1 << 0), AddPending = (1 << 1),
+ Immediate = (1 << 2), Loop = (1 << 3),
+ UnPacked = (1 << 4), Configured = (1 << 5),
+ Removed = (1 << 6),
+ InList = (1 << 7),
+ States = (UnPacked | Configured | Removed)};
+
+ // Flag manipulators
+ inline bool IsFlag(PkgIterator Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;};
+ inline bool IsFlag(Package *Pkg,unsigned long F) {return (Flags[Pkg->ID] & F) == F;};
+ void Flag(PkgIterator Pkg,unsigned long State, unsigned long F) {Flags[Pkg->ID] = (Flags[Pkg->ID] & (~F)) | State;};
+ inline void Flag(PkgIterator Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
+ inline void Flag(Package *Pkg,unsigned long F) {Flags[Pkg->ID] |= F;};
+ inline bool IsNow(PkgIterator Pkg) {return (Flags[Pkg->ID] & States) == 0;};
+ void WipeFlags(unsigned long F);
+
+ // Accessors
+ inline iterator begin() {return List;};
+ inline iterator end() {return End;};
+ inline void push_back(Package *Pkg) {*(End++) = Pkg;};
+ inline void push_back(PkgIterator Pkg) {*(End++) = Pkg;};
+ inline void pop_back() {End--;};
+ inline bool empty() {return End == List;};
+ inline unsigned int size() {return End - List;};
+
+ // Ordering modes
+ bool OrderCritical();
+ bool OrderUnpack();
+ bool OrderConfigure();
+
+ int Score(PkgIterator Pkg);
+
+ pkgOrderList(pkgDepCache &Cache);
+ ~pkgOrderList();
+};
+
+#endif