[Scummvm-cvs-logs] SF.net SVN: scummvm: [30787] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Feb 4 14:14:52 CET 2008


Revision: 30787
          http://scummvm.svn.sourceforge.net/scummvm/?rev=30787&view=rev
Author:   fingolfin
Date:     2008-02-04 05:14:52 -0800 (Mon, 04 Feb 2008)

Log Message:
-----------
Moved common code from Plugin subclasses to class Plugin itself

Modified Paths:
--------------
    scummvm/trunk/backends/plugins/dynamic-plugin.h
    scummvm/trunk/base/plugins.cpp
    scummvm/trunk/base/plugins.h

Modified: scummvm/trunk/backends/plugins/dynamic-plugin.h
===================================================================
--- scummvm/trunk/backends/plugins/dynamic-plugin.h	2008-02-04 10:15:21 UTC (rev 30786)
+++ scummvm/trunk/backends/plugins/dynamic-plugin.h	2008-02-04 13:14:52 UTC (rev 30787)
@@ -33,44 +33,11 @@
 class DynamicPlugin : public Plugin {
 protected:
 	typedef void (*VoidFunc)();
-
 	typedef MetaEngine *(*MetaAllocFunc)();
 
-	MetaEngine *_metaengine;
-
 	virtual VoidFunc findSymbol(const char *symbol) = 0;
 
 public:
-	DynamicPlugin() : _metaengine(0) {}
-
-	const char *getName() const {
-		return _metaengine->getName();
-	}
-
-	const char *getCopyright() const {
-		return _metaengine->getCopyright();
-	}
-
-	PluginError createInstance(OSystem *syst, Engine **engine) const {
-		return _metaengine->createInstance(syst, engine);
-	}
-
-	GameList getSupportedGames() const {
-		return _metaengine->getSupportedGames();
-	}
-
-	GameDescriptor findGame(const char *gameid) const {
-		return _metaengine->findGame(gameid);
-	}
-
-	GameList detectGames(const FSList &fslist) const {
-		return _metaengine->detectGames(fslist);
-	}
-
-	SaveStateList listSaves(const char *target) const {
-		return _metaengine->listSaves(target);
-	}
-
 	virtual bool loadPlugin() {
 		// Query the plugin's name
 		MetaAllocFunc metaAlloc = (MetaAllocFunc)findSymbol("PLUGIN_MetaEngine_alloc");

Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp	2008-02-04 10:15:21 UTC (rev 30786)
+++ scummvm/trunk/base/plugins.cpp	2008-02-04 13:14:52 UTC (rev 30787)
@@ -28,13 +28,41 @@
 #include "engines/metaengine.h"
 
 
+const char *Plugin::getName() const {
+	return _metaengine->getName();
+}
+
+const char *Plugin::getCopyright() const {
+	return _metaengine->getCopyright();
+}
+
+PluginError Plugin::createInstance(OSystem *syst, Engine **engine) const {
+	return _metaengine->createInstance(syst, engine);
+}
+
+GameList Plugin::getSupportedGames() const {
+	return _metaengine->getSupportedGames();
+}
+
+GameDescriptor Plugin::findGame(const char *gameid) const {
+	return _metaengine->findGame(gameid);
+}
+
+GameList Plugin::detectGames(const FSList &fslist) const {
+	return _metaengine->detectGames(fslist);
+}
+
+SaveStateList Plugin::listSaves(const char *target) const {
+	return _metaengine->listSaves(target);
+}
+
+
 #ifndef DYNAMIC_MODULES
 class StaticPlugin : public Plugin {
-	MetaEngine *_metaengine;
 public:
-	StaticPlugin(MetaEngine *metaengine)
-		: _metaengine(metaengine) {
-		assert(_metaengine);
+	StaticPlugin(MetaEngine *metaengine) {
+		assert(metaengine);
+		_metaengine = metaengine;
 	}
 
 	~StaticPlugin() {
@@ -43,34 +71,6 @@
 
 	virtual bool loadPlugin()		{ return true; }
 	virtual void unloadPlugin()		{}
-
-	const char *getName() const {
-		return _metaengine->getName();
-	}
-
-	const char *getCopyright() const {
-		return _metaengine->getCopyright();
-	}
-
-	PluginError createInstance(OSystem *syst, Engine **engine) const {
-		return _metaengine->createInstance(syst, engine);
-	}
-
-	GameList getSupportedGames() const {
-		return _metaengine->getSupportedGames();
-	}
-
-	GameDescriptor findGame(const char *gameid) const {
-		return _metaengine->findGame(gameid);
-	}
-
-	GameList detectGames(const FSList &fslist) const {
-		return _metaengine->detectGames(fslist);
-	}
-
-	SaveStateList listSaves(const char *target) const {
-		return _metaengine->listSaves(target);
-	}
 };
 
 class StaticPluginProvider : public PluginProvider {

Modified: scummvm/trunk/base/plugins.h
===================================================================
--- scummvm/trunk/base/plugins.h	2008-02-04 10:15:21 UTC (rev 30786)
+++ scummvm/trunk/base/plugins.h	2008-02-04 13:14:52 UTC (rev 30787)
@@ -44,24 +44,30 @@
  * plugins.
  */
 class Plugin {
+protected:
+	MetaEngine *_metaengine;
+
 public:
-	virtual ~Plugin() {}
+	Plugin() : _metaengine(0) {}
+	virtual ~Plugin() {
+		//if (isLoaded())
+			//unloadPlugin();
+	}
 
 //	virtual bool isLoaded() const = 0;	// TODO
-	virtual bool loadPlugin() = 0;
-	virtual void unloadPlugin() = 0;
+	virtual bool loadPlugin() = 0;	// TODO: Rename to load() ?
+	virtual void unloadPlugin() = 0;	// TODO: Rename to unload() ?
 
-	virtual const char *getName() const = 0;
-	virtual const char *getCopyright() const = 0;
+	const char *getName() const;
+	const char *getCopyright() const;
+
 //	virtual int getVersion() const	{ return 0; }	// TODO!
 
-	virtual GameList getSupportedGames() const = 0;
-	virtual GameDescriptor findGame(const char *gameid) const = 0;
-	virtual GameList detectGames(const FSList &fslist) const = 0;
-
-	virtual SaveStateList listSaves(const char *target) const = 0;
-
-	virtual PluginError createInstance(OSystem *syst, Engine **engine) const = 0;
+	PluginError createInstance(OSystem *syst, Engine **engine) const;
+	GameList getSupportedGames() const;
+	GameDescriptor findGame(const char *gameid) const;
+	GameList detectGames(const FSList &fslist) const;
+	SaveStateList listSaves(const char *target) const;
 };
 
 


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