Add architecture property to Package

This commit is contained in:
Ingo Weinhold 2011-06-27 06:50:39 +02:00
parent 2ec6e02711
commit eadc3c844d
2 changed files with 33 additions and 0 deletions

View File

@ -19,12 +19,20 @@
#include "Version.h" #include "Version.h"
const char* const kArchitectureNames[B_PACKAGE_ARCHITECTURE_ENUM_COUNT] = {
"any",
"x86",
"x86_gcc2",
};
Package::Package(PackageDomain* domain, dev_t deviceID, ino_t nodeID) Package::Package(PackageDomain* domain, dev_t deviceID, ino_t nodeID)
: :
fDomain(domain), fDomain(domain),
fFileName(NULL), fFileName(NULL),
fName(NULL), fName(NULL),
fVersion(NULL), fVersion(NULL),
fArchitecture(B_PACKAGE_ARCHITECTURE_ENUM_COUNT),
fLinkDirectory(NULL), fLinkDirectory(NULL),
fFD(-1), fFD(-1),
fOpenCount(0), fOpenCount(0),
@ -89,6 +97,18 @@ Package::SetVersion(::Version* version)
} }
const char*
Package::ArchitectureName() const
{
if (fArchitecture < 0
|| fArchitecture >= B_PACKAGE_ARCHITECTURE_ENUM_COUNT) {
return NULL;
}
return kArchitectureNames[fArchitecture];
}
void void
Package::AddNode(PackageNode* node) Package::AddNode(PackageNode* node)
{ {

View File

@ -6,6 +6,8 @@
#define PACKAGE_H #define PACKAGE_H
#include <package/PackageArchitecture.h>
#include <Referenceable.h> #include <Referenceable.h>
#include <util/DoublyLinkedList.h> #include <util/DoublyLinkedList.h>
@ -19,6 +21,9 @@
#include "Resolvable.h" #include "Resolvable.h"
using BPackageKit::BPackageArchitecture;
class PackageDomain; class PackageDomain;
class PackageLinkDirectory; class PackageLinkDirectory;
class Version; class Version;
@ -44,6 +49,13 @@ public:
::Version* Version() const ::Version* Version() const
{ return fVersion; } { return fVersion; }
void SetArchitecture(
BPackageArchitecture architecture)
{ fArchitecture = architecture; }
BPackageArchitecture Architecture() const
{ return fArchitecture; }
const char* ArchitectureName() const;
void SetLinkDirectory( void SetLinkDirectory(
PackageLinkDirectory* linkDirectory) PackageLinkDirectory* linkDirectory)
{ fLinkDirectory = linkDirectory; } { fLinkDirectory = linkDirectory; }
@ -72,6 +84,7 @@ private:
char* fFileName; char* fFileName;
char* fName; char* fName;
::Version* fVersion; ::Version* fVersion;
BPackageArchitecture fArchitecture;
PackageLinkDirectory* fLinkDirectory; PackageLinkDirectory* fLinkDirectory;
int fFD; int fFD;
uint32 fOpenCount; uint32 fOpenCount;