Home | Namespaces | Hierarchy | Alphabetical List | Class list | Files | Namespace Members | Class members | File members |
#include <ResourceManager.h>
Public Member Functions | |
void | addLoadEventReceiver (LoadEventReceiver *newEventReceiver) |
void | addSearchPath (const std::string &path, const std::string &type) |
Adds a relative path to search for resources. | |
Resource * | createResource (const ResourceType &type, const std::string &filename) |
Creates a resource. | |
Resource * | find (const u32 &id) |
Retrieves a pointer to a resource by id, or null if the resource does not exist. | |
Resource * | find (const ResourceType &type, const u32 &id) |
Retrieves a pointer to a resource by type and by id, or null if the resource does not exist. | |
u32 | getMemoryBudget () const |
Get the limit on the amount of memory in bytes the resource manager may use. | |
u32 | getMemoryUsage () const |
Gets the current memory usage, in bytes. | |
bool | loadResource (Resource *resource) |
void | loadResources () |
Load all resource waiting for load. | |
DataStream * | openResource (const std::string &filename) |
void | registerResourceFactory (const ResourceType &type, ResourceFactory *factory) |
void | registerSerializer (const ResourceType &type, Serializer *serializer) |
bool | reloadResource (Resource *resource) |
void | removeAllResources () |
void | removeLoadEventReceiver (LoadEventReceiver *oldEventReceiver) |
void | removeResource (Resource *resource) |
Remove a Resource from the managed resources list, calling it's unload() method. | |
void | removeResource (const u32 &id) |
void | removeResourceFactory (const ResourceType &type) |
void | removeSerializer (const ResourceType &type) |
ResourceManager () | |
void | setPaths (const std::string &resourcesfile) |
void | start () |
void | stop () |
void | unloadResource (Resource *resource) |
void | unloadResources () |
Unload all resources. | |
~ResourceManager () | |
Static Public Member Functions | |
static ResourceManager * | getInstance () |
Get instance. | |
Protected Member Functions | |
void | fireLoadEnded () |
void | fireLoadStarted () |
void | fireLoadUpdate () |
void | initializeImpl () |
void | uninitializeImpl () |
void | updateImpl (f32 elapsedTime) |
Protected Attributes | |
core::ConfigFile * | mConfigFile |
std::map< std::string, platform::FileSystem * > | mFiles |
u32 | mLoadedSize |
LoadEvent * | mLoadEvent |
std::list< LoadEventReceiver * > | mLoadEventReceivers |
std::vector< std::list < Resource * > > | mLoadResources |
Central lists of resources for loading created in order of type. | |
u32 | mMemoryBudget |
u32 | mMemoryUsage |
std::vector< ResourceFactory * > | mResourceFactories |
std::map< u32, Resource * > | mResources |
Central list of resources - for easy memory management and lookup. | |
std::map< std::string, Resource * > | mResourcesByFilename |
std::vector< Serializer * > | mSerializers |
u32 | mTotalLoadSize |
A resource manager is responsible for managing a pool of resources of a particular type. It must index them, look them up, load and destroy them. It may also need to stay within a defined memory budget, and temporaily unload some resources if it needs to to stay within this budget.
resource::ResourceManager::ResourceManager | ( | ) |
resource::ResourceManager::~ResourceManager | ( | ) |
References getInstance(), mLoadEvent, and mMemoryUsage.
void resource::ResourceManager::addLoadEventReceiver | ( | LoadEventReceiver * | newEventReceiver | ) |
References mLoadEventReceivers.
void resource::ResourceManager::addSearchPath | ( | const std::string & | path, |
const std::string & | type | ||
) |
Adds a relative path to search for resources.
References getInstance(), platform::FileSystem::list(), and mFiles.
Referenced by setPaths().
Resource * resource::ResourceManager::createResource | ( | const ResourceType & | type, |
const std::string & | filename | ||
) |
Creates a resource.
References resource::ResourceFactory::createResource(), engine::Object::getID(), getInstance(), engine::Object::getName(), core::intToString(), mLoadResources, mResourceFactories, mResources, mResourcesByFilename, and mSerializers.
Retrieves a pointer to a resource by id, or null if the resource does not exist.
References mResources.
Resource * resource::ResourceManager::find | ( | const ResourceType & | type, |
const u32 & | id | ||
) |
Retrieves a pointer to a resource by type and by id, or null if the resource does not exist.
References mResources.
void resource::ResourceManager::fireLoadEnded | ( | ) | [protected] |
References resource::LoadEvent::loadedSize, mLoadedSize, mLoadEvent, mLoadEventReceivers, mTotalLoadSize, and resource::LoadEvent::totalSize.
Referenced by loadResources(), and unloadResources().
void resource::ResourceManager::fireLoadStarted | ( | ) | [protected] |
References resource::LoadEvent::loadedSize, mLoadedSize, mLoadEvent, mLoadEventReceivers, mTotalLoadSize, and resource::LoadEvent::totalSize.
Referenced by loadResources(), and unloadResources().
void resource::ResourceManager::fireLoadUpdate | ( | ) | [protected] |
References resource::LoadEvent::loadedSize, mLoadedSize, mLoadEvent, mLoadEventReceivers, mTotalLoadSize, and resource::LoadEvent::totalSize.
Referenced by loadResource(), reloadResource(), and unloadResource().
ResourceManager * resource::ResourceManager::getInstance | ( | ) | [static] |
Get instance.
Reimplemented from core::Singleton< ResourceManager >.
Referenced by addSearchPath(), createResource(), render::DebugRenderable::initializeGeometry(), initializeImpl(), resource::Resource::initProperties(), resource::Resource::load(), loadResource(), loadResources(), scene::SceneManager::registerDefaultFactories(), render::RenderManager::registerDefaultFactories(), physics::PhysicsManager::registerDefaultFactories(), reloadResource(), scene::SceneManager::removeAllScenes(), scene::SceneManager::removeDefaultFactories(), render::RenderManager::removeDefaultFactories(), physics::PhysicsManager::removeDefaultFactories(), ResourceManager(), physics::Body::setBodyData(), render::TextOverlay::setFont(), render::PanelOverlay::setMaterial(), render::Model::setMaterial(), render::MeshData::setMaterial(), render::Font::setMaterial(), render::Model::setMeshData(), sound::Sound::setSoundData(), render::TextureUnit::setTexture(), uninitializeImpl(), unloadResource(), unloadResources(), and ~ResourceManager().
u32 resource::ResourceManager::getMemoryBudget | ( | ) | const |
Get the limit on the amount of memory in bytes the resource manager may use.
References mMemoryBudget.
u32 resource::ResourceManager::getMemoryUsage | ( | ) | const |
Gets the current memory usage, in bytes.
References mMemoryUsage.
void resource::ResourceManager::initializeImpl | ( | ) | [protected, virtual] |
Reimplemented from engine::Object.
References getInstance(), and mMemoryBudget.
bool resource::ResourceManager::loadResource | ( | Resource * | resource | ) |
void resource::ResourceManager::loadResources | ( | ) |
Load all resource waiting for load.
References fireLoadEnded(), fireLoadStarted(), getInstance(), resource::Resource::getSize(), loadResource(), mLoadedSize, mLoadResources, mTotalLoadSize, resource::RT_COUNT, and resource::RT_UNDEFINED.
Referenced by engine::EngineManager::start().
DataStream * resource::ResourceManager::openResource | ( | const std::string & | filename | ) |
References mFiles.
Referenced by resource::Resource::initProperties(), and resource::Resource::load().
void resource::ResourceManager::registerResourceFactory | ( | const ResourceType & | type, |
ResourceFactory * | factory | ||
) |
References mResourceFactories.
void resource::ResourceManager::registerSerializer | ( | const ResourceType & | type, |
Serializer * | serializer | ||
) |
References mSerializers.
bool resource::ResourceManager::reloadResource | ( | Resource * | resource | ) |
void resource::ResourceManager::removeAllResources | ( | ) |
References resource::ResourceFactory::destroyResource(), resource::Resource::getResourceType(), mResourceFactories, mResources, mResourcesByFilename, and unloadResource().
Referenced by uninitializeImpl().
void resource::ResourceManager::removeLoadEventReceiver | ( | LoadEventReceiver * | oldEventReceiver | ) |
References mLoadEventReceivers.
void resource::ResourceManager::removeResource | ( | Resource * | resource | ) |
Remove a Resource from the managed resources list, calling it's unload() method.
References engine::Object::getID().
void resource::ResourceManager::removeResource | ( | const u32 & | id | ) |
void resource::ResourceManager::removeResourceFactory | ( | const ResourceType & | type | ) |
References mResourceFactories.
void resource::ResourceManager::removeSerializer | ( | const ResourceType & | type | ) |
References mSerializers.
void resource::ResourceManager::setPaths | ( | const std::string & | resourcesfile | ) |
Method reads a resource configuration file and instantiates all found resource search paths.
resourcesfile,: | The file that contains resources information. |
References addSearchPath(), core::ConfigFile::getSettingsBegin(), core::ConfigFile::getSettingsEnd(), core::ConfigFile::load(), and mConfigFile.
Referenced by engine::EngineManager::setPaths().
void resource::ResourceManager::start | ( | ) |
Referenced by engine::EngineManager::start().
void resource::ResourceManager::stop | ( | ) |
Referenced by engine::EngineManager::stop().
void resource::ResourceManager::uninitializeImpl | ( | ) | [protected, virtual] |
Reimplemented from engine::Object.
References getInstance(), mFiles, mLoadEventReceivers, mLoadResources, mResourcesByFilename, and removeAllResources().
void resource::ResourceManager::unloadResource | ( | Resource * | resource | ) |
void resource::ResourceManager::unloadResources | ( | ) |
Unload all resources.
References fireLoadEnded(), fireLoadStarted(), getInstance(), mLoadedSize, mMemoryUsage, mResources, mTotalLoadSize, and unloadResource().
Referenced by engine::EngineManager::stop().
void resource::ResourceManager::updateImpl | ( | f32 | elapsedTime | ) | [protected, virtual] |
Reimplemented from engine::Object.
References mResources, and engine::Object::update().
core::ConfigFile* resource::ResourceManager::mConfigFile [protected] |
Referenced by ResourceManager(), and setPaths().
std::map<std::string, platform::FileSystem*> resource::ResourceManager::mFiles [protected] |
Referenced by addSearchPath(), openResource(), and uninitializeImpl().
u32 resource::ResourceManager::mLoadedSize [protected] |
Referenced by fireLoadEnded(), fireLoadStarted(), fireLoadUpdate(), loadResource(), loadResources(), ResourceManager(), unloadResource(), and unloadResources().
LoadEvent* resource::ResourceManager::mLoadEvent [protected] |
Referenced by fireLoadEnded(), fireLoadStarted(), fireLoadUpdate(), ResourceManager(), and ~ResourceManager().
std::list<LoadEventReceiver*> resource::ResourceManager::mLoadEventReceivers [protected] |
Referenced by addLoadEventReceiver(), fireLoadEnded(), fireLoadStarted(), fireLoadUpdate(), removeLoadEventReceiver(), and uninitializeImpl().
std::vector<std::list<Resource*> > resource::ResourceManager::mLoadResources [protected] |
Central lists of resources for loading created in order of type.
Referenced by createResource(), loadResources(), removeResource(), ResourceManager(), and uninitializeImpl().
u32 resource::ResourceManager::mMemoryBudget [protected] |
Referenced by getMemoryBudget(), initializeImpl(), loadResource(), and ResourceManager().
u32 resource::ResourceManager::mMemoryUsage [protected] |
Referenced by getMemoryUsage(), loadResource(), ResourceManager(), unloadResource(), unloadResources(), and ~ResourceManager().
std::vector<ResourceFactory*> resource::ResourceManager::mResourceFactories [protected] |
std::map<u32, Resource*> resource::ResourceManager::mResources [protected] |
Central list of resources - for easy memory management and lookup.
Referenced by createResource(), find(), removeAllResources(), removeResource(), unloadResources(), and updateImpl().
std::map<std::string, Resource*> resource::ResourceManager::mResourcesByFilename [protected] |
Referenced by createResource(), removeAllResources(), removeResource(), and uninitializeImpl().
std::vector<Serializer*> resource::ResourceManager::mSerializers [protected] |
Referenced by createResource(), registerSerializer(), removeSerializer(), and ResourceManager().
u32 resource::ResourceManager::mTotalLoadSize [protected] |
Referenced by fireLoadEnded(), fireLoadStarted(), fireLoadUpdate(), loadResources(), ResourceManager(), and unloadResources().
The KG Game Engine
Documentation © 2006-2011 by Kat'Oun. Generated on Sat Jul 2 2011 00:50:10 by
Doxygen
(1.7.4)
|