Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members
Public Member Functions | Protected Member Functions | Protected Attributes | Friends
resource::Resource Class Reference

#include <Resource.h>

Inheritance diagram for resource::Resource:
engine::Object physics::BodyData physics::Material render::Font render::Material render::MeshData render::Shader render::Texture scene::Scene script::Script sound::SoundData

List of all members.

Public Member Functions

void addResourceEventReceiver (ResourceEventReceiver *newEventReceiver)
const std::string & getFilename () const
const ResourceTypegetResourceType () const
 Gets resource type.
u32 getSize ()
 Retrieves info about the size of the resource.
const ResourceStategetState () const
bool load ()
bool reload ()
void removeResourceEventReceiver (ResourceEventReceiver *oldEventReceiver)
 Resource (const std::string &name, Serializer *serializer=NULL)
void unload ()
virtual ~Resource ()

Protected Member Functions

void fireLoaded ()
 internal method for firing events.
void fireUnloaded ()
 internal method for firing events.
void initProperties ()
virtual bool loadImpl ()
virtual void unloadImpl ()
virtual void updateImpl (f32 elapsedTime)

Protected Attributes

< ResourceEventReceiver * > 
std::string mFilename
< ResourceEventReceiver * > 
ResourceType mResourceType
u32 mSize
ResourceState mState


class ResourceManager
class Serializer

Detailed Description

Abstract class reprensenting a loadable resource (e.g. textures, sounds etc)

Resources are generally passive constructs, handled through the ResourceManager abstract class for the appropriate subclass. The main thing is that Resources can be loaded or unloaded by the ResourceManager to stay within a defined memory budget. Therefore, all Resources must be able to load, unload (whilst retainin enough info about themselves to be reloaded later), and state how big they are.

Subclasses must implement: 1. A constructor, with at least a mandatory name param. This constructor must set mID and optionally mSize. 2. The load() and unload() methods - mSize must be set after load() Each must check & update the mIsLoaded flag.

Constructor & Destructor Documentation

resource::Resource::Resource ( const std::string &  name,
Serializer serializer = NULL 
resource::Resource::~Resource ( ) [virtual]

References mDataStream, and mResourceEvent.

Member Function Documentation

void resource::Resource::addResourceEventReceiver ( ResourceEventReceiver newEventReceiver)
void resource::Resource::fireLoaded ( ) [protected]

internal method for firing events.

References mResourceEvent, mResourceEventReceivers, and resource::ResourceEvent::source.

Referenced by load().

void resource::Resource::fireUnloaded ( ) [protected]

internal method for firing events.

References mResourceEvent, mResourceEventReceivers, and resource::ResourceEvent::source.

Referenced by unload().

const std::string & resource::Resource::getFilename ( ) const
const ResourceType & resource::Resource::getResourceType ( ) const
u32 resource::Resource::getSize ( )
const ResourceState & resource::Resource::getState ( ) const
void resource::Resource::initProperties ( ) [protected]
bool resource::Resource::load ( )
bool resource::Resource::loadImpl ( ) [protected, virtual]

Reimplemented in render::Shader, and script::Script.

References resource::Serializer::importResource(), mDataStream, and mSerializer.

Referenced by load().

bool resource::Resource::reload ( )
void resource::Resource::removeResourceEventReceiver ( ResourceEventReceiver oldEventReceiver)
void resource::Resource::unload ( )
void resource::Resource::unloadImpl ( ) [protected, virtual]
void resource::Resource::updateImpl ( f32  elapsedTime) [protected, virtual]

if there were ResourceEventReceivers added when the resource was already loaded then send them the loaded event

Reimplemented from engine::Object.

References mAlreadyLoadedEventReceivers, mResourceEvent, and resource::ResourceEvent::source.

Friends And Related Function Documentation

friend class ResourceManager [friend]
friend class Serializer [friend]

Member Data Documentation

std::string resource::Resource::mFilename [protected]

Referenced by getFilename(), initProperties(), and load().

Referenced by loadImpl(), and Resource().

Reimplemented in render::Texture.

Referenced by getSize(), initProperties(), and load().

The documentation for this class was generated from the following files:

The KG Game Engine
The KG Game Engine Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:10 by Doxygen (1.7.4)