Helper class: Represents a loaded add-on image.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2797 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2003-02-22 23:46:59 +00:00
parent d749688652
commit 32de23c976
2 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,54 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
#include "AddOnImage.h"
// constructor
AddOnImage::AddOnImage()
: fID(-1)
{
}
// destructor
AddOnImage::~AddOnImage()
{
Unload();
}
// Load
status_t
AddOnImage::Load(const char *path)
{
Unload();
status_t error = (path ? B_OK : B_BAD_VALUE);
if (error == B_OK) {
image_id id = load_add_on(path);
if (id >= 0)
fID = id;
else
error = id;
}
return error;
}
// Unload
void
AddOnImage::Unload()
{
if (fID >= 0) {
unload_add_on(fID);
fID = -1;
}
}
// SetID
void
AddOnImage::SetID(image_id id)
{
Unload();
if (id >= 0)
fID = id;
}

View File

@ -0,0 +1,32 @@
//----------------------------------------------------------------------
// This software is part of the OpenBeOS distribution and is covered
// by the OpenBeOS license.
//---------------------------------------------------------------------
#ifndef _ADD_ON_IMAGE_H
#define _ADD_ON_IMAGE_H
#include <image.h>
namespace BPrivate {
class AddOnImage {
public:
AddOnImage();
~AddOnImage();
status_t Load(const char *path);
void Unload();
void SetID(image_id id);
image_id ID() const { return fID; }
private:
image_id fID;
};
} // namespace BPrivate
using BPrivate::AddOnImage;
#endif // _ADD_ON_IMAGE_H