changeset 149:823544621b5b

Removed the pool listener interface as purpose was unclear and it was unused and not exposed either. Minor cleanups and documentation.
author phoku@33b003aa-7bff-0310-803a-e67f0ece8222
date Sat, 11 Oct 2008 06:23:45 +0000
parents 72c25cc27d8b
children 6e7d228def30
files engine/core/util/resource/pool.cpp engine/core/util/resource/pool.h
diffstat 2 files changed, 5 insertions(+), 50 deletions(-) [+]
line wrap: on
line diff
--- a/engine/core/util/resource/pool.cpp	Sat Oct 11 06:05:11 2008 +0000
+++ b/engine/core/util/resource/pool.cpp	Sat Oct 11 06:23:45 2008 +0000
@@ -38,9 +38,7 @@
 	Pool::Pool(const std::string& name): 
 		m_entries(),
 		m_location_to_entry(),
-		m_listeners(),
 		m_loaders(),
-		m_curind(0),
 		m_name(name)
 	{
 	}
@@ -57,10 +55,6 @@
 	}
 	
 	void Pool::reset() {
-		std::vector<IPoolListener*>::iterator listener;
-		for (listener = m_listeners.begin(); listener != m_listeners.end(); listener++) {
-			(*listener)->poolCleared();
-		}
 		std::vector<PoolEntry*>::iterator entry;
 		for (entry = m_entries.begin(); entry != m_entries.end(); entry++) {
 			// Warn about leaks, but at least display ALL of them
@@ -76,10 +70,6 @@
 	}
 
 	int Pool::purgeLoadedResources() {
-		std::vector<IPoolListener*>::iterator listener;
-		for (listener = m_listeners.begin(); listener != m_listeners.end(); listener++) {
-			(*listener)->poolCleared();
-		}
 		int count = 0;
 		std::vector<PoolEntry*>::iterator it;
 		for (it = m_entries.begin(); it != m_entries.end(); it++) {
@@ -140,8 +130,12 @@
 				throw NotFound(msg.str);
 			}
 
+			// This branch will only be relevant if the resource has been
+			// loaded successfully before, but for some reason the loader
+			// can't load the resource anymore.
+			// Maybe someone deleted a file under FIFE's hands?
 			if (!entry->resource) {
-				LMsg msg("No loader was able to load the requested resource ");
+				LMsg msg("The loader was unable to load the resource ");
 				msg << "#" << index << "<" << entry->location->getFilename()
 				    << "> in pool " << m_name;
 				FL_ERR(_log, msg);
@@ -198,21 +192,6 @@
 		return amount;
 	}
 
-	void Pool::addPoolListener(IPoolListener* listener) {
-		m_listeners.push_back(listener);
-	}
-
-	void Pool::removePoolListener(IPoolListener* listener) {
-		std::vector<IPoolListener*>::iterator i = m_listeners.begin();
-		while (i != m_listeners.end()) {
-			if ((*i) == listener) {
-				m_listeners.erase(i);
-				return;
-			}
-			++i;
-		}
-	}
-
 	void Pool::findAndSetProvider(PoolEntry& entry) {
 		std::vector<ResourceLoader*>::iterator it = m_loaders.begin();
 		std::vector<ResourceLoader*>::iterator end = m_loaders.end();
--- a/engine/core/util/resource/pool.h	Sat Oct 11 06:05:11 2008 +0000
+++ b/engine/core/util/resource/pool.h	Sat Oct 11 06:23:45 2008 +0000
@@ -42,14 +42,6 @@
 
 	class IResource;
 
-	/**  Clients of pool get notifications about pool events through this interface
-	 */
-	class IPoolListener {
-	public:
-		virtual void poolCleared() = 0;
-		virtual ~IPoolListener() {};
-	};
-
 	enum { RES_LOADED = 0x01, RES_NON_LOADED  = 0x02};
 
 	/**  Pool is used to optimize memory usage for resources
@@ -121,16 +113,6 @@
 		 */
 		virtual int getResourceCount(int status);
 
-		/** Adds pool listener.
-		 * Pool listeners get indications e.g. when ownerships of pooled
-		 * resources change.
-		 */
-		virtual void addPoolListener(IPoolListener* listener);
-
-		/** Removes pool listener
-		 */
-		virtual void removePoolListener(IPoolListener* listener);
-
 		/** Prints the cache statistics to the log
 		 */
 		virtual void printStatistics();
@@ -169,14 +151,8 @@
 		std::vector<PoolEntry*> m_entries;
 		typedef std::map<ResourceLocation, int> ResourceLocationToEntry;
 		ResourceLocationToEntry m_location_to_entry;
-		std::vector<IPoolListener*> m_listeners;
 		std::vector<ResourceLoader*> m_loaders;
-		int m_curind;
 		std::string m_name;
-
-		/** Clears pool from ALL resources. Frees associated memory 
-		 */
-		void cleanUp();
 	};
 
 } // FIFE