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 /* 19 * Defines a resolvable (something other packages can depend upon). 20 * Each resolvable is defined as a name (with an optional type prefix) 21 * and an optional version. 22 * 23 * resolvable ::= <name>['='<version>] 24 * name ::= [<type>':']<word> 25 * type ::= 'lib' | 'cmd' | 'app' | 'add_on' 26 * 27 * The type doesn't have any specific meaning to the dependency resolver, 28 * it just facilitates doing specific queries on the repository (like "is 29 * there any package providing the 'svn' command that the user just typed?"). 30 * At a later stage, more types may be added in order to declare additional 31 * entities, e.g. translators. 32 * 33 * String examples: 34 * haiku=r1 35 * lib:libssl=0.9.8i 36 * subversion=1.5 37 * cmd:svn 38 */ 39 class BPackageResolvable { 40 public: 41 BPackageResolvable(); 42 BPackageResolvable(const BString& name, 43 BPackageResolvableType type 44 = B_PACKAGE_RESOLVABLE_TYPE_DEFAULT, 45 const BPackageVersion& version 46 = BPackageVersion()); 47 48 status_t InitCheck() const; 49 50 const BString& Name() const; 51 BPackageResolvableType Type() const; 52 const BPackageVersion& Version() const; 53 54 BString AsString() const; 55 56 void SetTo(const BString& name, 57 BPackageResolvableType type 58 = B_PACKAGE_RESOLVABLE_TYPE_DEFAULT, 59 const BPackageVersion& version 60 = BPackageVersion()); 61 void Clear(); 62 63 public: 64 static const char* kTypeNames[]; 65 66 private: 67 BString fName; 68 BPackageResolvableType fType; 69 BPackageVersion fVersion; 70 }; 71 72 73 } // namespace BPackageKit 74 75 76 #endif // _PACKAGE__PACKAGE_RESOLVABLE_H_ 77