]>
Commit | Line | Data |
---|---|---|
7939f6d1 RC |
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 | ||
fa0c0d10 | 19 | class packageversion; |
bb849dbd | 20 | class packagemeta; |
4fe323f9 | 21 | class category; |
7939f6d1 | 22 | |
bb849dbd | 23 | /* Required to parse this completely */ |
3c196821 | 24 | #include <set> |
3c054baf | 25 | #include "String++.h" |
4fe323f9 | 26 | #include "category.h" |
076654e7 | 27 | #include "PackageTrust.h" |
3c196821 | 28 | #include "package_version.h" |
bb849dbd | 29 | |
bb849dbd | 30 | /* NOTE: A packagemeta without 1 packageversion is invalid! */ |
7939f6d1 RC |
31 | class packagemeta |
32 | { | |
33 | public: | |
3c196821 | 34 | packagemeta (packagemeta const &); |
076654e7 | 35 | packagemeta (String const &pkgname):name (pkgname), key(pkgname), installed_from (), |
3c196821 RC |
36 | prevtimestamp (0), currtimestamp (0), |
37 | exptimestamp (0), architecture (), priority() | |
7939f6d1 | 38 | { |
3c054baf | 39 | } |
fa0c0d10 | 40 | |
3c054baf RC |
41 | packagemeta (String const &pkgname, |
42 | String const &installedfrom):name (pkgname), key(pkgname), | |
43 | installed_from (installedfrom), | |
3c196821 RC |
44 | prevtimestamp (0), currtimestamp (0), |
45 | exptimestamp (0), architecture (), priority() | |
fa0c0d10 | 46 | { |
fa0c0d10 RC |
47 | }; |
48 | ||
7c6ef2c3 | 49 | ~packagemeta (); |
7939f6d1 | 50 | |
fa0c0d10 RC |
51 | void add_version (packageversion &); |
52 | void set_installed (packageversion &); | |
7e8fc33c RC |
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; | |
3c196821 RC |
74 | void set_action (packageversion const &default_version); |
75 | void set_action (_actions, packageversion const & default_version); | |
fa0c0d10 | 76 | void uninstall (); |
97647369 | 77 | int set_requirements (trusts deftrust = TRUST_CURR, size_t depth = 0); |
7939f6d1 | 78 | |
3c054baf | 79 | String action_caption (); |
3c196821 | 80 | packageversion trustp (trusts const t) const |
97647369 RC |
81 | { |
82 | return t == TRUST_PREV ? (prev ? prev : (curr ? curr : installed)) | |
83 | : t == TRUST_CURR ? (curr ? curr : installed) | |
2fa7c5a4 | 84 | : exp ? exp : installed; |
97647369 | 85 | } |
cbfc4215 | 86 | |
3c054baf RC |
87 | String name; /* package name, like "cygwin" */ |
88 | String key; | |
fa0c0d10 | 89 | /* legacy variable used to output data for installed.db versions <= 2 */ |
3c054baf | 90 | String installed_from; |
bb849dbd RC |
91 | /* SDesc is global in theory, across all package versions. |
92 | LDesc is not: it can be different per version */ | |
3c054baf | 93 | String const SDesc () const; |
bb849dbd RC |
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 | */ | |
0cf68afd | 97 | void add_category (String const &); |
405d7186 | 98 | set <String, String::caseless> categories; |
3c196821 | 99 | set <packageversion> versions; |
fa0c0d10 | 100 | |
7939f6d1 | 101 | /* which one is installed. */ |
3c196821 | 102 | packageversion installed; |
7939f6d1 | 103 | /* which one is listed as "prev" in our available packages db */ |
3c196821 | 104 | packageversion prev; |
bb849dbd RC |
105 | /* And what was the timestamp of the ini it was found from */ |
106 | unsigned int prevtimestamp; | |
7939f6d1 | 107 | /* ditto for current - stable */ |
3c196821 | 108 | packageversion curr; |
bb849dbd | 109 | unsigned int currtimestamp; |
7939f6d1 | 110 | /* and finally the experimental version */ |
3c196821 | 111 | packageversion exp; |
bb849dbd RC |
112 | unsigned int exptimestamp; |
113 | /* Now for the user stuff :] */ | |
114 | /* What version does the user want ? */ | |
3c196821 | 115 | packageversion desired; |
7e8fc33c | 116 | |
aa1e3b4d RC |
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 | ||
3c196821 RC |
128 | /* can one or more versions be installed? */ |
129 | bool accessible () const; | |
130 | bool sourceAccessible() const; | |
131 | ||
cbfc4215 | 132 | protected: |
cbfc4215 | 133 | packagemeta &operator= (packagemeta const &); |
7939f6d1 RC |
134 | }; |
135 | ||
136 | #endif /* _PACKAGE_META_H_ */ |