[Scummvm-cvs-logs] SF.net SVN: scummvm: [32121] scummvm/trunk/base
jvprat at users.sourceforge.net
jvprat at users.sourceforge.net
Wed May 14 19:26:06 CEST 2008
Revision: 32121
http://scummvm.svn.sourceforge.net/scummvm/?rev=32121&view=rev
Author: jvprat
Date: 2008-05-14 10:26:05 -0700 (Wed, 14 May 2008)
Log Message:
-----------
Added plugin priority so there's just one plugin that provides a module functionality.
Modified Paths:
--------------
scummvm/trunk/base/plugins.cpp
scummvm/trunk/base/plugins.h
Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp 2008-05-14 16:59:34 UTC (rev 32120)
+++ scummvm/trunk/base/plugins.cpp 2008-05-14 17:26:05 UTC (rev 32121)
@@ -317,17 +317,27 @@
assert(plugin);
// Try to load the plugin
if (plugin->loadPlugin()) {
- // If successful, add it to the list of known plugins and return.
- _plugins[plugin->getType()].push_back(plugin);
+ // The plugin is valid, see if it provides the same module as an
+ // already loaded one and should replace it.
+ bool found = false;
- // TODO/FIXME: We should perform some additional checks here:
- // * Check for some kind of "API version" (possibly derived from the
- // SVN tree revision?)
- // * If two plugins provide the same engine, we should only load one.
- // To detect this situation, we could just compare the plugin name.
- // To handle it, simply prefer modules loaded earlier to those coming.
- // Or vice versa... to be determined... :-)
+ PluginList::iterator pl = _plugins[plugin->getType()].begin();
+ while (!found && pl != _plugins[plugin->getType()].end()) {
+ if (!strcmp(plugin->getName(), (*pl)->getName())) {
+ // Found a duplicated module. Replace the old one.
+ found = true;
+ delete *pl;
+ *pl = plugin;
+ debug(1, "Replaced the duplicated plugin: '%s'", plugin->getName());
+ }
+ pl++;
+ }
+ if (!found) {
+ // If it provides a new module, just add it to the list of known plugins.
+ _plugins[plugin->getType()].push_back(plugin);
+ }
+
return true;
} else {
// Failed to load the plugin
Modified: scummvm/trunk/base/plugins.h
===================================================================
--- scummvm/trunk/base/plugins.h 2008-05-14 16:59:34 UTC (rev 32120)
+++ scummvm/trunk/base/plugins.h 2008-05-14 17:26:05 UTC (rev 32121)
@@ -27,9 +27,8 @@
#define BASE_PLUGINS_H
#include "common/error.h"
-#include "common/list.h"
#include "common/singleton.h"
-#include "base/game.h"
+#include "common/util.h"
#ifdef DYNAMIC_MODULES
#include "common/fs.h"
@@ -69,7 +68,7 @@
};
// TODO: Make the engine API version depend on ScummVM's version
-// because of the backlinking
+// because of the backlinking (posibly from the SVN revision)
#define PLUGIN_TYPE_ENGINE_VERSION 1
#define PLUGIN_TYPE_MIDI_VERSION 1
@@ -274,7 +273,7 @@
* managing all Plugin class instances, and unloading them.
*/
class PluginManager : public Common::Singleton<PluginManager> {
- typedef Common::List<PluginProvider *> ProviderList;
+ typedef Common::Array<PluginProvider *> ProviderList;
private:
PluginList _plugins[PLUGIN_TYPE_MAX];
ProviderList _providers;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list