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_
23 /* Required to parse this completely */
27 #include "PackageTrust.h"
28 #include "package_version.h"
30 /* NOTE: A packagemeta without 1 packageversion is invalid! */
34 packagemeta (packagemeta
const &);
35 packagemeta (String
const &pkgname
):name (pkgname
), key(pkgname
), installed_from (),
36 prevtimestamp (0), currtimestamp (0),
37 exptimestamp (0), architecture (), priority()
41 packagemeta (String
const &pkgname
,
42 String
const &installedfrom
):name (pkgname
), key(pkgname
),
43 installed_from (installedfrom
),
44 prevtimestamp (0), currtimestamp (0),
45 exptimestamp (0), architecture (), priority()
51 void add_version (packageversion
&);
52 void set_installed (packageversion
&);
57 _actions ():_value (0) {};
60 if (_value
< 0 || _value
> 3)
63 _actions
& operator ++ ();
64 bool operator == (_actions
const &rhs
) { return _value
== rhs
._value
; }
65 bool operator != (_actions
const &rhs
) { return _value
!= rhs
._value
; }
66 const char *caption ();
70 static const _actions Default_action
;
71 static const _actions Install_action
;
72 static const _actions Reinstall_action
;
73 static const _actions Uninstall_action
;
74 void set_action (packageversion
const &default_version
);
75 void set_action (_actions
, packageversion
const & default_version
);
77 int set_requirements (trusts deftrust
= TRUST_CURR
, size_t depth
= 0);
79 String
action_caption ();
80 packageversion
trustp (trusts
const t
) const
82 return t
== TRUST_PREV
? (prev
? prev
: (curr
? curr
: installed
))
83 : t
== TRUST_CURR
? (curr
? curr
: installed
)
84 : exp
? exp
: installed
;
87 String name
; /* package name, like "cygwin" */
89 /* legacy variable used to output data for installed.db versions <= 2 */
90 String installed_from
;
91 /* SDesc is global in theory, across all package versions.
92 LDesc is not: it can be different per version */
93 String
const SDesc () const;
94 /* what categories does this package belong in. Note that if multiple versions
95 * of a package disagree.... the first one read in will take precedence.
97 void add_category (String
const &);
98 std::set
<String
, String::caseless
> categories
;
99 std::set
<packageversion
> versions
;
101 /* which one is installed. */
102 packageversion installed
;
103 /* which one is listed as "prev" in our available packages db */
105 /* And what was the timestamp of the ini it was found from */
106 unsigned int prevtimestamp
;
107 /* ditto for current - stable */
109 unsigned int currtimestamp
;
110 /* and finally the experimental version */
112 unsigned int exptimestamp
;
113 /* Now for the user stuff :] */
114 /* What version does the user want ? */
115 packageversion desired
;
117 /* What platform is this for ?
119 * cygwin - cygwin for 32 bit MS Windows
120 * All - no binary code, or a version for every platform
123 /* What priority does this package have?
124 * TODO: this should be linked into a list of priorities.
128 /* can one or more versions be installed? */
129 bool accessible () const;
130 bool sourceAccessible() const;
133 packagemeta
&operator= (packagemeta
const &);
136 #endif /* _PACKAGE_META_H_ */