Resource

Inherited: None

Description

Note: This class must be a superclass only and shouldn’t be created manually.

Public Methods

void

decRef ()

void

incRef ()

bool

isUnloadable ()

void

notifyCurrentState ()

void

setState (Resource::State state)

Resource::State

state () const

void

subscribe (Resource::ResourceUpdatedCallback callback, void * object)

void

switchState (Resource::State state)

void

unsubscribe (void * object)

Public Enums

enum Resource::State

Status for the resource.

Constant

Value

Description

Resource::Invalid

0

The state is invalid (Unable to load resource).

Resource::Loading

1

This resource is loading from the disc.

Resource::ToBeUpdated

2

This resource must be updated. Mostly used for the graphical resources to upload resouce to the graphical system. In case of resource doesn’t require updating internal data. The resource must switch state to Ready immediately.

Resource::Ready

3

This resource is ready to use.

Resource::Suspend

4

This resource is not needed at this moment. In case of resource system will require additional memory suspended resources will be unloaded.

Resource::Unloading

5

This resource is marked to be unloaded. Mostly used for the graphical resources to unload resources from the graphical system. In case of resource doesn’t require to unload internal data. The resource must switch state to ToBeDeleted immediately.

Resource::ToBeDeleted

6

This resource will be deleted soon. Resources with this state must not be used anywhere.

Static Methods

None

Methods Description

void Resource::decRef ()

Decreases the reference counter for the resource. In case of the reference count becomes zero the resource set to ResourceState::Suspend state.


void Resource::incRef ()

Increases the reference counter for the resource.


bool Resource::isUnloadable ()

Returns true in case of resource can be unloaded from GPU; otherwise returns false.


void Resource::notifyCurrentState ()

Notifies subscribers about the current state of the resource.


void Resource::setState (Resource::State state)

Sets new state for the resource.

See also *state*().


Resource::State Resource::state () const

Returns state for the resource. For possible states please see Resource::ResourceState.

See also setState().


void Resource::subscribe (Resource::ResourceUpdatedCallback callback, void * object)

Subscribes callback fro object to handle resource status. Increases reference count.


void Resource::switchState (Resource::State state)

Switches the current state to a new state for the resource.


void Resource::unsubscribe (void * object)

Unsubscribes an object to stop handle resource status. Decreases reference count.