/[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

revision 31 by william, Tue Sep 7 03:24:11 2010 UTC revision 62 by william, Tue Sep 7 11:08:22 2010 UTC
# Line 16  Line 16 
16  #pragma once  #pragma once
17    
18  // Dependencies.h : Contains classes required by all Utilities headers.  // Dependencies.h : Contains classes required by all Utilities headers.
19    //   This file is included by most .h files provided by the Utilities class.
20    
21    // --------------------------------------------------------------------------------------
22    //  Forward Declarations Section
23    // --------------------------------------------------------------------------------------
24    
25    class wxOutputStream;
26    class wxInputStream;
27    class wxPoint;
28    class wxRect;
29    class wxSize;
30    
31    extern const wxSize wxDefaultSize;
32    extern const wxPoint wxDefaultPosition;
33    
34    namespace Threading
35    {
36            class Mutex;
37            class Semaphore;
38            class pxThread;
39    }
40    
41  // This should prove useful....  // This should prove useful....
42  #define wxsFormat wxString::Format  #define wxsFormat wxString::Format
43    
44    #ifdef PCSX2_DEBUG
45    #       define tryDEBUG                         try
46    #       define catchDEBUG(clause)       catch(clause)
47    #else
48    #       define tryDEBUG                         if(true)
49    #       define catchDEBUG(clause)       if(false)
50    #endif
51    
52    #if defined(PCSX2_DEVBUILD) || defined(PCSX2_DEBUG)
53    #       define tryDEVEL                         try
54    #       define catchDEVEL                       catch(clause)
55    #else
56    #       define tryDEBUG                         if(true)
57    #       define catchDEBUG(clause)       if(false)
58    #endif
59    
60    // --------------------------------------------------------------------------------------
61    //  ImplementEnumOperators  (macro)
62    // --------------------------------------------------------------------------------------
63    // This macro implements ++/-- operators for any conforming enumeration.  In order for an
64    // enum to conform, it must have _FIRST and _COUNT members defined, and must have a full
65    // compliment of sequential members (no custom assignments) --- looking like so:
66    //
67    // enum Dummy {
68    //    Dummy_FIRST,
69    //    Dummy_Item = Dummy_FIRST,
70    //    Dummy_Crap,
71    //    Dummy_COUNT
72    // };
73    //
74    // The macro also defines utility functions for bounds checking enumerations:
75    //   EnumIsValid(value);   // returns TRUE if the enum value is between FIRST and COUNT.
76    //   EnumAssert(value);
77    //
78    // It also defines a *prototype* for converting the enumeration to a string.  Note that this
79    // method is not implemented!  You must implement it yourself if you want to use it:
80    //   EnumToString(value);
81    //
82    #define ImplementEnumOperators( enumName ) \
83            static __fi enumName& operator++        ( enumName& src ) { src = (enumName)((int)src+1); return src; } \
84            static __fi enumName& operator--        ( enumName& src ) { src = (enumName)((int)src-1); return src; } \
85            static __fi enumName operator++ ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src+1); return orig; } \
86            static __fi enumName operator-- ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src-1); return orig; } \
87     \
88            static __fi bool operator<      ( const enumName& left, const pxEnumEnd_t& )    { return (int)left < enumName##_COUNT; } \
89            static __fi bool operator!=( const enumName& left, const pxEnumEnd_t& ) { return (int)left != enumName##_COUNT; } \
90            static __fi bool operator==( const enumName& left, const pxEnumEnd_t& ) { return (int)left == enumName##_COUNT; } \
91     \
92            static __fi bool EnumIsValid( enumName id ) { \
93                    return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); } \
94            static __fi bool EnumAssert( enumName id ) { \
95                    return pxAssert( EnumIsValid(id) ); } \
96     \
97            extern const wxChar* EnumToString( enumName id )
98    
99    class pxEnumEnd_t { };
100    static const pxEnumEnd_t pxEnumEnd = {};
101    
102  // --------------------------------------------------------------------------------------  // --------------------------------------------------------------------------------------
103  //  DeclareNoncopyableObject  //  DeclareNoncopyableObject
104  // --------------------------------------------------------------------------------------  // --------------------------------------------------------------------------------------
105  // This macro provides an easy and clean method for ensuring objects are not copyable.  // This macro provides an easy and clean method for ensuring objects are not copyable.
106  // Simply add the macro to the head or tail of your class declaration, and attempts to  // Simply add the macro to the head or tail of your class declaration, and attempts to
107  // copy the class will give you a moderately obtuse compiler error that will have you  // copy the class will give you a moderately obtuse compiler error that will have you
108  // scratching your head for 20 mintes.  // scratching your head for 20 minutes.
109  //  //
110  // (... but that's probably better than having a weird invalid object copy having you  // (... but that's probably better than having a weird invalid object copy having you
111  //  scratch your head for a day).  //  scratch your head for a day).
# Line 50  Line 129 
129          classname& operator=(const classname&)          classname& operator=(const classname&)
130  #endif  #endif
131    
132  //////////////////////////////////////////////////////////////////////////////////////////  
133  // macro provided for tagging translation strings, without actually running them through the  // --------------------------------------------------------------------------------------
134  // translator (which the _() does automatically, and sometimes we don't want that).  This is  //  ScopedBool  -  Makes sure a boolean is set back to FALSE when current scope is left
135  // a shorthand replacement for wxTRANSLATE.  // --------------------------------------------------------------------------------------
136    // Exception-safe way of tracking entry and exit of various functions of execution zones.
137  //  //
138  #define wxLt(a)         (a)  class ScopedBool
139    {
140    protected:
141            bool*   m_boolme;
142    
143    public:
144            ScopedBool(bool& boolme)
145            {
146                    boolme = true;
147                    m_boolme = &boolme;
148            }
149    
150            ~ScopedBool() throw()
151            {
152                    m_boolme = false;
153            }
154    };
155    
156  #include <wx/string.h>  #include <wx/string.h>
 #include <wx/gdicmn.h>          // for wxPoint/wxRect stuff  
157  #include <wx/intl.h>  #include <wx/intl.h>
158  #include <wx/log.h>  #include <wx/log.h>
159    
 #include "Pcsx2Defs.h"  
   
160  #include <stdexcept>  #include <stdexcept>
 #include <algorithm>  
 #include <string>  
161  #include <cstring>              // string.h under c++  #include <cstring>              // string.h under c++
162  #include <cstdio>               // stdio.h under c++  #include <cstdio>               // stdio.h under c++
163  #include <cstdlib>  #include <cstdlib>
164  #include <vector>  #include <vector>
165  #include <list>  #include <list>
166    
167    #include "Pcsx2Defs.h"
168    
169    // ===========================================================================================
170    //  i18n/Translation Feature Set!
171    // ===========================================================================================
172    
173    extern const wxChar* __fastcall pxExpandMsg( const wxChar* key, const wxChar* englishContent );
174    extern const wxChar* __fastcall pxGetTranslation( const wxChar* message );
175    extern bool pxIsEnglish( int id );
176    
177    // --------------------------------------------------------------------------------------
178    //  wxLt(x)   [macro]
179    // --------------------------------------------------------------------------------------
180    // macro provided for tagging translation strings, without actually running them through the
181    // translator (which the _() does automatically, and sometimes we don't want that).  This is
182    // a shorthand replacement for wxTRANSLATE.
183    //
184    #ifndef wxLt
185    #       define wxLt(a)          wxT(a)
186    #endif
187    
188    // --------------------------------------------------------------------------------------
189    //  pxE(x)   [macro]
190    // --------------------------------------------------------------------------------------
191    // Translation Feature: pxE is used as a method of dereferencing very long english text
192    // descriptions via a "key" identifier.  In this way, the english text can be revised without
193    // it breaking existing translation bindings.  Make sure to add pxE to your PO catalog's
194    // source code identifiers, and then reference the source code to see what the current
195    // english version is.
196    //
197    // Valid prefix types:
198    //
199    // .Panel:   Key-based translation of a panel or dialog text; usually either a header or
200    //           checkbox description, by may also include some controls with long labels.
201    //           These have the highest translation priority.
202    //
203    // .Popup:   Key-based translation of a popup dialog box; either a notice, confirmation,
204    //           or error.  These typically have very high translation priority (roughly equal
205    //           or slightly less than pxE_Panel).
206    //
207    // .Error    Key-based translation of error messages, typically used when throwing exceptions
208    //           that have end-user errors.  These are normally (but not always) displayed as popups
209    //           to the user.  Translation priority is medium.
210    //
211    // .Wizard   Key-based translation of a heading, checkbox item, description, or other text
212    //           associated with the First-time wizard.  Translation of these items is considered
213    //           lower-priority to most other messages; but equal or higher priority to tooltips.
214    //
215    // .Tooltip: Key-based translation of a tooltip for a control on a dialog/panel.  Translation
216    //           of these items is typically considered "lowest priority" as they usually provide
217    //           the most tertiary of info to the user.
218    //
219    
220    #define pxE(key, english)                       pxExpandMsg( wxT(key),                                          english )
221    
222  #include "Utilities/Assertions.h"  #include "Utilities/Assertions.h"

Legend:
Removed from v.31  
changed lines
  Added in v.62

  ViewVC Help
Powered by ViewVC 1.1.22