From 4438ef7a2c32f9c0e975b56bd11f893533a1cb4a Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 27 Jun 2011 03:48:00 +0200 Subject: [PATCH] BPackageResolvable: Add compatibleVersion property --- headers/os/package/PackageResolvable.h | 15 +++++++++++---- src/kits/package/PackageResolvable.cpp | 23 +++++++++++++++++++---- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/headers/os/package/PackageResolvable.h b/headers/os/package/PackageResolvable.h index 18cf29e102..e26daa4673 100644 --- a/headers/os/package/PackageResolvable.h +++ b/headers/os/package/PackageResolvable.h @@ -23,10 +23,11 @@ using BHPKG::BPackageResolvableData; /* * Defines a resolvable (something other packages can depend upon). - * Each resolvable is defined as a name (with an optional type prefix) - * and an optional version. + * Each resolvable is defined as a name (with an optional type prefix), + * an optional version, and an optional compatibility version (the least + * version the resolvable is backwards compatible with). * - * resolvable ::= ['='] + * resolvable ::= ['=']['compat' '>=' ] * name ::= [':'] * type ::= 'lib' | 'cmd' | 'app' | 'add_on' * @@ -39,7 +40,7 @@ using BHPKG::BPackageResolvableData; * String examples: * haiku=r1 * lib:libssl=0.9.8i - * subversion=1.5 + * subversion=1.5 compat>=1.0 * cmd:svn */ class BPackageResolvable { @@ -51,6 +52,8 @@ public: BPackageResolvableType type = B_PACKAGE_RESOLVABLE_TYPE_DEFAULT, const BPackageVersion& version + = BPackageVersion(), + const BPackageVersion& compatibleVersion = BPackageVersion()); status_t InitCheck() const; @@ -58,6 +61,7 @@ public: const BString& Name() const; BPackageResolvableType Type() const; const BPackageVersion& Version() const; + const BPackageVersion& CompatibleVersion() const; BString ToString() const; @@ -65,6 +69,8 @@ public: BPackageResolvableType type = B_PACKAGE_RESOLVABLE_TYPE_DEFAULT, const BPackageVersion& version + = BPackageVersion(), + const BPackageVersion& compatibleVersion = BPackageVersion()); void Clear(); @@ -75,6 +81,7 @@ private: BString fName; BPackageResolvableType fType; BPackageVersion fVersion; + BPackageVersion fCompatibleVersion; }; diff --git a/src/kits/package/PackageResolvable.cpp b/src/kits/package/PackageResolvable.cpp index e04915c2cf..3c1c632ffe 100644 --- a/src/kits/package/PackageResolvable.cpp +++ b/src/kits/package/PackageResolvable.cpp @@ -33,17 +33,20 @@ BPackageResolvable::BPackageResolvable(const BPackageResolvableData& data) : fName(data.name), fType(data.type), - fVersion(data.version) + fVersion(data.version), + fCompatibleVersion(data.compatibleVersion) { } BPackageResolvable::BPackageResolvable(const BString& name, - BPackageResolvableType type, const BPackageVersion& version) + BPackageResolvableType type, const BPackageVersion& version, + const BPackageVersion& compatibleVersion) : fName(name), fType(type), - fVersion(version) + fVersion(version), + fCompatibleVersion(compatibleVersion) { } @@ -76,6 +79,13 @@ BPackageResolvable::Version() const } +const BPackageVersion& +BPackageResolvable::CompatibleVersion() const +{ + return fCompatibleVersion; +} + + BString BPackageResolvable::ToString() const { @@ -85,17 +95,21 @@ BPackageResolvable::ToString() const if (fVersion.InitCheck() == B_OK) string << '=' << fVersion.ToString(); + if (fCompatibleVersion.InitCheck() == B_OK) + string << " compat>=" << fCompatibleVersion.ToString(); + return string; } void BPackageResolvable::SetTo(const BString& name, BPackageResolvableType type, - const BPackageVersion& version) + const BPackageVersion& version, const BPackageVersion& compatibleVersion) { fName = name; fType = type; fVersion = version; + fCompatibleVersion = compatibleVersion; } @@ -104,6 +118,7 @@ BPackageResolvable::Clear() { fName.Truncate(0); fVersion.Clear(); + fCompatibleVersion.Clear(); }