2 * Copyright (c) 2001, 2003 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 SETUP_PACKAGE_META_H
17 #define SETUP_PACKAGE_META_H
23 /* Required to parse this completely */
25 #include "PackageTrust.h"
26 #include "package_version.h"
27 #include "package_message.h"
29 typedef std::pair
<const std::string
, std::vector
<packagemeta
*> > Category
;
31 /* NOTE: A packagemeta without 1 packageversion is invalid! */
35 static void ScanDownloadedFiles();
36 packagemeta (packagemeta
const &);
37 packagemeta (const std::string
& pkgname
):name (pkgname
), key(pkgname
), installed_from (),
38 architecture (), priority(), visited_(false)
42 packagemeta (const std::string
& pkgname
,
43 const std::string
& installedfrom
):name (pkgname
), key(pkgname
),
44 installed_from (installedfrom
),
45 architecture (), priority(), visited_(false)
51 void add_version (packageversion
&);
52 void set_installed (packageversion
&);
53 void visited(bool const &);
55 void addToCategoryBase();
56 bool hasNoCategories() const;
57 void setDefaultCategories();
58 void addToCategoryAll();
63 _actions ():_value (0) {};
66 if (_value
< 0 || _value
> 3)
69 _actions
& operator ++ ();
70 bool operator == (_actions
const &rhs
) { return _value
== rhs
._value
; }
71 bool operator != (_actions
const &rhs
) { return _value
!= rhs
._value
; }
72 const char *caption ();
76 static const _actions Default_action
;
77 static const _actions Install_action
;
78 static const _actions Reinstall_action
;
79 static const _actions Uninstall_action
;
80 void set_action (packageversion
const &default_version
);
81 void set_action (_actions
, packageversion
const & default_version
);
83 int set_requirements (trusts deftrust
, size_t depth
);
84 // explicit separation for generic programming.
85 int set_requirements (trusts deftrust
)
86 { return set_requirements (deftrust
, 0); }
87 void set_message (const std::string
& message_id
, const std::string
& message_string
)
89 message
.set (message_id
, message_string
);
92 std::string
action_caption () const;
93 packageversion
trustp (trusts
const t
) const
95 if (t
== TRUST_TEST
&& exp
)
103 std::string name
; /* package name, like "cygwin" */
105 /* legacy variable used to output data for installed.db versions <= 2 */
106 std::string installed_from
;
107 /* true if package was selected on command-line. */
108 bool isManuallyWanted() const;
109 /* SDesc is global in theory, across all package versions.
110 LDesc is not: it can be different per version */
111 const std::string
SDesc () const;
112 /* what categories does this package belong in. Note that if multiple versions
113 * of a package disagree.... the first one read in will take precedence.
115 void add_category (const std::string
& );
116 std::set
<std::string
, casecompare_lt_op
> categories
;
117 const std::string
getReadableCategoryList () const;
118 std::set
<packageversion
> versions
;
120 /* which one is installed. */
121 packageversion installed
;
122 /* which one is listed as "prev" in our available packages db */
124 /* ditto for current - stable */
126 /* and finally the experimental version */
128 /* Now for the user stuff :] */
129 /* What version does the user want ? */
130 packageversion desired
;
132 /* What platform is this for ?
134 * cygwin - cygwin for 32 bit MS Windows
135 * All - no binary code, or a version for every platform
137 std::string architecture
;
138 /* What priority does this package have?
139 * TODO: this should be linked into a list of priorities.
141 std::string priority
;
143 packagemessage message
;
145 /* can one or more versions be installed? */
146 bool accessible () const;
147 bool sourceAccessible() const;
149 void logSelectionStatus() const;
150 void logAllVersions() const;
153 packagemeta
&operator= (packagemeta
const &);
155 std::string
trustLabel(packageversion
const &) const;
159 #endif /* SETUP_PACKAGE_META_H */