]> cygwin.com Git - cygwin-apps/setup.git/blame - package_meta.h
2002-04-23 Robert Collins <rbtcollins@hotmail.com>
[cygwin-apps/setup.git] / package_meta.h
CommitLineData
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
97647369
RC
19/* Used for selecting a given 'trust' level */
20typedef enum
21{
22 TRUST_UNKNOWN,
23 TRUST_PREV,
24 TRUST_CURR,
25 TRUST_TEST,
26 NTRUST
27}
28trusts;
29
fa0c0d10 30class packageversion;
bb849dbd 31class packagemeta;
4fe323f9 32class category;
7939f6d1 33
bb849dbd 34/* Required to parse this completely */
bb849dbd 35#include "list.h"
3c054baf 36#include "String++.h"
4fe323f9 37#include "category.h"
bb849dbd
RC
38
39/*
40 For cleanliness this may need to be put in its own file later. */
41class CategoryPackage
42{
43public:
4fe323f9 44 CategoryPackage (Category & cat):key (cat), pkg (0)
bb849dbd 45 {
4fe323f9
RC
46 next = cat.packages;
47 cat.packages = this;
bb849dbd 48 };
7c6ef2c3 49 ~CategoryPackage ();
4fe323f9 50 Category & key;
bb849dbd 51 CategoryPackage *next; /* The next package pointer in the list */
4fe323f9 52 packagemeta *pkg;
bb849dbd
RC
53};
54
55
56/* NOTE: A packagemeta without 1 packageversion is invalid! */
7939f6d1
RC
57class packagemeta
58{
59public:
3c054baf 60 packagemeta (String const &pkgname):name (pkgname), key(pkgname), installed_from (0),
bb849dbd
RC
61 //versions (0),
62// versioncount (0), versionspace (0),
63 installed (0), prev (0), prevtimestamp (0), curr (0), currtimestamp (0),
64 exp (0), exptimestamp (0), desired (0)
7939f6d1 65 {
3c054baf 66 }
fa0c0d10 67
3c054baf
RC
68 packagemeta (String const &pkgname,
69 String const &installedfrom):name (pkgname), key(pkgname),
70 installed_from (installedfrom),
bb849dbd
RC
71 //versions (0), versioncount (0), versionspace (0),
72
73 installed (0), prev (0), prevtimestamp (0), curr (0), currtimestamp (0),
74 exp (0), exptimestamp (0), desired (0)
fa0c0d10 75 {
fa0c0d10
RC
76 };
77
7c6ef2c3 78 ~packagemeta ();
7939f6d1 79
fa0c0d10
RC
80 void add_version (packageversion &);
81 void set_installed (packageversion &);
7e8fc33c
RC
82
83 class _actions
84 {
85 public:
86 _actions ():_value (0) {};
87 _actions (int aInt) {
88 _value = aInt;
89 if (_value < 0 || _value > 3)
90 _value = 0;
91 }
92 _actions & operator ++ ();
93 bool operator == (_actions const &rhs) { return _value == rhs._value; }
94 bool operator != (_actions const &rhs) { return _value != rhs._value; }
95 const char *caption ();
96 private:
97 int _value;
98 };
99 static const _actions Default_action;
100 static const _actions Install_action;
101 static const _actions Reinstall_action;
102 static const _actions Uninstall_action;
cbfc4215 103 void set_action (packageversion *default_version);
7e8fc33c 104 void set_action (_actions, packageversion * default_version);
fa0c0d10 105 void uninstall ();
97647369 106 int set_requirements (trusts deftrust = TRUST_CURR, size_t depth = 0);
7939f6d1 107
3c054baf 108 String action_caption ();
97647369
RC
109 packageversion * trustp (trusts const t) const
110 {
111 return t == TRUST_PREV ? (prev ? prev : (curr ? curr : installed))
112 : t == TRUST_CURR ? (curr ? curr : installed)
2fa7c5a4 113 : exp ? exp : installed;
97647369 114 }
cbfc4215 115
3c054baf
RC
116 String name; /* package name, like "cygwin" */
117 String key;
fa0c0d10 118 /* legacy variable used to output data for installed.db versions <= 2 */
3c054baf 119 String installed_from;
bb849dbd
RC
120 /* SDesc is global in theory, across all package versions.
121 LDesc is not: it can be different per version */
3c054baf 122 String const SDesc () const;
bb849dbd
RC
123 /* what categories does this package belong in. Note that if multiple versions
124 * of a package disagree.... the first one read in will take precedence.
125 */
bb849dbd 126 void add_category (Category &);
4fe323f9 127 list < CategoryPackage, Category &, Categorycmp > Categories;
fa0c0d10 128
3c054baf 129 list < packageversion, String, String::casecompare > versions;
7939f6d1 130 /* which one is installed. */
fa0c0d10 131 packageversion *installed;
7939f6d1 132 /* which one is listed as "prev" in our available packages db */
fa0c0d10 133 packageversion *prev;
bb849dbd
RC
134 /* And what was the timestamp of the ini it was found from */
135 unsigned int prevtimestamp;
7939f6d1 136 /* ditto for current - stable */
fa0c0d10 137 packageversion *curr;
bb849dbd 138 unsigned int currtimestamp;
7939f6d1 139 /* and finally the experimental version */
fa0c0d10 140 packageversion *exp;
bb849dbd
RC
141 unsigned int exptimestamp;
142 /* Now for the user stuff :] */
143 /* What version does the user want ? */
144 packageversion *desired;
7e8fc33c 145
cbfc4215
RC
146protected:
147 packagemeta (packagemeta const &);
148 packagemeta &operator= (packagemeta const &);
7939f6d1
RC
149};
150
151#endif /* _PACKAGE_META_H_ */
This page took 0.042313 seconds and 5 git commands to generate.