Resource Class Reference
[Framework Module]

#include <resource.h>

Inheritance diagram for Resource:

Root Object TreeNode< Root > Referenced Counted Serialized List< Root > ListNode< Root > Font SerializedResource Sound SoundResource Texture OpenGLFont Animation Mesh Model OpenALSound OpenALSoundResource OpenGLTexture

List of all members.


Detailed Description

A superclass of all resource related subclasses such as Sound, Texture and so on.

Public Types

enum  Type {
  RES_SOUND, RES_SOUND_RESOURCE, RES_TEXTURE, RES_MESH,
  RES_MODEL, RES_ANIMATION, RES_FONT, RES_OTHER,
  RES_COUNT, RES_ALL, RES_INVALID
}
 Resource type. More...

Public Member Functions

 Resource (const char *id)
virtual ~Resource ()
bool Load ()
void Unload ()
Type GetType () const
bool TestType (Type t) const
bool IsLoaded () const
void SetFileName (const string &file_name)
const string & GetFileName () const
void SetDataFile (DataFile *data_file)
DataFileGetDataFile () const
virtual ulong_t GetDataSize ()
uint_t GetUniqueId () const

Protected Member Functions

virtual bool LoadResource ()
virtual void UnloadResource ()

Protected Attributes

Type type
bool loaded
string file_name
 File name to load.
DataFiledata_file
 Data file will be used insted of file name.
uint_t unique_id
Ref< ResourceServerres_server

Friends

class ResourceServer

Member Enumeration Documentation

enum Resource::Type

Resource type.

Enumerator:
RES_SOUND  A non-shared sound (Sound).
RES_SOUND_RESOURCE  A shared sound resource (SoundResource).
RES_TEXTURE  A texture object.
RES_MESH  A mesh object.
RES_MODEL  A model object.
RES_ANIMATION  An animation.
RES_FONT  Font data.
RES_OTHER  Something else.
RES_COUNT  Count of types.
RES_ALL  Means all types.
RES_INVALID  Invalid type.


Constructor & Destructor Documentation

Resource::Resource ( const char *  id  ) 

Constructor.

Resource::~Resource (  )  [virtual]

Destructor.


Member Function Documentation

bool Resource::Load (  ) 

Requests to load a resource. Invoke the LoadResource() method which should be overriden by subclasses to implement the actual loading.

Pozn. Load() je oddelene od LoadResource() aby bolo mozne urobit nacitavanie na pozadi. V takomto pripade Load() iba prida job a nic viac. Ked sa job dostane na rad, zavola sa LoadResource().

Returns:
True if all ok.

void Resource::Unload (  ) 

Unload the resource data, freeing runtime resources. This method will call the protected virtual UnloadResources() method which should be overriden by subclasses.

Resource::Type Resource::GetType (  )  const [inline]

Gets the resource type.

Returns:
Resource type.

bool Resource::TestType ( Type  t  )  const [inline]

Tests the resource type.

Returns:
True if tested type is same as current type.

bool Resource::IsLoaded (  )  const [inline]

void Resource::SetFileName ( const string &  file_name  )  [inline]

Sets path to the resource file.

Parameters:
file_name Path to the resource file.

const string & Resource::GetFileName (  )  const [inline]

Gets path to the resource file.

Returns:
Path to the resource file.

void Resource::SetDataFile ( DataFile data_file  )  [inline]

DataFile * Resource::GetDataFile (  )  const [inline]

ulong_t Resource::GetDataSize (  )  [virtual]

Return an estimated byte size of the resource data. This is only used for statistics.

Reimplemented in Animation, Mesh, Model, OpenALSound, OpenALSoundResource, OpenGLFont, and OpenGLTexture.

uint_t Resource::GetUniqueId (  )  const [inline]

Returns the unique id of this resource object. You should use the unique id to check whether 2 resources are identical instead of comparing their pointers.

bool Resource::LoadResource (  )  [protected, virtual]

Subclasses must override this method and implement the actual resource loading code here. The method may get called from a thread (if the class returns true in the CanLoadAsync() method and the resource object works in async mode).

Reimplemented in Model, SerializedResource, OpenALSound, OpenALSoundResource, OpenGLFont, and OpenGLTexture.

void Resource::UnloadResource (  )  [protected, virtual]

Subclasses must override this method and implement the resource unloading. This method will always run in the main thread.

Reimplemented in SerializedResource, OpenALSound, OpenALSoundResource, OpenGLFont, and OpenGLTexture.


Friends And Related Function Documentation

friend class ResourceServer [friend]


Member Data Documentation

Type Resource::type [protected]

Reimplemented in Animation.

bool Resource::loaded [protected]

string Resource::file_name [protected]

File name to load.

DataFile* Resource::data_file [protected]

Data file will be used insted of file name.

uint_t Resource::unique_id [protected]

Ref<ResourceServer> Resource::res_server [protected]


The documentation for this class was generated from the following files:
Generated on Sat Oct 20 14:47:34 2007 for Dark Oberon by  doxygen 1.5.3