Regenerate Japanese resources
[cygwin-setup.git] / package_db.h
blob3886bf22fd576d0e966486f1ae364506db6ff961
1 /*
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
10 * http://www.gnu.org/
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 */
20 #include <vector>
21 #include <map>
22 #include "String++.h"
23 class packagemeta;
24 class io_stream;
25 class PackageSpecification;
27 typedef enum {
28 PackageDB_Install,
29 PackageDB_Download
30 } PackageDBActions;
32 class packagedb;
33 typedef std::vector <packagemeta *>::iterator PackageDBConnectedIterator;
35 /*TODO: add mutexs */
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 "libsolv.h"
61 #include <PackageTrust.h>
63 class packagedb
65 public:
66 packagedb ();
67 void init();
68 /* 0 on success */
69 int flush ();
70 void prep();
71 /* Set the database to a "no changes requested" state. */
72 void noChanges ();
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;
101 private:
102 void makeBase();
103 void makeWindows();
104 void read();
105 void upgrade ();
106 void fixup_source_package_ids();
107 void removeEmptyCategories();
108 void fillMissingCategory();
109 void setExistence();
110 void guessUserPicked(void);
112 static int installeddbread; /* do we have to reread this */
113 static int installeddbver;
114 static bool prepped;
116 friend class ConnectedLoopFinder;
117 static std::vector <packagemeta *> dependencyOrderedPackages;
120 #endif /* SETUP_PACKAGE_DB_H */