]> cygwin.com Git - cygwin-apps/setup.git/blob - package_version.h
2002-11-04 Max Bowsher <maxb@ukf.net>
[cygwin-apps/setup.git] / package_version.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 /* This is a package version abstrct class, that should be able to
17 * arbitrate acceess to cygwin binary packages, cygwin source package,
18 * and the rpm and deb equivalents of the same.
19 */
20
21 #ifndef _PACKAGE_VERSION_H_
22 #define _PACKAGE_VERSION_H_
23
24 /* standard binary package metadata:
25 * Name (ie mutt
26 * Vendor Version (ie 2.5.1)
27 * Package Version (ie 16)
28 * Stability
29 * Files
30 */
31
32 /* For non installed files, this class can be populated via information about
33 * what is available on the net, or by parsing a specific package file.
34 * for installed packages, this class should represent what is currently installed,
35 * - updated by what net metadata has about it.
36 * i.e. the stability of this version will change simply because the net mirrors
37 * now consider it old.
38 */
39
40 class CategoryList;
41
42 /*Required for parsing */
43 #include "package_source.h"
44 #include "String++.h"
45 #include "PackageSpecification.h"
46 #include "PackageTrust.h"
47 #include <vector>
48
49 typedef enum
50 {
51 package_invalid,
52 package_old,
53 package_current,
54 package_experimental
55 }
56 package_stability_t;
57
58 typedef enum
59 {
60 package_notinstalled,
61 package_installed
62 }
63 package_status_t;
64
65 typedef enum
66 {
67 package_binary,
68 package_source
69 }
70 package_type_t;
71
72 /* A wrapper class to be copied by value that
73 references the same package.
74 Nothing is virtual, because the wrapper cannot be inherited.
75 However, as all the methods are implemented in the referenced
76 _packageversion, that class allows virtual overriding.
77 */
78
79 class _packageversion;
80
81 /* This class has pointer semantics
82 Specifically: a=b does not alter the value of *a.
83 */
84 class packageversion
85 {
86 public:
87 packageversion (); /* creates an empty packageversion */
88 packageversion (_packageversion *); /* used when creating an instance */
89 packageversion (packageversion const &);
90 ~packageversion ();
91 packageversion &operator= (packageversion const &);
92 bool operator ! () const; /* true if the package is invalid. (i.e.
93 uninitialised */
94 operator bool () const; /* returns ! !() */
95 bool operator == (packageversion const &) const; /* equality */
96 bool operator != (packageversion const &) const;
97 bool operator < (packageversion const &) const;
98 bool operator <= (packageversion const &) const;
99 bool operator > (packageversion const &) const;
100 bool operator >= (packageversion const &) const;
101
102 String const Name () const;
103 String const Vendor_version () const;
104 String const Package_version () const;
105 String const Canonical_version () const;
106 void setCanonicalVersion (String const &);
107 package_status_t Status () const;
108 package_type_t Type () const;
109 String const getfirstfile ();
110 String const getnextfile ();
111 String const SDesc () const;
112 void set_sdesc (String const &);
113 String const LDesc () const;
114 void set_ldesc (String const &);
115 packageversion sourcePackage ();
116 PackageSpecification & sourcePackageSpecification ();
117 void setSourcePackageSpecification (PackageSpecification const &);
118
119 /* invariant: these never return NULL */
120 std::vector <std::vector <PackageSpecification *> *> *depends(), *predepends(),
121 *recommends(), *suggests(), *replaces(), *conflicts(), *provides(), *binaries();
122
123 bool picked() const; /* true if this version is to be installed */
124 void pick(bool); /* trigger an install/reinsall */
125 /* a change - install/uninstall/reinstall/source install
126 has been requested */
127 bool changeRequested () const;
128
129 void uninstall ();
130 /* invariant: never null */
131 packagesource *source(); /* where can we source the file from */
132 /* invariant: never null */
133 std::vector <packagesource> *sources(); /* expose the list of files.
134 source() returns the 'default' file
135 sources() allows managing multiple files
136 in a single package
137 */
138
139 bool accessible () const;
140
141 /* ensure that the depends clause is satisfied */
142 int set_requirements (trusts deftrust = TRUST_CURR, size_t depth = 0);
143
144 private:
145 _packageversion *data; /* Invariant: * data is always valid */
146 };
147
148 class _packageversion
149 {
150 public:
151 _packageversion();
152 virtual ~_packageversion();
153 /* for list inserts/mgmt. */
154 String key;
155 /* name is needed here, because if we are querying a file, the data may be embedded in
156 the file */
157 virtual String const Name () = 0;
158 virtual String const Vendor_version () = 0;
159 virtual String const Package_version () = 0;
160 virtual String const Canonical_version () = 0;
161 virtual void setCanonicalVersion (String const &) = 0;
162 virtual package_status_t Status () = 0;
163 // virtual package_stability_t Stability () = 0;
164 virtual package_type_t Type () = 0;
165 /* TODO: we should probably return a metaclass - file name & path & size & type
166 - ie doc/script/binary
167 */
168 virtual String const getfirstfile () = 0;
169 virtual String const getnextfile () = 0;
170 virtual String const SDesc () = 0;
171 virtual void set_sdesc (String const &) = 0;
172 virtual String const LDesc () = 0;
173 virtual void set_ldesc (String const &) = 0;
174 /* only semantically meaningful for binary packages */
175 /* direct link to the source package for this binary */
176 /* if multiple versions exist and the source doesn't discriminate
177 then the most recent is used
178 */
179 virtual packageversion sourcePackage ();
180 virtual PackageSpecification & sourcePackageSpecification ();
181 virtual void setSourcePackageSpecification (PackageSpecification const &);
182
183 std::vector <std::vector <PackageSpecification *> *> depends, predepends, recommends,
184 suggests, replaces, conflicts, provides, binaries;
185
186 bool picked; /* non zero if this version is to be installed */
187 /* This will also trigger reinstalled if it is set */
188 /* a change - install/uninstall/reinstall/source install
189 has been requested */
190 bool changeRequested ();
191
192
193 virtual void uninstall () = 0;
194 std::vector<packagesource> sources; /* where can we source the files from */
195
196 bool accessible () const;
197
198 /* TODO: Implement me:
199 static package_meta * scan_package (io_stream *);
200 */
201 size_t references;
202 protected:
203 /* only meaningful for binary packages */
204 PackageSpecification _sourcePackage;
205 packageversion sourceVersion;
206 };
207
208 #endif /* _PACKAGE_VERSION_H_ */
This page took 0.043459 seconds and 5 git commands to generate.