]> cygwin.com Git - cygwin-apps/setup.git/blob - package_meta.h
2006-04-16 Max Bowsher <maxb1@ukf.net>
[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 "String++.h"
26 #include "PackageTrust.h"
27 #include "package_version.h"
28
29 typedef std::pair<String const, 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 (String const &pkgname):name (pkgname), key(pkgname), installed_from (),
38 prevtimestamp (0), currtimestamp (0),
39 exptimestamp (0), architecture (), priority(), visited_(false)
40 {
41 }
42
43 packagemeta (String const &pkgname,
44 String const &installedfrom):name (pkgname), key(pkgname),
45 installed_from (installedfrom),
46 prevtimestamp (0), currtimestamp (0),
47 exptimestamp (0), architecture (), priority(), visited_(false)
48 {
49 }
50
51 ~packagemeta ();
52
53 void add_version (packageversion &);
54 void set_installed (packageversion &);
55 void visited(bool const &);
56 bool visited() const;
57 bool hasNoCategories() const;
58 void setDefaultCategories();
59 void addToCategoryAll();
60
61 class _actions
62 {
63 public:
64 _actions ():_value (0) {};
65 _actions (int aInt) {
66 _value = aInt;
67 if (_value < 0 || _value > 3)
68 _value = 0;
69 }
70 _actions & operator ++ ();
71 bool operator == (_actions const &rhs) { return _value == rhs._value; }
72 bool operator != (_actions const &rhs) { return _value != rhs._value; }
73 const char *caption ();
74 private:
75 int _value;
76 };
77 static const _actions Default_action;
78 static const _actions Install_action;
79 static const _actions Reinstall_action;
80 static const _actions Uninstall_action;
81 void set_action (packageversion const &default_version);
82 void set_action (_actions, packageversion const & default_version);
83 void uninstall ();
84 int set_requirements (trusts deftrust, size_t depth);
85 // explicit separation for generic programming.
86 int set_requirements (trusts deftrust)
87 { return set_requirements (deftrust, 0); }
88
89 String action_caption () const;
90 packageversion trustp (trusts const t) const
91 {
92 return t == TRUST_PREV ? (prev ? prev : (curr ? curr : installed))
93 : t == TRUST_CURR ? (curr ? curr : installed)
94 : exp ? exp : installed;
95 }
96
97 String name; /* package name, like "cygwin" */
98 String key;
99 /* legacy variable used to output data for installed.db versions <= 2 */
100 String installed_from;
101 /* SDesc is global in theory, across all package versions.
102 LDesc is not: it can be different per version */
103 String const SDesc () const;
104 /* what categories does this package belong in. Note that if multiple versions
105 * of a package disagree.... the first one read in will take precedence.
106 */
107 void add_category (String const &);
108 std::set <String, String::caseless> categories;
109 String const getReadableCategoryList () const;
110 std::set <packageversion> versions;
111
112 /* which one is installed. */
113 packageversion installed;
114 /* which one is listed as "prev" in our available packages db */
115 packageversion prev;
116 /* And what was the timestamp of the ini it was found from */
117 unsigned int prevtimestamp;
118 /* ditto for current - stable */
119 packageversion curr;
120 unsigned int currtimestamp;
121 /* and finally the experimental version */
122 packageversion exp;
123 unsigned int exptimestamp;
124 /* Now for the user stuff :] */
125 /* What version does the user want ? */
126 packageversion desired;
127
128 /* What platform is this for ?
129 * i386 - linux i386
130 * cygwin - cygwin for 32 bit MS Windows
131 * All - no binary code, or a version for every platform
132 */
133 String architecture;
134 /* What priority does this package have?
135 * TODO: this should be linked into a list of priorities.
136 */
137 String priority;
138
139 /* can one or more versions be installed? */
140 bool accessible () const;
141 bool sourceAccessible() const;
142
143 void logSelectionStatus() const;
144 void logAllVersions() const;
145
146 protected:
147 packagemeta &operator= (packagemeta const &);
148 private:
149 String trustLabel(packageversion const &) const;
150 bool visited_;
151 };
152
153 #endif /* SETUP_PACKAGE_META_H */
This page took 0.045941 seconds and 6 git commands to generate.