Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Ogre::Resource Class Reference

Abstract class reprensenting a loadable resource (e.g. More...

#include <OgreResource.h>

Inheritance diagram for Ogre::Resource:

Ogre::ArchiveEx Ogre::BspLevel Ogre::DynLib Ogre::Font Ogre::Material Ogre::Mesh Ogre::Overlay Ogre::Quake3Shader Ogre::Skeleton Ogre::StringResource Ogre::Texture List of all members.

Public Methods

 Resource ()
 Basic constructor. More...

virtual ~Resource ()
 Virtual destructor. More...

virtual void load ()=0
 Loads the resource, if it is not already. More...

virtual void unload ()
 Unloads the resource, but retains data to recreate. More...

virtual size_t getSize (void)
 Retrieves info about the size of the resource. More...

void touch (void)
 'Touches' the resource to indicate it has been used. More...

time_t getLastAccess (void) const
 Gets the last time the resource was 'touched'. More...

const StringgetName (void) const
 Gets resource name. More...

bool isLoaded (void) const
 Returns true if the Resource has been loaded, false otherwise. More...

virtual void destroy ()
 A method to make the resource delete itself. More...


Protected Attributes

String mName
bool mIsLoaded
time_t mLastAccess
size_t mSize

Detailed Description

Abstract class reprensenting a loadable resource (e.g.

textures, sounds etc)

Remarks:
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 mName 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

Ogre::Resource::Resource   [inline]
 

Basic constructor.

@warn Subclasses must init mName and mSize!

virtual Ogre::Resource::~Resource   [inline, virtual]
 

Virtual destructor.

Shouldn't need to be overloaded, as the resource deallocation code should reside in unload()

See also:
Resource::unload()


Member Function Documentation

virtual void Ogre::Resource::destroy void    [inline, virtual]
 

A method to make the resource delete itself.

Note:
This exists because Resource objects could be created in other processes, and they need to be destroyed in the process that created them.

time_t Ogre::Resource::getLastAccess void    const [inline]
 

Gets the last time the resource was 'touched'.

const String& Ogre::Resource::getName void    const [inline]
 

Gets resource name.

Reimplemented in Ogre::Material.

virtual size_t Ogre::Resource::getSize void    [inline, virtual]
 

Retrieves info about the size of the resource.

bool Ogre::Resource::isLoaded void    const [inline]
 

Returns true if the Resource has been loaded, false otherwise.

virtual void Ogre::Resource::load   [pure virtual]
 

Loads the resource, if it is not already.

Implemented in Ogre::ArchiveEx.

void Ogre::Resource::touch void    [inline]
 

'Touches' the resource to indicate it has been used.

virtual void Ogre::Resource::unload void    [inline, virtual]
 

Unloads the resource, but retains data to recreate.

Reimplemented in Ogre::ArchiveEx.


Member Data Documentation

bool Ogre::Resource::mIsLoaded [protected]
 

time_t Ogre::Resource::mLastAccess [protected]
 

String Ogre::Resource::mName [protected]
 

size_t Ogre::Resource::mSize [protected]
 

Copyright © 2002 by The OGRE Team