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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 62 - (hide annotations) (download)
Tue Sep 7 11:08:22 2010 UTC (9 years, 11 months ago) by william
File MIME type: text/plain
File size: 9078 byte(s)
Auto Commited Import of: pcsx2-0.9.7-r3738-debug in ./trunk
1 william 31 /* PCSX2 - PS2 Emulator for PCs
2     * Copyright (C) 2002-2010 PCSX2 Dev Team
3     *
4     * PCSX2 is free software: you can redistribute it and/or modify it under the terms
5     * of the GNU Lesser General Public License as published by the Free Software Found-
6     * ation, either version 3 of the License, or (at your option) any later version.
7     *
8     * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9     * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
10     * PURPOSE. See the GNU General Public License for more details.
11     *
12     * You should have received a copy of the GNU General Public License along with PCSX2.
13     * If not, see <http://www.gnu.org/licenses/>.
14     */
15    
16     #pragma once
17    
18     // Dependencies.h : Contains classes required by all Utilities headers.
19 william 62 // This file is included by most .h files provided by the Utilities class.
20 william 31
21 william 62 // --------------------------------------------------------------------------------------
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 william 31 // This should prove useful....
42     #define wxsFormat wxString::Format
43    
44 william 62 #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 william 31 // --------------------------------------------------------------------------------------
61 william 62 // 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 william 31 // DeclareNoncopyableObject
104     // --------------------------------------------------------------------------------------
105     // 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
107     // copy the class will give you a moderately obtuse compiler error that will have you
108 william 62 // scratching your head for 20 minutes.
109 william 31 //
110     // (... but that's probably better than having a weird invalid object copy having you
111     // scratch your head for a day).
112     //
113     // Programmer's notes:
114     // * We intentionally do NOT provide implementations for these methods, which should
115     // never be referenced anyway.
116    
117     // * I've opted for macro form over multi-inherited class form (Boost style), because
118     // the errors generated by the macro are considerably less voodoo. The Boost-style
119     // The macro reports the exact class that causes the copy failure, while Boost's class
120     // approach just reports an error in whatever "NoncopyableObject" is inherited.
121     //
122     // * This macro is the same as wxWidgets' DECLARE_NO_COPY_CLASS macro. This one is free
123     // of wx dependencies though, and has a nicer typeset. :)
124     //
125     #ifndef DeclareNoncopyableObject
126     # define DeclareNoncopyableObject(classname) \
127     private: \
128     explicit classname(const classname&); \
129     classname& operator=(const classname&)
130     #endif
131    
132 william 62
133     // --------------------------------------------------------------------------------------
134     // ScopedBool - Makes sure a boolean is set back to FALSE when current scope is left
135     // --------------------------------------------------------------------------------------
136     // Exception-safe way of tracking entry and exit of various functions of execution zones.
137 william 31 //
138 william 62 class ScopedBool
139     {
140     protected:
141     bool* m_boolme;
142 william 31
143 william 62 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 william 31 #include <wx/string.h>
157     #include <wx/intl.h>
158     #include <wx/log.h>
159    
160     #include <stdexcept>
161     #include <cstring> // string.h under c++
162     #include <cstdio> // stdio.h under c++
163     #include <cstdlib>
164     #include <vector>
165     #include <list>
166    
167 william 62 #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 william 31 #include "Utilities/Assertions.h"

  ViewVC Help
Powered by ViewVC 1.1.22