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:
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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
|
||||||
Reference in New Issue
Block a user