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 * and an optional version. 28 * 29 * resolvable ::= <name>['='<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 43 * cmd:svn 44 */ 45 class BPackageResolvable { 46 public: 47 BPackageResolvable(); 48 BPackageResolvable( 49 const BPackageResolvableData& data); 50 BPackageResolvable(const BString& name, 51 BPackageResolvableType type 52 = B_PACKAGE_RESOLVABLE_TYPE_DEFAULT, 53 const BPackageVersion& version 54 = BPackageVersion()); 55 56 status_t InitCheck() const; 57 58 const BString& Name() const; 59 BPackageResolvableType Type() const; 60 const BPackageVersion& Version() const; 61 62 BString ToString() const; 63 64 void SetTo(const BString& name, 65 BPackageResolvableType type 66 = B_PACKAGE_RESOLVABLE_TYPE_DEFAULT, 67 const BPackageVersion& version 68 = BPackageVersion()); 69 void Clear(); 70 71 public: 72 static const char* kTypeNames[]; 73 74 private: 75 BString fName; 76 BPackageResolvableType fType; 77 BPackageVersion fVersion; 78 }; 79 80 81 } // namespace BPackageKit 82 83 84 #endif // _PACKAGE__PACKAGE_RESOLVABLE_H_ 85