/[pcsx2_0.9.7]/trunk/pcsx2/Plugins.h
ViewVC logotype

Diff of /trunk/pcsx2/Plugins.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- trunk/pcsx2/Plugins.h	2010/09/07 03:24:11	31
+++ trunk/pcsx2/Plugins.h	2010/09/07 11:08:22	62
@@ -55,24 +55,21 @@
 namespace Exception
 {
 	// Exception thrown when a corrupted or truncated savestate is encountered.
-	class SaveStateLoadError : public virtual BadStream
+	class SaveStateLoadError : public BadStream
 	{
-	public:
-		DEFINE_STREAM_EXCEPTION( SaveStateLoadError, wxLt("Load failed: The savestate appears to be corrupt or incomplete.") )
+		DEFINE_STREAM_EXCEPTION( SaveStateLoadError, BadStream, wxLt("The savestate appears to be corrupt or incomplete.") )
 	};
 
-	class PluginError : public virtual RuntimeError
+	class PluginError : public RuntimeError
 	{
+		DEFINE_RUNTIME_EXCEPTION( PluginError, RuntimeError, L"Generic plugin error")
+
 	public:
 		PluginsEnum_t PluginId;
 
 	public:
-		DEFINE_EXCEPTION_COPYTORS( PluginError )
-
-		PluginError() {}
-		PluginError( PluginsEnum_t pid, const char* msg="Generic plugin error" )
+		explicit PluginError( PluginsEnum_t pid )
 		{
-			BaseException::InitBaseEx( msg );
 			PluginId = pid;
 		}
 
@@ -81,17 +78,24 @@
 	};
 
 	// Plugin load errors occur when initially trying to load plugins during the
-	// creation of a PluginManager object.  The error may either be due to non-existence,
+	// creation of a SysCorePlugins object.  The error may either be due to non-existence,
 	// corruption, or incompatible versioning.
-	class PluginLoadError : public virtual PluginError, public virtual BadStream
+	class PluginLoadError : public PluginError
 	{
+		DEFINE_EXCEPTION_COPYTORS( PluginLoadError, PluginError )
+		DEFINE_EXCEPTION_MESSAGES( PluginLoadError )
+
 	public:
-		DEFINE_EXCEPTION_COPYTORS_COVARIANT( PluginLoadError )
+		wxString	StreamName;
 
-		PluginLoadError( PluginsEnum_t pid, const wxString& objname, const char* eng );
+	protected:
+		PluginLoadError() {}
+
+	public:
+		PluginLoadError( PluginsEnum_t pid );
 
-		PluginLoadError( PluginsEnum_t pid, const wxString& objname,
-			const wxString& eng_msg, const wxString& xlt_msg );
+		virtual PluginLoadError& SetStreamName( const wxString& name )	{ StreamName = name;			return *this; } \
+		virtual PluginLoadError& SetStreamName( const char* name )		{ StreamName = fromUTF8(name);	return *this; }
 
 		virtual wxString FormatDiagnosticMessage() const;
 		virtual wxString FormatDisplayMessage() const;
@@ -100,44 +104,46 @@
 	// Thrown when a plugin fails it's init() callback.  The meaning of this error is entirely
 	// dependent on the plugin and, in most cases probably never happens (most plugins do little
 	// more than a couple basic memory reservations during init)
-	class PluginInitError : public virtual PluginError
+	class PluginInitError : public PluginError
 	{
-	public:
-		DEFINE_EXCEPTION_COPYTORS_COVARIANT( PluginInitError )
+		DEFINE_EXCEPTION_COPYTORS( PluginInitError, PluginError )
+		DEFINE_EXCEPTION_MESSAGES( PluginInitError )
 
-		explicit PluginInitError( PluginsEnum_t pid,
-			const char* msg=wxLt("%s plugin failed to initialize.  Your system may have insufficient memory or resources needed.") )
-		{
-			BaseException::InitBaseEx( msg );
-			PluginId = pid;
-		}
+	protected:
+		PluginInitError() {}
+
+	public:
+		PluginInitError( PluginsEnum_t pid );
 	};
 
 	// Plugin failed to open.  Typically this is a non-critical error that means the plugin has
 	// not been configured properly by the user, but may also be indicative of a system
-	class PluginOpenError : public virtual PluginError
+	class PluginOpenError : public PluginError
 	{
-	public:
-		DEFINE_EXCEPTION_COPYTORS_COVARIANT( PluginOpenError )
+		DEFINE_EXCEPTION_COPYTORS( PluginOpenError, PluginError )
+		DEFINE_EXCEPTION_MESSAGES( PluginOpenError )
 
-		explicit PluginOpenError( PluginsEnum_t pid,
-			const char* msg=wxLt("%s plugin failed to open.  Your computer may have insufficient resources, or incompatible hardware/drivers.") )
-		{
-			BaseException::InitBaseEx( msg );
-			PluginId = pid;
-		}
+	protected:
+		PluginOpenError() {}
+
+	public:
+		explicit PluginOpenError( PluginsEnum_t pid );
 	};
 	
 	// This exception is thrown when a plugin returns an error while trying to save itself.
 	// Typically this should be a very rare occurance since a plugin typically shoudn't
 	// be doing memory allocations or file access during state saving.
 	//
-	class FreezePluginFailure : public virtual PluginError
+	class FreezePluginFailure : public PluginError
 	{
-	public:
-		DEFINE_EXCEPTION_COPYTORS( FreezePluginFailure )
+		DEFINE_EXCEPTION_COPYTORS( FreezePluginFailure, PluginError )
+		DEFINE_EXCEPTION_MESSAGES( FreezePluginFailure )
+
+	protected:
+		FreezePluginFailure() {}
 
-		explicit FreezePluginFailure( PluginsEnum_t pid)
+	public:
+		explicit FreezePluginFailure( PluginsEnum_t pid )
 		{
 			PluginId = pid;
 		}
@@ -146,11 +152,18 @@
 		virtual wxString FormatDisplayMessage() const;
 	};
 
-	class ThawPluginFailure : public virtual PluginError, public virtual SaveStateLoadError
+	class ThawPluginFailure : public SaveStateLoadError
 	{
+		DEFINE_EXCEPTION_COPYTORS( ThawPluginFailure, SaveStateLoadError )
+		DEFINE_EXCEPTION_MESSAGES( ThawPluginFailure )
+
 	public:
-		DEFINE_EXCEPTION_COPYTORS( ThawPluginFailure )
+		PluginsEnum_t PluginId;
+
+	protected:
+		ThawPluginFailure() {}
 
+	public:
 		explicit ThawPluginFailure( PluginsEnum_t pid )
 		{
 			PluginId = pid;
@@ -165,6 +178,8 @@
 #	pragma warning(pop)
 #endif
 
+typedef void CALLBACK FnType_SetDir( const char* dir );
+
 // --------------------------------------------------------------------------------------
 //  LegacyPluginAPI_Common
 // --------------------------------------------------------------------------------------
@@ -180,8 +195,9 @@
 	void (CALLBACK* Shutdown)();
 
 	void (CALLBACK* KeyEvent)( keyEvent* evt );
-	void (CALLBACK* SetSettingsDir)( const char* dir );
-	void (CALLBACK* SetLogFolder)( const char* dir );
+
+	FnType_SetDir* SetSettingsDir;
+	FnType_SetDir* SetLogDir;
 
 	s32  (CALLBACK* Freeze)(int mode, freezeData *data);
 	s32  (CALLBACK* Test)();
@@ -201,7 +217,7 @@
 //  PluginBindings
 // --------------------------------------------------------------------------------------
 // This structure is intended to be the "future" of PCSX2's plugin interface, and will hopefully
-// make the current PluginManager largely obsolete (with the exception of the general Load/Unload
+// make the current SysCorePlugins largely obsolete (with the exception of the general Load/Unload
 // management facilities)
 //
 class SysPluginBindings
@@ -222,18 +238,18 @@
 	void McdEraseBlock( uint port, uint slot, u32 adr );
 	u64  McdGetCRC( uint port, uint slot );
 
-	friend class PluginManager;
+	friend class SysCorePlugins;
 };
 
 extern SysPluginBindings SysPlugins;
 
 // --------------------------------------------------------------------------------------
-//  PluginManager Class
+//  SysCorePlugins Class
 // --------------------------------------------------------------------------------------
 //
-class PluginManager
+class SysCorePlugins
 {
-	DeclareNoncopyableObject( PluginManager );
+	DeclareNoncopyableObject( SysCorePlugins );
 
 protected:
 	class PluginStatus_t
@@ -279,8 +295,8 @@
 	ScopedPtr<PluginStatus_t>	m_info[PluginId_Count];
 
 public:
-	PluginManager();
-	virtual ~PluginManager() throw();
+	SysCorePlugins();
+	virtual ~SysCorePlugins() throw();
 
 	virtual void Load( PluginsEnum_t pid, const wxString& srcfile );
 	virtual void Load( const wxString (&folders)[PluginId_Count] );
@@ -288,15 +304,16 @@
 	virtual void Unload( PluginsEnum_t pid );
 
 	bool AreLoaded() const;
+	bool AreOpen() const;
 	bool AreAnyLoaded() const;
 	bool AreAnyInitialized() const;
 	
 	Threading::Mutex& GetMutex() { return m_mtx_PluginStatus; }
 
-	virtual void Init();
+	virtual bool Init();
 	virtual void Init( PluginsEnum_t pid );
 	virtual void Shutdown( PluginsEnum_t pid );
-	virtual void Shutdown();
+	virtual bool Shutdown();
 	virtual void Open();
 	virtual void Open( PluginsEnum_t pid );
 	virtual void Close( PluginsEnum_t pid );
@@ -312,8 +329,8 @@
 	virtual bool KeyEvent( const keyEvent& evt );
 	virtual void Configure( PluginsEnum_t pid );
 	virtual void SetSettingsFolder( const wxString& folder );
+	virtual void SetLogFolder( const wxString& folder );
 	virtual void SendSettingsFolder();
-    virtual void SetLogFolder( const wxString& folder );
 	virtual void SendLogFolder();
 
 
@@ -357,10 +374,10 @@
 
 // GetPluginManager() is a required external implementation. This function is *NOT*
 // provided by the PCSX2 core library.  It provides an interface for the linking User
-// Interface apps or DLLs to reference their own instance of PluginManager (also allowing
+// Interface apps or DLLs to reference their own instance of SysCorePlugins (also allowing
 // them to extend the class and override virtual methods).
 
-extern PluginManager& GetCorePlugins();
+extern SysCorePlugins& GetCorePlugins();
 
 // Hack to expose internal MemoryCard plugin:
 

 

  ViewVC Help
Powered by ViewVC 1.1.22