]> cygwin.com Git - cygwin-apps/setup.git/blob - package_meta.h
* res.rc: Remove Prev button from chooser page.
[cygwin-apps/setup.git] / package_meta.h
1 /*
2 * Copyright (c) 2001, 2003 Robert Collins.
3 *
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.
8 *
9 * A copy of the GNU General Public License can be found at
10 * http://www.gnu.org/
11 *
12 * Written by Robert Collins <rbtcollins@hotmail.com>
13 *
14 */
15
16 #ifndef SETUP_PACKAGE_META_H
17 #define SETUP_PACKAGE_META_H
18
19 class packageversion;
20 class packagemeta;
21 class category;
22
23 /* Required to parse this completely */
24 #include <set>
25 #include "PackageTrust.h"
26 #include "package_version.h"
27 #include "package_message.h"
28
29 typedef std::pair<const std::string, std::vector<packagemeta *> > Category;
30
31 /* NOTE: A packagemeta without 1 packageversion is invalid! */
32 class packagemeta
33 {
34 public:
35 static void ScanDownloadedFiles();
36 packagemeta (packagemeta const &);
37 packagemeta (const std::string& pkgname):name (pkgname), key(pkgname), installed_from (),
38 architecture (), priority(), visited_(false)
39 {
40 }
41
42 packagemeta (const std::string& pkgname,
43 const std::string& installedfrom):name (pkgname), key(pkgname),
44 installed_from (installedfrom),
45 architecture (), priority(), visited_(false)
46 {
47 }
48
49 ~packagemeta ();
50
51 void add_version (packageversion &);
52 void set_installed (packageversion &);
53 void visited(bool const &);
54 bool visited() const;
55 void addToCategoryBase();
56 bool hasNoCategories() const;
57 void setDefaultCategories();
58 void addToCategoryAll();
59
60 class _actions
61 {
62 public:
63 _actions ():_value (0) {};
64 _actions (int aInt) {
65 _value = aInt;
66 if (_value < 0 || _value > 3)
67 _value = 0;
68 }
69 _actions & operator ++ ();
70 bool operator == (_actions const &rhs) { return _value == rhs._value; }
71 bool operator != (_actions const &rhs) { return _value != rhs._value; }
72 const char *caption ();
73 private:
74 int _value;
75 };
76 static const _actions Default_action;
77 static const _actions Install_action;
78 static const _actions Reinstall_action;
79 static const _actions Uninstall_action;
80 void set_action (packageversion const &default_version);
81 void set_action (_actions, packageversion const & default_version);
82 void uninstall ();
83 int set_requirements (trusts deftrust, size_t depth);
84 // explicit separation for generic programming.
85 int set_requirements (trusts deftrust)
86 { return set_requirements (deftrust, 0); }
87 void set_message (const std::string& message_id, const std::string& message_string)
88 {
89 message.set (message_id, message_string);
90 }
91
92 std::string action_caption () const;
93 packageversion trustp (trusts const t) const
94 {
95 if (t == TRUST_TEST && exp)
96 return exp;
97 else if (curr)
98 return curr;
99 else
100 return installed;
101 }
102
103 std::string name; /* package name, like "cygwin" */
104 std::string key;
105 /* legacy variable used to output data for installed.db versions <= 2 */
106 std::string installed_from;
107 /* true if package was selected on command-line. */
108 bool isManuallyWanted() const;
109 /* SDesc is global in theory, across all package versions.
110 LDesc is not: it can be different per version */
111 const std::string SDesc () const;
112 /* what categories does this package belong in. Note that if multiple versions
113 * of a package disagree.... the first one read in will take precedence.
114 */
115 void add_category (const std::string& );
116 std::set <std::string, casecompare_lt_op> categories;
117 const std::string getReadableCategoryList () const;
118 std::set <packageversion> versions;
119
120 /* which one is installed. */
121 packageversion installed;
122 /* which one is listed as "prev" in our available packages db */
123 packageversion prev;
124 /* ditto for current - stable */
125 packageversion curr;
126 /* and finally the experimental version */
127 packageversion exp;
128 /* Now for the user stuff :] */
129 /* What version does the user want ? */
130 packageversion desired;
131
132 /* What platform is this for ?
133 * i386 - linux i386
134 * cygwin - cygwin for 32 bit MS Windows
135 * All - no binary code, or a version for every platform
136 */
137 std::string architecture;
138 /* What priority does this package have?
139 * TODO: this should be linked into a list of priorities.
140 */
141 std::string priority;
142
143 packagemessage message;
144
145 /* can one or more versions be installed? */
146 bool accessible () const;
147 bool sourceAccessible() const;
148
149 void logSelectionStatus() const;
150 void logAllVersions() const;
151
152 protected:
153 packagemeta &operator= (packagemeta const &);
154 private:
155 std::string trustLabel(packageversion const &) const;
156 bool visited_;
157 };
158
159 #endif /* SETUP_PACKAGE_META_H */
This page took 0.046253 seconds and 6 git commands to generate.