2 * Copyright (c) 2001, Robert Collins.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 #ifndef SETUP_PACKAGE_DB_H
17 #define SETUP_PACKAGE_DB_H
19 /* required to parse this file */
25 class PackageSpecification
;
33 typedef std::vector
<packagemeta
*>::iterator PackageDBConnectedIterator
;
37 /*TODO: add sanity. Beware, Here Be C++ Dragons:
39 This class is a hidden singleton. It's a singleton, but you create
40 and delete transient objects of the class, none of which have any
41 member data, but solely serve as shortcuts to access one static set
42 of shared data through an irrelevant this-pointer.
44 Not only that, but it's a hidden singleton that is constructed
45 the first time you access it, and constructed differently
46 based on implicit global state.
48 Not only that, but it has some static state of its own that also
49 controls how it gets constructed, but that could then be changed
50 afterward without invalidating the cached data, silently changing
51 its semantic interpretation.
53 To use this class, you must first set the packagedb::task member
54 and the cygfile:// (install dir) root path. You must only then
55 construct a packagedb, and must remember not to change the
56 task or root path any later in the execution sequence.
61 #include <PackageTrust.h>
71 /* Set the database to a "no changes requested" state. */
74 packagemeta
* findBinary (PackageSpecification
const &) const;
75 packageversion
findBinaryVersion (PackageSpecification
const &) const;
76 packagemeta
* findSource (PackageSpecification
const &) const;
77 packageversion
findSourceVersion (PackageSpecification
const &spec
) const;
78 packagemeta
* addBinary (const std::string
&pkgname
, const SolverPool::addPackageData
&pkgdata
);
79 packageversion
addSource (const std::string
&pkgname
, const SolverPool::addPackageData
&pkgdata
);
81 PackageDBConnectedIterator
connectedBegin();
82 PackageDBConnectedIterator
connectedEnd();
84 void defaultTrust (SolverTasks
&q
, SolverSolution::updateMode mode
, bool test
);
86 typedef std::map
<std::string
, packagemeta
*> packagecollection
;
87 /* all seen binary packages */
88 static packagecollection packages
;
89 /* all seen source packages */
90 static packagecollection sourcePackages
;
91 /* all seen categories */
92 typedef std::map
<std::string
, std::vector
<packagemeta
*>, casecompare_lt_op
> categoriesType
;
93 static categoriesType categories
;
94 static PackageDBActions task
;
95 /* a ficitious package that requires all packages in the Base category */
96 static packageversion basepkg
;
98 static SolverPool solver
;
99 static SolverSolution solution
;
106 void fixup_source_package_ids();
107 void removeEmptyCategories();
108 void fillMissingCategory();
110 void guessUserPicked(void);
112 static int installeddbread
; /* do we have to reread this */
113 static int installeddbver
;
116 friend class ConnectedLoopFinder
;
117 static std::vector
<packagemeta
*> dependencyOrderedPackages
;
120 #endif /* SETUP_PACKAGE_DB_H */