2013-11-22 10:46:25 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Dennis Andersen] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef MISC_O_RESOURCE_H
|
|
|
|
#define MISC_O_RESOURCE_H
|
|
|
|
|
|
|
|
#include "..\Utilities.h"
|
|
|
|
#include "OysterResource.h"
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Oyster
|
|
|
|
{
|
|
|
|
namespace Resource
|
|
|
|
{
|
|
|
|
class OResource
|
|
|
|
{
|
2013-11-26 10:55:51 +01:00
|
|
|
public:
|
|
|
|
struct CustomResourceData
|
|
|
|
{
|
|
|
|
CustomLoadFunction loadingFunction;
|
|
|
|
CustomUnloadFunction unloadingFunction;
|
|
|
|
};
|
|
|
|
|
2013-11-22 10:46:25 +01:00
|
|
|
public:
|
|
|
|
OResource(OHRESOURCE handle, ResourceType type, size_t size, size_t elementSize, ::std::wstring resourceFilename);
|
|
|
|
virtual~ OResource();
|
|
|
|
|
|
|
|
inline ResourceType GetResourceType() const
|
2013-11-27 21:12:37 +01:00
|
|
|
{
|
|
|
|
return this->resourceType;
|
|
|
|
}
|
2013-11-22 10:46:25 +01:00
|
|
|
inline const wchar_t* GetResourceFilename() const
|
2013-11-27 21:12:37 +01:00
|
|
|
{
|
|
|
|
return this->resourceFilename.c_str();
|
|
|
|
}
|
2013-11-22 10:46:25 +01:00
|
|
|
inline OHRESOURCE GetResourceHandle() const
|
2013-11-27 21:12:37 +01:00
|
|
|
{
|
|
|
|
return this->resourceData;
|
|
|
|
}
|
2013-11-22 10:46:25 +01:00
|
|
|
inline unsigned long long GetResourceSize() const
|
2013-11-27 21:12:37 +01:00
|
|
|
{
|
|
|
|
return this->resourceSize;
|
|
|
|
}
|
2013-11-22 10:46:25 +01:00
|
|
|
inline unsigned long long GetResourceElementSize() const
|
2013-11-27 21:12:37 +01:00
|
|
|
{
|
|
|
|
return this->resourceElementSize;
|
|
|
|
}
|
2013-11-22 10:46:25 +01:00
|
|
|
inline unsigned int GetResourceID() const
|
2013-11-27 21:12:37 +01:00
|
|
|
{
|
|
|
|
return this->resourceID;
|
|
|
|
}
|
|
|
|
inline void SetResourceID(int id)
|
|
|
|
{
|
|
|
|
this->resourceID = id;
|
|
|
|
}
|
2013-11-22 10:46:25 +01:00
|
|
|
|
|
|
|
public:
|
2013-11-26 10:55:51 +01:00
|
|
|
static OResource* Load (const wchar_t filename[], ResourceType type);
|
|
|
|
static OResource* Load (const wchar_t filename[], CustomLoadFunction loadFnc);
|
|
|
|
static OResource* Reload (OResource* resource);
|
|
|
|
static bool Release (OResource* resource);
|
2013-11-22 10:46:25 +01:00
|
|
|
|
|
|
|
Utility::DynamicMemory::RefCount resourceRef;
|
|
|
|
|
|
|
|
private:
|
2013-11-26 10:55:51 +01:00
|
|
|
static OResource* ByteLoader (const wchar_t filename[], ResourceType type, OResource* old = 0);
|
|
|
|
void ByteUnloader ();
|
|
|
|
OResource* ByteReloader ();
|
|
|
|
|
|
|
|
static OResource* CustomLoader (const wchar_t filename[], CustomLoadFunction loadFnc);
|
|
|
|
void CustomUnloader ();
|
|
|
|
OResource* CustomReloader ();
|
|
|
|
|
|
|
|
OHRESOURCE resourceData;
|
|
|
|
ResourceType resourceType;
|
|
|
|
size_t resourceSize;
|
|
|
|
size_t resourceElementSize;
|
|
|
|
::std::wstring resourceFilename;
|
2013-11-27 21:12:37 +01:00
|
|
|
int resourceID;
|
2013-11-26 10:55:51 +01:00
|
|
|
|
|
|
|
CustomResourceData *customData;
|
2013-11-22 10:46:25 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|