2 * Copyright (c) 2001, Robert Collins.
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.
9 * A copy of the GNU General Public License can be found at
12 * Written by Robert Collins <rbtcollins@hotmail.com>
16 #ifndef _PACKAGE_META_H_
17 #define _PACKAGE_META_H_
19 /* Used for selecting a given 'trust' level */
34 /* Required to parse this completely */
40 For cleanliness this may need to be put in its own file later. */
44 CategoryPackage (Category
& cat
):key (cat
), pkg (0)
50 CategoryPackage
*next
; /* The next package pointer in the list */
55 /* NOTE: A packagemeta without 1 packageversion is invalid! */
59 packagemeta (char const *pkgname
):installed_from (0),
61 // versioncount (0), versionspace (0),
62 installed (0), prev (0), prevtimestamp (0), curr (0), currtimestamp (0),
63 exp (0), exptimestamp (0), desired (0)
65 name
= new char[strlen (pkgname
) + 1];
66 strcpy (name
, pkgname
);
70 packagemeta (char const *pkgname
,
71 char const *installedfrom
):installed_from (0),
72 //versions (0), versioncount (0), versionspace (0),
74 installed (0), prev (0), prevtimestamp (0), curr (0), currtimestamp (0),
75 exp (0), exptimestamp (0), desired (0)
77 name
= new char[strlen (pkgname
) + 1];
79 strcpy (name
, pkgname
);
80 installed_from
= new char[strlen (installedfrom
) + 1];
81 strcpy (installed_from
, installedfrom
);
88 delete[] installed_from
;
91 void add_version (packageversion
&);
92 void set_installed (packageversion
&);
97 _actions ():_value (0) {};
100 if (_value
< 0 || _value
> 3)
103 _actions
& operator ++ ();
104 bool operator == (_actions
const &rhs
) { return _value
== rhs
._value
; }
105 bool operator != (_actions
const &rhs
) { return _value
!= rhs
._value
; }
106 const char *caption ();
110 static const _actions Default_action
;
111 static const _actions Install_action
;
112 static const _actions Reinstall_action
;
113 static const _actions Uninstall_action
;
114 void set_action (packageversion
*default_version
);
115 void set_action (_actions
, packageversion
* default_version
);
117 int set_requirements (trusts deftrust
= TRUST_CURR
, size_t depth
= 0);
119 char const *action_caption ();
120 packageversion
* trustp (trusts
const t
) const
122 return t
== TRUST_PREV
? (prev
? prev
: (curr
? curr
: installed
))
123 : t
== TRUST_CURR
? (curr
? curr
: installed
)
127 char *name
; /* package name, like "cygwin" */
129 /* legacy variable used to output data for installed.db versions <= 2 */
130 char *installed_from
;
131 /* SDesc is global in theory, across all package versions.
132 LDesc is not: it can be different per version */
133 char const *SDesc () const;
134 /* what categories does this package belong in. Note that if multiple versions
135 * of a package disagree.... the first one read in will take precedence.
137 void add_category (Category
&);
138 list
< CategoryPackage
, Category
&, Categorycmp
> Categories
;
140 list
< packageversion
, char const *, strcasecmp
> versions
;
141 /* which one is installed. */
142 packageversion
*installed
;
143 /* which one is listed as "prev" in our available packages db */
144 packageversion
*prev
;
145 /* And what was the timestamp of the ini it was found from */
146 unsigned int prevtimestamp
;
147 /* ditto for current - stable */
148 packageversion
*curr
;
149 unsigned int currtimestamp
;
150 /* and finally the experimental version */
152 unsigned int exptimestamp
;
153 /* Now for the user stuff :] */
154 /* What version does the user want ? */
155 packageversion
*desired
;
158 packagemeta (packagemeta
const &);
159 packagemeta
&operator= (packagemeta
const &);
162 #endif /* _PACKAGE_META_H_ */