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