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