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.
60 #include <PackageTrust.h>
68 packagemeta
* findBinary (PackageSpecification
const &) const;
69 packagemeta
* findSource (PackageSpecification
const &) const;
70 PackageDBConnectedIterator
connectedBegin();
71 PackageDBConnectedIterator
connectedEnd();
72 void fillMissingCategory();
73 void defaultTrust (trusts trust
);
76 typedef std::map
<std::string
, packagemeta
*> packagecollection
;
77 /* all seen binary packages */
78 static packagecollection packages
;
79 /* all seen source packages */
80 static packagecollection sourcePackages
;
81 /* all seen categories */
82 typedef std::map
<std::string
, std::vector
<packagemeta
*>, casecompare_lt_op
> categoriesType
;
83 static categoriesType categories
;
84 static PackageDBActions task
;
86 static int installeddbread
; /* do we have to reread this */
87 friend class ConnectedLoopFinder
;
88 static std::vector
<packagemeta
*> dependencyOrderedPackages
;
91 #endif /* SETUP_PACKAGE_DB_H */