diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-06-23 23:33:34 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-06-23 23:33:34 +0000 |
commit | 4b0172d1f666a12cffbdd6bd331e95a92d8f652f (patch) | |
tree | dde7ab71fd5d02200be35e041b00e5649f9cd3a8 /src/resources/resourcemanager.h | |
parent | 33587089cf7d87bbc2104e80746fdddc7a5498e1 (diff) | |
download | mana-4b0172d1f666a12cffbdd6bd331e95a92d8f652f.tar.gz mana-4b0172d1f666a12cffbdd6bd331e95a92d8f652f.tar.bz2 mana-4b0172d1f666a12cffbdd6bd331e95a92d8f652f.tar.xz mana-4b0172d1f666a12cffbdd6bd331e95a92d8f652f.zip |
Finishing resource manager ability to clean up resources. Still work to do on
resources other than images.
Diffstat (limited to 'src/resources/resourcemanager.h')
-rw-r--r-- | src/resources/resourcemanager.h | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 2204d455..f95acadc 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -32,17 +32,6 @@ #include "soundeffect.h" /** - * A resource entry descriptor. - */ -struct ResourceEntry -{ - ResourceEntry(); - - Resource *resource; - std::string filePath; -}; - -/** * A class for loading and managing resources. */ class ResourceManager @@ -81,27 +70,35 @@ class ResourceManager * @return A valid resource or <code>NULL</code> if the resource could * not be loaded. */ - Resource *get( - const E_RESOURCE_TYPE &type, - const std::string &idPath); + Resource* + get(const E_RESOURCE_TYPE &type, const std::string &idPath); /** * Convenience wrapper around ResourceManager::create for loading * images. */ - Image *getImage(const std::string &idPath); + Image* + getImage(const std::string &idPath); /** * Convenience wrapper around ResourceManager::create for loading * songs. */ - Music *getMusic(const std::string &idPath); + Music* + getMusic(const std::string &idPath); /** * Convenience wrapper around ResourceManager::create for loading * samples. */ - SoundEffect *getSoundEffect(const std::string &idPath); + SoundEffect* + getSoundEffect(const std::string &idPath); + + /** + * Releases a resource, removing it from the set of loaded resources. + */ + void + release(const std::string &idPath); /** * Allocates data into a buffer pointer for raw data loading. The @@ -113,28 +110,32 @@ class ResourceManager * @return An allocated byte array containing the data that was loaded, * or <code>NULL</code> on fail. */ - void *loadFile(const std::string &fileName, int &fileSize); + void* + loadFile(const std::string &fileName, int &fileSize); /** * Returns an instance of the class, creating one if it does not * already exist. */ - static ResourceManager *getInstance(); + static ResourceManager* + getInstance(); /** * Deletes the class instance if it exists. */ - static void deleteInstance(); + static void + deleteInstance(); private: /** * Searches for zip files and adds them to the PhysicsFS search path. */ - void searchAndAddZipFiles(); + void + searchAndAddZipFiles(); static ResourceManager *instance; - std::map<std::string, ResourceEntry> resources; + std::map<std::string, Resource*> resources; }; #endif |