[Scummvm-cvs-logs] SF.net SVN: scummvm:[51502] scummvm/branches/gsoc2010-plugins/base

toneman1138 at users.sourceforge.net toneman1138 at users.sourceforge.net
Fri Jul 30 11:32:45 CEST 2010


Revision: 51502
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51502&view=rev
Author:   toneman1138
Date:     2010-07-30 09:32:45 +0000 (Fri, 30 Jul 2010)

Log Message:
-----------
initial work on plugin design changes (already added games can be launched with only one plugin loaded at a time if you compile with a 'NEW_PLUGIN_DESIGN_FIRST_REFINEMENT' flag)

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/base/main.cpp
    scummvm/branches/gsoc2010-plugins/base/plugins.cpp
    scummvm/branches/gsoc2010-plugins/base/plugins.h

Modified: scummvm/branches/gsoc2010-plugins/base/main.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/main.cpp	2010-07-30 08:44:40 UTC (rev 51501)
+++ scummvm/branches/gsoc2010-plugins/base/main.cpp	2010-07-30 09:32:45 UTC (rev 51502)
@@ -103,8 +103,9 @@
 	// Query the plugins and find one that will handle the specified gameid
 	printf("User picked target '%s' (gameid '%s')...\n", ConfMan.getActiveDomainName().c_str(), gameid.c_str());
 	printf("  Looking for a plugin supporting this gameid... ");
+	
 	GameDescriptor game = EngineMan.findGame(gameid, &plugin);
-
+	
 	if (plugin == 0) {
 		printf("failed\n");
 		warning("%s is an invalid gameid. Use the --list-games option to list supported gameid", gameid.c_str());
@@ -335,8 +336,12 @@
 		settings.erase("debugflags");
 	}
 
+#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT //note: I'm going to refactor this name later :P
+	// Don't load the plugins initially in this case.
+#else
 	// Load the plugins.
 	PluginManager::instance().loadPlugins();
+#endif
 
 	// Process the remaining command line settings. Must be done after the
 	// config file and the plugins have been loaded.
@@ -367,7 +372,7 @@
 	// Unless a game was specified, show the launcher dialog
 	if (0 == ConfMan.getActiveDomain())
 		launcherDialog();
-
+		
 	// FIXME: We're now looping the launcher. This, of course, doesn't
 	// work as well as it should. In theory everything should be destroyed
 	// cleanly, so this is now enabled to encourage people to fix bits :)

Modified: scummvm/branches/gsoc2010-plugins/base/plugins.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/plugins.cpp	2010-07-30 08:44:40 UTC (rev 51501)
+++ scummvm/branches/gsoc2010-plugins/base/plugins.cpp	2010-07-30 09:32:45 UTC (rev 51502)
@@ -306,6 +306,26 @@
 	_providers.push_back(pp);
 }
 
+bool PluginManager::loadFirstPlugin() {
+	PluginList plugs;
+	for (ProviderList::iterator pp = _providers.begin();
+	                            pp != _providers.end();
+	                            ++pp) {
+		PluginList pl((*pp)->getPlugins());
+		for (PluginList::iterator p = pl.begin(); p != pl.end(); ++p) {
+			plugs.push_back(*p);
+		}
+	}
+	_allPlugs = plugs.begin();
+	return tryLoadPlugin(*_allPlugs); //TODO: return false if no plugins!
+}
+
+bool PluginManager::loadNextPlugin() {
+	unloadPluginsExcept(PLUGIN_TYPE_ENGINE, NULL);
+	++_allPlugs;
+	return tryLoadPlugin(*_allPlugs); //TODO: return false if got to the end of list of plugins.
+}
+
 void PluginManager::loadPlugins() {
 	for (ProviderList::iterator pp = _providers.begin();
 	                            pp != _providers.end();
@@ -313,7 +333,6 @@
 		PluginList pl((*pp)->getPlugins());
 		Common::for_each(pl.begin(), pl.end(), Common::bind1st(Common::mem_fun(&PluginManager::tryLoadPlugin), this));
 	}
-
 }
 
 void PluginManager::unloadPlugins() {
@@ -344,7 +363,6 @@
 		// The plugin is valid, see if it provides the same module as an
 		// already loaded one and should replace it.
 		bool found = false;
-
 		PluginList::iterator pl = _plugins[plugin->getType()].begin();
 		while (!found && pl != _plugins[plugin->getType()].end()) {
 			if (!strcmp(plugin->getName(), (*pl)->getName())) {
@@ -370,7 +388,6 @@
 	}
 }
 
-
 // Engine plugins
 
 #include "engines/metaengine.h"
@@ -385,15 +402,23 @@
 	if (plugin)
 		*plugin = 0;
 
-	EnginePlugin::List::const_iterator iter = plugins.begin();
-	for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
-		result = (**iter)->findGame(gameName.c_str());
-		if (!result.gameid().empty()) {
-			if (plugin)
-				*plugin = *iter;
-			break;
+	EnginePlugin::List::const_iterator iter;
+	
+#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT
+	PluginManager::instance().loadFirstPlugin();
+	do {
+#endif
+		for (iter = plugins.begin(); iter != plugins.end(); ++iter) {
+			result = (**iter)->findGame(gameName.c_str());
+			if (!result.gameid().empty()) {
+				if (plugin)
+					*plugin = *iter;
+				return result;
+			}
 		}
-	}
+#ifdef NEW_PLUGIN_DESIGN_FIRST_REFINEMENT
+	} while(PluginManager::instance().loadNextPlugin());
+#endif
 	return result;
 }
 

Modified: scummvm/branches/gsoc2010-plugins/base/plugins.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/base/plugins.h	2010-07-30 08:44:40 UTC (rev 51501)
+++ scummvm/branches/gsoc2010-plugins/base/plugins.h	2010-07-30 09:32:45 UTC (rev 51502)
@@ -275,9 +275,10 @@
 private:
 	PluginList _plugins[PLUGIN_TYPE_MAX];
 	ProviderList _providers;
-
+	PluginList::iterator _allPlugs;
+	
 	bool tryLoadPlugin(Plugin *plugin);
-
+	
 	friend class Common::Singleton<SingletonBaseType>;
 	PluginManager();
 
@@ -286,6 +287,8 @@
 
 	void addPluginProvider(PluginProvider *pp);
 
+	bool loadFirstPlugin();
+	bool loadNextPlugin();
 	void loadPlugins();
 	void unloadPlugins();
 	void unloadPluginsExcept(PluginType type, const Plugin *plugin);


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