/[pcsx2_0.9.7]/trunk/common/include/Utilities/Dependencies.h
ViewVC logotype

Diff of /trunk/common/include/Utilities/Dependencies.h

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

--- trunk/common/include/Utilities/Dependencies.h	2010/09/07 06:28:05	61
+++ trunk/common/include/Utilities/Dependencies.h	2010/09/07 11:08:22	62
@@ -16,17 +16,96 @@
 #pragma once
 
 // Dependencies.h : Contains classes required by all Utilities headers.
+//   This file is included by most .h files provided by the Utilities class.
+
+// --------------------------------------------------------------------------------------
+//  Forward Declarations Section
+// --------------------------------------------------------------------------------------
+
+class wxOutputStream;
+class wxInputStream;
+class wxPoint;
+class wxRect;
+class wxSize;
+
+extern const wxSize wxDefaultSize;
+extern const wxPoint wxDefaultPosition;
+
+namespace Threading
+{
+	class Mutex;
+	class Semaphore;
+	class pxThread;
+}
 
 // This should prove useful....
 #define wxsFormat wxString::Format
 
+#ifdef PCSX2_DEBUG
+#	define tryDEBUG				try
+#	define catchDEBUG(clause)	catch(clause)
+#else
+#	define tryDEBUG				if(true)
+#	define catchDEBUG(clause)	if(false)
+#endif
+
+#if defined(PCSX2_DEVBUILD) || defined(PCSX2_DEBUG)
+#	define tryDEVEL				try
+#	define catchDEVEL			catch(clause)
+#else
+#	define tryDEBUG				if(true)
+#	define catchDEBUG(clause)	if(false)
+#endif
+
+// --------------------------------------------------------------------------------------
+//  ImplementEnumOperators  (macro)
+// --------------------------------------------------------------------------------------
+// This macro implements ++/-- operators for any conforming enumeration.  In order for an
+// enum to conform, it must have _FIRST and _COUNT members defined, and must have a full
+// compliment of sequential members (no custom assignments) --- looking like so:
+//
+// enum Dummy {
+//    Dummy_FIRST,
+//    Dummy_Item = Dummy_FIRST,
+//    Dummy_Crap,
+//    Dummy_COUNT
+// };
+//
+// The macro also defines utility functions for bounds checking enumerations:
+//   EnumIsValid(value);   // returns TRUE if the enum value is between FIRST and COUNT.
+//   EnumAssert(value);
+//
+// It also defines a *prototype* for converting the enumeration to a string.  Note that this
+// method is not implemented!  You must implement it yourself if you want to use it:
+//   EnumToString(value);
+//
+#define ImplementEnumOperators( enumName ) \
+	static __fi enumName& operator++	( enumName& src ) { src = (enumName)((int)src+1); return src; } \
+	static __fi enumName& operator--	( enumName& src ) { src = (enumName)((int)src-1); return src; } \
+	static __fi enumName operator++	( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src+1); return orig; } \
+	static __fi enumName operator--	( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src-1); return orig; } \
+ \
+	static __fi bool operator<	( const enumName& left, const pxEnumEnd_t& )	{ return (int)left < enumName##_COUNT; } \
+	static __fi bool operator!=( const enumName& left, const pxEnumEnd_t& )	{ return (int)left != enumName##_COUNT; } \
+	static __fi bool operator==( const enumName& left, const pxEnumEnd_t& )	{ return (int)left == enumName##_COUNT; } \
+ \
+	static __fi bool EnumIsValid( enumName id ) { \
+		return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); } \
+	static __fi bool EnumAssert( enumName id ) { \
+		return pxAssert( EnumIsValid(id) ); } \
+ \
+	extern const wxChar* EnumToString( enumName id )
+
+class pxEnumEnd_t { };
+static const pxEnumEnd_t pxEnumEnd = {};
+
 // --------------------------------------------------------------------------------------
 //  DeclareNoncopyableObject
 // --------------------------------------------------------------------------------------
 // This macro provides an easy and clean method for ensuring objects are not copyable.
 // Simply add the macro to the head or tail of your class declaration, and attempts to
 // copy the class will give you a moderately obtuse compiler error that will have you
-// scratching your head for 20 mintes.
+// scratching your head for 20 minutes.
 //
 // (... but that's probably better than having a weird invalid object copy having you
 //  scratch your head for a day).
@@ -50,27 +129,94 @@
 	classname& operator=(const classname&)
 #endif
 
-//////////////////////////////////////////////////////////////////////////////////////////
-// macro provided for tagging translation strings, without actually running them through the
-// translator (which the _() does automatically, and sometimes we don't want that).  This is
-// a shorthand replacement for wxTRANSLATE.
+
+// --------------------------------------------------------------------------------------
+//  ScopedBool  -  Makes sure a boolean is set back to FALSE when current scope is left
+// --------------------------------------------------------------------------------------
+// Exception-safe way of tracking entry and exit of various functions of execution zones.
 //
-#define wxLt(a)		(a)
+class ScopedBool
+{
+protected:
+	bool*	m_boolme;
+
+public:
+	ScopedBool(bool& boolme)
+	{
+		boolme = true;
+		m_boolme = &boolme;
+	}
+
+	~ScopedBool() throw()
+	{
+		m_boolme = false;
+	}
+};
 
 #include <wx/string.h>
-#include <wx/gdicmn.h>		// for wxPoint/wxRect stuff
 #include <wx/intl.h>
 #include <wx/log.h>
 
-#include "Pcsx2Defs.h"
-
 #include <stdexcept>
-#include <algorithm>
-#include <string>
 #include <cstring>		// string.h under c++
 #include <cstdio>		// stdio.h under c++
 #include <cstdlib>
 #include <vector>
 #include <list>
 
+#include "Pcsx2Defs.h"
+
+// ===========================================================================================
+//  i18n/Translation Feature Set!
+// ===========================================================================================
+
+extern const wxChar* __fastcall pxExpandMsg( const wxChar* key, const wxChar* englishContent );
+extern const wxChar* __fastcall pxGetTranslation( const wxChar* message );
+extern bool pxIsEnglish( int id );
+
+// --------------------------------------------------------------------------------------
+//  wxLt(x)   [macro]
+// --------------------------------------------------------------------------------------
+// macro provided for tagging translation strings, without actually running them through the
+// translator (which the _() does automatically, and sometimes we don't want that).  This is
+// a shorthand replacement for wxTRANSLATE.
+//
+#ifndef wxLt
+#	define wxLt(a)		wxT(a)
+#endif
+
+// --------------------------------------------------------------------------------------
+//  pxE(x)   [macro]
+// --------------------------------------------------------------------------------------
+// Translation Feature: pxE is used as a method of dereferencing very long english text
+// descriptions via a "key" identifier.  In this way, the english text can be revised without
+// it breaking existing translation bindings.  Make sure to add pxE to your PO catalog's
+// source code identifiers, and then reference the source code to see what the current
+// english version is.
+//
+// Valid prefix types:
+//
+// .Panel:   Key-based translation of a panel or dialog text; usually either a header or
+//           checkbox description, by may also include some controls with long labels.
+//           These have the highest translation priority.
+//
+// .Popup:   Key-based translation of a popup dialog box; either a notice, confirmation,
+//           or error.  These typically have very high translation priority (roughly equal
+//           or slightly less than pxE_Panel).
+//
+// .Error    Key-based translation of error messages, typically used when throwing exceptions
+//           that have end-user errors.  These are normally (but not always) displayed as popups
+//           to the user.  Translation priority is medium.
+//
+// .Wizard   Key-based translation of a heading, checkbox item, description, or other text
+//           associated with the First-time wizard.  Translation of these items is considered
+//           lower-priority to most other messages; but equal or higher priority to tooltips.
+//
+// .Tooltip: Key-based translation of a tooltip for a control on a dialog/panel.  Translation
+//           of these items is typically considered "lowest priority" as they usually provide
+//           the most tertiary of info to the user.
+//
+
+#define pxE(key, english)			pxExpandMsg( wxT(key),						english )
+
 #include "Utilities/Assertions.h"

 

  ViewVC Help
Powered by ViewVC 1.1.22