summaryrefslogtreecommitdiff
path: root/src/resources/resourcemanager.h
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-16 11:06:46 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-11-16 11:06:46 +0000
commit89e78bcc5b29a8dd14422a8fa6a23a17a93e98e0 (patch)
treee738bf9dde771e59f19e8f162e4e910fe3cc3c1f /src/resources/resourcemanager.h
parent427c2ec86e33c7a23ae38c862d8866fcb2c2eb16 (diff)
downloadmana-client-89e78bcc5b29a8dd14422a8fa6a23a17a93e98e0.tar.gz
mana-client-89e78bcc5b29a8dd14422a8fa6a23a17a93e98e0.tar.bz2
mana-client-89e78bcc5b29a8dd14422a8fa6a23a17a93e98e0.tar.xz
mana-client-89e78bcc5b29a8dd14422a8fa6a23a17a93e98e0.zip
Delayed resource deletion by 30 seconds.
Diffstat (limited to 'src/resources/resourcemanager.h')
-rw-r--r--src/resources/resourcemanager.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index c52248b1..46b17d1b 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -24,6 +24,7 @@
#ifndef _TMW_RESOURCE_MANAGER_H
#define _TMW_RESOURCE_MANAGER_H
+#include <ctime>
#include <map>
#include <string>
#include <vector>
@@ -41,7 +42,11 @@ struct SDL_Surface;
*/
class ResourceManager
{
+
+ friend class Resource;
+
public:
+
typedef Resource *(*loader)(void *, unsigned);
typedef Resource *(*generator)(void *);
@@ -154,10 +159,9 @@ class ResourceManager
SpriteDef *getSprite(std::string const &path, int variant = 0);
/**
- * Releases a resource, removing it from the set of loaded resources.
+ * Releases a resource, placing it in the set of orphaned resources.
*/
- void
- release(const std::string &idPath);
+ void release(Resource *);
/**
* Allocates data into a buffer pointer for raw data loading. The
@@ -205,10 +209,14 @@ class ResourceManager
static void
cleanUp(Resource *resource);
+ void cleanOrphans();
+
static ResourceManager *instance;
typedef std::map<std::string, Resource*> Resources;
typedef Resources::iterator ResourceIterator;
Resources mResources;
+ Resources mOrphanedResources;
+ time_t mOldestOrphan;
};
#endif