# HG changeset patch # User phoku@33b003aa-7bff-0310-803a-e67f0ece8222 # Date 1223706225 0 # Node ID 823544621b5bc9f6f923f196358e6dae2b4e58c6 # Parent 72c25cc27d8b087d97fa42b4bd8199af7d0c5da9 Removed the pool listener interface as purpose was unclear and it was unused and not exposed either. Minor cleanups and documentation. diff -r 72c25cc27d8b -r 823544621b5b engine/core/util/resource/pool.cpp --- 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::iterator listener; - for (listener = m_listeners.begin(); listener != m_listeners.end(); listener++) { - (*listener)->poolCleared(); - } std::vector::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::iterator listener; - for (listener = m_listeners.begin(); listener != m_listeners.end(); listener++) { - (*listener)->poolCleared(); - } int count = 0; std::vector::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::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::iterator it = m_loaders.begin(); std::vector::iterator end = m_loaders.end(); diff -r 72c25cc27d8b -r 823544621b5b engine/core/util/resource/pool.h --- 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 m_entries; typedef std::map ResourceLocationToEntry; ResourceLocationToEntry m_location_to_entry; - std::vector m_listeners; std::vector m_loaders; - int m_curind; std::string m_name; - - /** Clears pool from ALL resources. Frees associated memory - */ - void cleanUp(); }; } // FIFE