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