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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 280 - (show annotations) (download)
Thu Dec 23 12:02:12 2010 UTC (9 years, 1 month ago) by william
File MIME type: text/plain
File size: 10011 byte(s)
re-commit (had local access denied errors when committing)
1 /* 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 // 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 wxFileOutputStream;
27 class wxFFileOutputStream;
28
29 class wxInputStream;
30 class wxFileInputStream;
31 class wxFFileInputStream;
32
33 class wxPoint;
34 class wxRect;
35 class wxSize;
36
37 extern const wxSize wxDefaultSize;
38 extern const wxPoint wxDefaultPosition;
39
40 namespace Threading
41 {
42 class Mutex;
43 class Semaphore;
44 class pxThread;
45 }
46
47 namespace Exception
48 {
49 class BaseException;
50 }
51
52 // This should prove useful....
53 #define wxsFormat wxString::Format
54
55 #ifdef PCSX2_DEBUG
56 # define tryDEBUG try
57 # define catchDEBUG(clause) catch(clause)
58 #else
59 # define tryDEBUG if(true)
60 # define catchDEBUG(clause) if(false)
61 #endif
62
63 #if defined(PCSX2_DEVBUILD) || defined(PCSX2_DEBUG)
64 # define tryDEVEL try
65 # define catchDEVEL catch(clause)
66 #else
67 # define tryDEBUG if(true)
68 # define catchDEBUG(clause) if(false)
69 #endif
70
71 // --------------------------------------------------------------------------------------
72 // ImplementEnumOperators (macro)
73 // --------------------------------------------------------------------------------------
74 // This macro implements ++/-- operators for any conforming enumeration. In order for an
75 // enum to conform, it must have _FIRST and _COUNT members defined, and must have a full
76 // compliment of sequential members (no custom assignments) --- looking like so:
77 //
78 // enum Dummy {
79 // Dummy_FIRST,
80 // Dummy_Item = Dummy_FIRST,
81 // Dummy_Crap,
82 // Dummy_COUNT
83 // };
84 //
85 // The macro also defines utility functions for bounds checking enumerations:
86 // EnumIsValid(value); // returns TRUE if the enum value is between FIRST and COUNT.
87 // EnumAssert(value);
88 //
89 // It also defines a *prototype* for converting the enumeration to a string. Note that this
90 // method is not implemented! You must implement it yourself if you want to use it:
91 // EnumToString(value);
92 //
93 #define ImplementEnumOperators( enumName ) \
94 static __fi enumName& operator++ ( enumName& src ) { src = (enumName)((int)src+1); return src; } \
95 static __fi enumName& operator-- ( enumName& src ) { src = (enumName)((int)src-1); return src; } \
96 static __fi enumName operator++ ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src+1); return orig; } \
97 static __fi enumName operator-- ( enumName& src, int ) { enumName orig = src; src = (enumName)((int)src-1); return orig; } \
98 \
99 static __fi bool operator< ( const enumName& left, const pxEnumEnd_t& ) { return (int)left < enumName##_COUNT; } \
100 static __fi bool operator!=( const enumName& left, const pxEnumEnd_t& ) { return (int)left != enumName##_COUNT; } \
101 static __fi bool operator==( const enumName& left, const pxEnumEnd_t& ) { return (int)left == enumName##_COUNT; } \
102 \
103 static __fi bool EnumIsValid( enumName id ) { \
104 return ((int)id >= enumName##_FIRST) && ((int)id < enumName##_COUNT); } \
105 static __fi bool EnumAssert( enumName id ) { \
106 return pxAssert( EnumIsValid(id) ); } \
107 \
108 extern const wxChar* EnumToString( enumName id )
109
110 class pxEnumEnd_t { };
111 static const pxEnumEnd_t pxEnumEnd = {};
112
113 // --------------------------------------------------------------------------------------
114 // DeclareNoncopyableObject
115 // --------------------------------------------------------------------------------------
116 // This macro provides an easy and clean method for ensuring objects are not copyable.
117 // Simply add the macro to the head or tail of your class declaration, and attempts to
118 // copy the class will give you a moderately obtuse compiler error that will have you
119 // scratching your head for 20 minutes.
120 //
121 // (... but that's probably better than having a weird invalid object copy having you
122 // scratch your head for a day).
123 //
124 // Programmer's notes:
125 // * We intentionally do NOT provide implementations for these methods, which should
126 // never be referenced anyway.
127
128 // * I've opted for macro form over multi-inherited class form (Boost style), because
129 // the errors generated by the macro are considerably less voodoo. The Boost-style
130 // The macro reports the exact class that causes the copy failure, while Boost's class
131 // approach just reports an error in whatever "NoncopyableObject" is inherited.
132 //
133 // * This macro is the same as wxWidgets' DECLARE_NO_COPY_CLASS macro. This one is free
134 // of wx dependencies though, and has a nicer typeset. :)
135 //
136 #ifndef DeclareNoncopyableObject
137 # define DeclareNoncopyableObject(classname) \
138 private: \
139 explicit classname(const classname&); \
140 classname& operator=(const classname&)
141 #endif
142
143
144 // --------------------------------------------------------------------------------------
145 // ScopedBool - Makes sure a boolean is set back to FALSE when current scope is left
146 // --------------------------------------------------------------------------------------
147 // Exception-safe way of tracking entry and exit of various functions of execution zones.
148 //
149 class ScopedBool
150 {
151 protected:
152 bool* m_boolme;
153
154 public:
155 ScopedBool(bool& boolme)
156 {
157 boolme = true;
158 m_boolme = &boolme;
159 }
160
161 ~ScopedBool() throw()
162 {
163 *m_boolme = false;
164 }
165 };
166
167 #include <wx/string.h>
168 #include <wx/intl.h>
169 #include <wx/log.h>
170
171 #include <stdexcept>
172 #include <cstring> // string.h under c++
173 #include <cstdio> // stdio.h under c++
174 #include <cstdlib>
175 #include <vector>
176 #include <list>
177
178 #include "Pcsx2Defs.h"
179
180 static const sptr _64kb = 0x10000;
181 static const sptr _16kb = _64kb / 4;
182 static const sptr _128kb = _64kb * 2;
183 static const sptr _256kb = _128kb * 2;
184
185 static const s64 _1mb = 0x100000;
186 static const s64 _8mb = _1mb * 8;
187 static const s64 _16mb = _1mb * 16;
188 static const s64 _32mb = _1mb * 32;
189 static const s64 _64mb = _1mb * 64;
190 static const s64 _256mb = _1mb * 256;
191 static const s64 _1gb = _256mb * 4;
192 static const s64 _4gb = _1gb * 4;
193
194 // ===========================================================================================
195 // i18n/Translation Feature Set!
196 // ===========================================================================================
197
198 extern const wxChar* __fastcall pxExpandMsg( const wxChar* key, const wxChar* englishContent );
199 extern const wxChar* __fastcall pxGetTranslation( const wxChar* message );
200 extern bool pxIsEnglish( int id );
201
202 extern wxString fromUTF8( const char* src );
203 extern wxString fromAscii( const char* src );
204
205 // --------------------------------------------------------------------------------------
206 // wxLt(x) [macro]
207 // --------------------------------------------------------------------------------------
208 // macro provided for tagging translation strings, without actually running them through the
209 // translator (which the _() does automatically, and sometimes we don't want that). This is
210 // a shorthand replacement for wxTRANSLATE.
211 //
212 #ifndef wxLt
213 # define wxLt(a) wxT(a)
214 #endif
215
216 // --------------------------------------------------------------------------------------
217 // pxE(key, msg) and pxEt(key, msg) [macros]
218 // --------------------------------------------------------------------------------------
219 // Translation Feature: pxE is used as a method of dereferencing very long english text
220 // descriptions via a "key" identifier. In this way, the english text can be revised without
221 // it breaking existing translation bindings. Make sure to add pxE to your PO catalog's
222 // source code identifiers, and then reference the source code to see what the current
223 // english version is.
224 //
225 // Valid prefix types:
226 //
227 // !Panel: Key-based translation of a panel or dialog text; usually either a header or
228 // checkbox description, by may also include some controls with long labels.
229 // These have the highest translation priority.
230 //
231 // !Notice: Key-based translation of a popup dialog box; either a notice, confirmation,
232 // or error. These typically have very high translation priority (roughly equal
233 // or slightly less than pxE_Panel).
234 //
235 // !Tooltip: Key-based translation of a tooltip for a button on a tool bar. Since buttons are
236 // rarely self-explanatory, these translations are considered medium to high priority.
237 //
238 // !Wizard Key-based translation of a heading, checkbox item, description, or other text
239 // associated with the First-time wizard. Translation of these items is considered
240 // lower-priority to most other messages; but equal or higher priority to ContextTips.
241 //
242 // !ContextTip: Key-based translation of a tooltip for a control on a dialog/panel. Translation
243 // of these items is typically considered "lowest priority" as they usually provide
244 // only tertiary (extra) info to the user.
245 //
246
247 #define pxE(key, english) pxExpandMsg( wxT(key), english )
248
249 // For use with tertiary translations (low priority).
250 #define pxEt(key, english) pxExpandMsg( wxT(key), english )
251
252 #include "Utilities/Assertions.h"
253 #include "Utilities/Exceptions.h"
254 #include "Utilities/ScopedPtr.h"
255 #include "Utilities/ScopedAlloc.h"

  ViewVC Help
Powered by ViewVC 1.1.22