[SCM] Development fot GoFind! branch, master, updated. 1d20ea241ccba53d2c68637d15ccb227a40ed79b

Miriam Ruiz miriam at debian.org
Thu Nov 20 01:30:37 UTC 2008


The following commit has been merged in the master branch:
commit 1d20ea241ccba53d2c68637d15ccb227a40ed79b
Author: Miriam Ruiz <miriam at debian.org>
Date:   Thu Nov 20 02:32:41 2008 +0100

    Added GUI Plugin version

diff --git a/gui_cli.cpp b/gui_cli.cpp
index 9af8312..4e121d5 100644
--- a/gui_cli.cpp
+++ b/gui_cli.cpp
@@ -57,7 +57,7 @@ using namespace ept::textsearch;
 class GUIPlugInCLI : public GUIPlugIn
 {
  public:
-	GUIPlugInCLI()
+	GUIPlugInCLI(GUIPlugInFactory *f) : GUIPlugIn(f)
 	{
 		std::cout << "GUIPlugInCLI() Created" << std::endl;
 	}
@@ -277,6 +277,10 @@ class GUIPlugInCLIFactory : public GUIPlugInFactory
  public:
 	GUIPlugInCLIFactory()
 	{
+#ifdef GUIPLUGIN_VERSION
+		if (version != GUIPlugInFactory::version)
+			fprintf(stderr, "Wrong GUI Plugin Version: Program = 0x%04X, Plugin = 0x%04X\n", GUIPlugInFactory::version, version );			
+#endif
 	}
 
 	~GUIPlugInCLIFactory()
@@ -285,10 +289,22 @@ class GUIPlugInCLIFactory : public GUIPlugInFactory
 
 	virtual GUIPlugIn * CreatePlugIn()
 	{
-		return new GUIPlugInCLI;
+#ifdef GUIPLUGIN_VERSION
+		if (version != GUIPlugInFactory::version)
+			return NULL;
+#endif
+		return new GUIPlugInCLI(this);
 	}
+
+ protected:
+#ifdef GUIPLUGIN_VERSION
+	const static unsigned int version;
+#endif
 };
 
+#ifdef GUIPLUGIN_VERSION
+	const unsigned int GUIPlugInCLIFactory::version = GUIPLUGIN_VERSION;
+#endif
 
 //
 // The "C" linkage factory0() function creates the PlugIn Factory
diff --git a/guiplugin.cpp b/guiplugin.cpp
index 81dc398..f03b3fd 100644
--- a/guiplugin.cpp
+++ b/guiplugin.cpp
@@ -24,12 +24,16 @@
 
 #include "guiplugin.h"
 
+#ifdef GUIPLUGIN_VERSION
+	const unsigned int GUIPlugInFactory::version = GUIPLUGIN_VERSION;
+#endif
+
 //
 // Announce to the world that the PlugIn base
 // class has been created or destroyed
 //
 
-GUIPlugIn::GUIPlugIn() 
+GUIPlugIn::GUIPlugIn(GUIPlugInFactory *f) : factory(f)
 {
 	std::cout << "GUIPlugIn Created" << std::endl;
 }
diff --git a/guiplugin.h b/guiplugin.h
index d4abd28..6d0f4b9 100644
--- a/guiplugin.h
+++ b/guiplugin.h
@@ -19,55 +19,34 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#ifndef __PLUGIN_H
-#define __PLUGIN_H
+#ifndef _GOFIND_GUIPLUGIN_H
+#define _GOFIND_GUIPLUGIN_H
 
 #include "dll.h"
 #include "Engine.h"
 
 #include <iostream>
 
-//
-// PlugIn is an abstract class.
-//
-// This is an example plug in.  This plug in only has one method, Show(),
-// which we will use to show its name.
-//
-//
+#define GUIPLUGIN_VERSION 0x0001
 
 using namespace ept;
 
+class GUIPlugInFactory;
+
 class GUIPlugIn
 {
  public:
-	GUIPlugIn();
+	GUIPlugIn(GUIPlugInFactory *f);
 
 	virtual ~GUIPlugIn();
 
 	virtual void Comment(const char *szFormat, ...) = 0;
 	virtual bool Go(Engine &engine) = 0;
+ 
+ protected:
+	 GUIPlugInFactory *factory;
 };
 
-
-//
-// The is an example factory for plug ins. 
-//
-// This example factory only announces when it is created/destroyed and
-// has the single abstract method CreatePlugIn() which returns a type 
-// of plug in.
-//
-// In the real world, you may have multiple different classes in each
-// shared library that are made to work together.  All these classes
-// must be created by the Factory class.
-//
-// You may find it useful to have the objects that you create with
-// the factory class be given a pointer to the factory class so
-// they can create their own objects that they need, using the same
-// factory class.  Compiler support of covariant return types is 
-// real useful here.
-//
-
-
 class GUIPlugInFactory
 {
  public:
@@ -82,6 +61,11 @@ class GUIPlugInFactory
 	}
 	
 	virtual GUIPlugIn * CreatePlugIn() = 0;
-};
 
+ protected:
+#ifdef GUIPLUGIN_VERSION
+	const static unsigned int version;
 #endif
+};
+
+#endif // _GOFIND_GUIPLUGIN_H

-- 
Development fot GoFind!



More information about the Pkg-games-commits mailing list