]> cygwin.com Git - cygwin-apps/setup.git/blame - package_meta.h
2003-10-23 Jerry D. Hedden <jerry@hedden.us>
[cygwin-apps/setup.git] / package_meta.h
CommitLineData
7939f6d1 1/*
d55e14fe 2 * Copyright (c) 2001, 2003 Robert Collins.
7939f6d1
RC
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
c93bc6d0
MB
16#ifndef SETUP_PACKAGE_META_H
17#define SETUP_PACKAGE_META_H
7939f6d1 18
fa0c0d10 19class packageversion;
bb849dbd 20class packagemeta;
4fe323f9 21class 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
31class packagemeta
32{
33public:
8c242540 34 static void PrepareForVisit();
cda26207 35 static void ScanDownloadedFiles();
3c196821 36 packagemeta (packagemeta const &);
076654e7 37 packagemeta (String const &pkgname):name (pkgname), key(pkgname), installed_from (),
3c196821 38 prevtimestamp (0), currtimestamp (0),
8c242540 39 exptimestamp (0), architecture (), priority(), visited_(false)
7939f6d1 40 {
3c054baf 41 }
fa0c0d10 42
3c054baf
RC
43 packagemeta (String const &pkgname,
44 String const &installedfrom):name (pkgname), key(pkgname),
45 installed_from (installedfrom),
3c196821 46 prevtimestamp (0), currtimestamp (0),
8c242540 47 exptimestamp (0), architecture (), priority(), visited_(false)
fa0c0d10 48 {
8c242540 49 }
fa0c0d10 50
7c6ef2c3 51 ~packagemeta ();
7939f6d1 52
fa0c0d10
RC
53 void add_version (packageversion &);
54 void set_installed (packageversion &);
8c242540
RC
55 void visited(bool const &);
56 bool visited() const;
31f0ccce
RC
57 bool hasNoCategories() const;
58 void setDefaultCategories();
358712d8 59 void addToCategoryAll();
7e8fc33c
RC
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;
3c196821
RC
81 void set_action (packageversion const &default_version);
82 void set_action (_actions, packageversion const & default_version);
fa0c0d10 83 void uninstall ();
d05ae76a
RC
84 int set_requirements (trusts deftrust, size_t depth);
85 // explicit separation for generic programming.
86 int set_requirements (trusts deftrust = TRUST_CURR)
87 { return set_requirements (deftrust, 0); }
7939f6d1 88
d55e14fe 89 String action_caption () const;
3c196821 90 packageversion trustp (trusts const t) const
97647369
RC
91 {
92 return t == TRUST_PREV ? (prev ? prev : (curr ? curr : installed))
93 : t == TRUST_CURR ? (curr ? curr : installed)
2fa7c5a4 94 : exp ? exp : installed;
97647369 95 }
cbfc4215 96
3c054baf
RC
97 String name; /* package name, like "cygwin" */
98 String key;
fa0c0d10 99 /* legacy variable used to output data for installed.db versions <= 2 */
3c054baf 100 String installed_from;
bb849dbd
RC
101 /* SDesc is global in theory, across all package versions.
102 LDesc is not: it can be different per version */
3c054baf 103 String const SDesc () const;
bb849dbd
RC
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 */
0cf68afd 107 void add_category (String const &);
666bf37d 108 std::set <String, String::caseless> categories;
bfdf6ac2 109 String const getReadableCategoryList () const;
666bf37d 110 std::set <packageversion> versions;
fa0c0d10 111
7939f6d1 112 /* which one is installed. */
3c196821 113 packageversion installed;
7939f6d1 114 /* which one is listed as "prev" in our available packages db */
3c196821 115 packageversion prev;
bb849dbd
RC
116 /* And what was the timestamp of the ini it was found from */
117 unsigned int prevtimestamp;
7939f6d1 118 /* ditto for current - stable */
3c196821 119 packageversion curr;
bb849dbd 120 unsigned int currtimestamp;
7939f6d1 121 /* and finally the experimental version */
3c196821 122 packageversion exp;
bb849dbd
RC
123 unsigned int exptimestamp;
124 /* Now for the user stuff :] */
125 /* What version does the user want ? */
3c196821 126 packageversion desired;
7e8fc33c 127
aa1e3b4d
RC
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
3c196821
RC
139 /* can one or more versions be installed? */
140 bool accessible () const;
141 bool sourceAccessible() const;
142
d55e14fe 143 void logSelectionStatus() const;
f416a2b6
RC
144 void logAllVersions() const;
145
cbfc4215 146protected:
cbfc4215 147 packagemeta &operator= (packagemeta const &);
f416a2b6
RC
148private:
149 String trustLabel(packageversion const &) const;
8c242540 150 bool visited_;
7939f6d1
RC
151};
152
12f8ac69
RC
153// for generic programming
154struct SetRequirement {
155 SetRequirement (trusts aTrust) : theTrust (aTrust){}
156 void operator() (packagemeta *pkg) { pkg->set_requirements(theTrust);}
157 trusts theTrust;
158};
159
160
c93bc6d0 161#endif /* SETUP_PACKAGE_META_H */
This page took 0.053155 seconds and 5 git commands to generate.