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 */
27 #include "PackageTrust.h"
28 #include "package_version.h"
30 /* NOTE: A packagemeta without 1 packageversion is invalid! */
34 static void PrepareForVisit();
35 static void ScanDownloadedFiles();
36 packagemeta (packagemeta
const &);
37 packagemeta (String
const &pkgname
):name (pkgname
), key(pkgname
), installed_from (),
38 prevtimestamp (0), currtimestamp (0),
39 exptimestamp (0), architecture (), priority(), visited_(false)
43 packagemeta (String
const &pkgname
,
44 String
const &installedfrom
):name (pkgname
), key(pkgname
),
45 installed_from (installedfrom
),
46 prevtimestamp (0), currtimestamp (0),
47 exptimestamp (0), architecture (), priority(), visited_(false)
53 void add_version (packageversion
&);
54 void set_installed (packageversion
&);
55 void visited(bool const &);
57 bool hasNoCategories() const;
58 void setDefaultCategories();
59 void addToCategoryAll();
64 _actions ():_value (0) {};
67 if (_value
< 0 || _value
> 3)
70 _actions
& operator ++ ();
71 bool operator == (_actions
const &rhs
) { return _value
== rhs
._value
; }
72 bool operator != (_actions
const &rhs
) { return _value
!= rhs
._value
; }
73 const char *caption ();
77 static const _actions Default_action
;
78 static const _actions Install_action
;
79 static const _actions Reinstall_action
;
80 static const _actions Uninstall_action
;
81 void set_action (packageversion
const &default_version
);
82 void set_action (_actions
, packageversion
const & default_version
);
84 int set_requirements (trusts deftrust
, size_t depth
);
85 // explicit separation for generic programming.
86 int set_requirements (trusts deftrust
= TRUST_CURR
)
87 { return set_requirements (deftrust
, 0); }
89 String
action_caption () const;
90 packageversion
trustp (trusts
const t
) const
92 return t
== TRUST_PREV
? (prev
? prev
: (curr
? curr
: installed
))
93 : t
== TRUST_CURR
? (curr
? curr
: installed
)
94 : exp
? exp
: installed
;
97 String name
; /* package name, like "cygwin" */
99 /* legacy variable used to output data for installed.db versions <= 2 */
100 String installed_from
;
101 /* SDesc is global in theory, across all package versions.
102 LDesc is not: it can be different per version */
103 String
const SDesc () const;
104 /* what categories does this package belong in. Note that if multiple versions
105 * of a package disagree.... the first one read in will take precedence.
107 void add_category (String
const &);
108 std::set
<String
, String::caseless
> categories
;
109 String
const getReadableCategoryList () const;
110 std::set
<packageversion
> versions
;
112 /* which one is installed. */
113 packageversion installed
;
114 /* which one is listed as "prev" in our available packages db */
116 /* And what was the timestamp of the ini it was found from */
117 unsigned int prevtimestamp
;
118 /* ditto for current - stable */
120 unsigned int currtimestamp
;
121 /* and finally the experimental version */
123 unsigned int exptimestamp
;
124 /* Now for the user stuff :] */
125 /* What version does the user want ? */
126 packageversion desired
;
128 /* What platform is this for ?
130 * cygwin - cygwin for 32 bit MS Windows
131 * All - no binary code, or a version for every platform
134 /* What priority does this package have?
135 * TODO: this should be linked into a list of priorities.
139 /* can one or more versions be installed? */
140 bool accessible () const;
141 bool sourceAccessible() const;
143 void logSelectionStatus() const;
144 void logAllVersions() const;
147 packagemeta
&operator= (packagemeta
const &);
149 String
trustLabel(packageversion
const &) const;
153 // for generic programming
154 struct SetRequirement
{
155 SetRequirement (trusts aTrust
) : theTrust (aTrust
){}
156 void operator() (packagemeta
*pkg
) { pkg
->set_requirements(theTrust
);}
161 #endif /* SETUP_PACKAGE_META_H */