xref: /haiku/headers/os/package/PackageResolvable.h (revision dd2a1e350b303b855a50fd64e6cb55618be1ae6a)
1 /*
2  * Copyright 2011, Haiku, Inc.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _PACKAGE__PACKAGE_RESOLVABLE_H_
6 #define _PACKAGE__PACKAGE_RESOLVABLE_H_
7 
8 
9 #include <String.h>
10 
11 #include <package/PackageVersion.h>
12 
13 
14 namespace BPackageKit {
15 
16 
17 namespace BHPKG {
18 	struct BPackageResolvableData;
19 }
20 using BHPKG::BPackageResolvableData;
21 
22 
23 /*
24  * Defines a resolvable (something other packages can depend upon).
25  * Each resolvable is defined as a name (with an optional type prefix),
26  * an optional version, and an optional compatibility version (the least
27  * version the resolvable is backwards compatible with).
28  *
29  * 		resolvable ::= <name>['='<version>]['compat' '>=' <version>]
30  * 		name       ::= [<type>':']<word>
31  * 		type       ::= 'lib' | 'cmd' | 'app' | 'add_on'
32  *
33  * The type doesn't have any specific meaning to the dependency resolver,
34  * it just facilitates doing specific queries on the repository (like "is
35  * there any package providing the 'svn' command that the user just typed?").
36  * At a later stage, more types may be added in order to declare additional
37  * entities, e.g. translators.
38  *
39  * String examples:
40  * 		haiku=r1
41  * 		lib:libssl=0.9.8i
42  * 		subversion=1.5 compat>=1.0
43  * 		cmd:svn
44  */
45 class BPackageResolvable {
46 public:
47 								BPackageResolvable();
48 								BPackageResolvable(
49 									const BPackageResolvableData& data);
50 								BPackageResolvable(const BString& name,
51 									const BPackageVersion& version
52 										= BPackageVersion(),
53 									const BPackageVersion& compatibleVersion
54 										= BPackageVersion());
55 
56 			status_t			InitCheck() const;
57 
58 			const BString&		Name() const;
59 			const BPackageVersion& Version() const;
60 			const BPackageVersion& CompatibleVersion() const;
61 
62 			BString				ToString() const;
63 
64 			status_t			SetToString(const BString& expressionString);
65 			void				SetTo(const BString& name,
66 									const BPackageVersion& version
67 										= BPackageVersion(),
68 									const BPackageVersion& compatibleVersion
69 										= BPackageVersion());
70 			void				Clear();
71 
72 private:
73 			BString				fName;
74 			BPackageVersion		fVersion;
75 			BPackageVersion		fCompatibleVersion;
76 };
77 
78 
79 }	// namespace BPackageKit
80 
81 
82 #endif	// _PACKAGE__PACKAGE_RESOLVABLE_H_
83