]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/memory.h
automated ifacecheck fixes
[wxWidgets.git] / interface / wx / memory.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: memory.h
ba1d7a6c 3// Purpose: interface of wxDebugContext
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
e54c96f1 9
23324ae1
FM
10/**
11 @class wxDebugContext
7c913512 12
ba1d7a6c
FM
13 A class for performing various debugging and memory tracing operations.
14
15 Full functionality (such as printing out objects currently allocated) is
16 only present in a debugging build of wxWidgets, i.e. if the __WXDEBUG__
17 symbol is defined. wxDebugContext and related functions and macros can be
18 compiled out by setting wxUSE_DEBUG_CONTEXT to 0 is setup.h
7c913512 19
23324ae1
FM
20 @library{wxbase}
21 @category{debugging}
7c913512 22
ba1d7a6c 23 @see @ref overview_debugging
23324ae1 24*/
7c913512 25class wxDebugContext
23324ae1
FM
26{
27public:
28 /**
29 Checks the memory blocks for errors, starting from the currently set
30 checkpoint.
3c4f71cc 31
d29a9a8a 32 @return Returns the number of errors, so a value of zero represents
ba1d7a6c
FM
33 success. Returns -1 if an error was detected that prevents
34 further checking.
23324ae1 35 */
43c48e1e 36 static int Check(bool checkAll = false);
23324ae1
FM
37
38 /**
39 Performs a memory dump from the currently set checkpoint, writing to the
40 current debug stream. Calls the @b Dump member function for each wxObject
41 derived instance.
3c4f71cc 42
d29a9a8a 43 @return @true if the function succeeded, @false otherwise.
23324ae1 44 */
da1ed74c 45 static bool Dump();
23324ae1
FM
46
47 /**
48 Returns @true if the memory allocator checks all previous memory blocks for
49 errors.
ba1d7a6c 50
23324ae1 51 By default, this is @false since it slows down execution considerably.
3c4f71cc 52
4cc4bfaf 53 @see SetCheckPrevious()
23324ae1 54 */
da1ed74c 55 static bool GetCheckPrevious();
23324ae1
FM
56
57 /**
ba1d7a6c
FM
58 Returns @true if debug mode is on.
59
60 If debug mode is on, the wxObject new and delete operators store or use
61 information about memory allocation. Otherwise, a straight malloc and
62 free will be performed by these operators.
3c4f71cc 63
4cc4bfaf 64 @see SetDebugMode()
23324ae1 65 */
da1ed74c 66 static bool GetDebugMode();
23324ae1
FM
67
68 /**
ba1d7a6c
FM
69 Gets the debug level (default 1).
70
71 The debug level is used by the wxTraceLevel function and the WXTRACELEVEL
72 macro to specify how detailed the trace information is; setting a
73 different level will only have an effect if trace statements in the
74 application specify a value other than one.
75
76 @deprecated
23324ae1 77 This is obsolete, replaced by wxLog functionality.
3c4f71cc 78
4cc4bfaf 79 @see SetLevel()
23324ae1 80 */
da1ed74c 81 static int GetLevel();
23324ae1
FM
82
83 /**
84 Returns the output stream associated with the debug context.
ba1d7a6c
FM
85
86 @deprecated
23324ae1 87 This is obsolete, replaced by wxLog functionality.
3c4f71cc 88
4cc4bfaf 89 @see SetStream()
23324ae1
FM
90 */
91 ostream GetStream();
92
93 /**
94 Returns a pointer to the output stream buffer associated with the debug context.
95 There may not necessarily be a stream buffer if the stream has been set
96 by the user.
ba1d7a6c
FM
97
98 @deprecated
23324ae1
FM
99 This is obsolete, replaced by wxLog functionality.
100 */
101 streambuf* GetStreamBuf();
102
103 /**
104 Returns @true if there is a stream currently associated
105 with the debug context.
ba1d7a6c
FM
106
107 @deprecated
23324ae1 108 This is obsolete, replaced by wxLog functionality.
3c4f71cc 109
4cc4bfaf 110 @see SetStream(), GetStream()
23324ae1
FM
111 */
112 bool HasStream();
113
114 /**
115 Prints a list of the classes declared in this application, giving derivation
116 and whether instances of this class can be dynamically created.
3c4f71cc 117
4cc4bfaf 118 @see PrintStatistics()
23324ae1 119 */
da1ed74c 120 static bool PrintClasses();
23324ae1
FM
121
122 /**
123 Performs a statistics analysis from the currently set checkpoint, writing
124 to the current debug stream. The number of object and non-object
125 allocations is printed, together with the total size.
3c4f71cc 126
7c913512 127 @param detailed
ba1d7a6c
FM
128 If @true, the function will also print how many objects of each class
129 have been allocated, and the space taken by these class instances.
3c4f71cc 130
4cc4bfaf 131 @see PrintStatistics()
23324ae1 132 */
da1ed74c 133 static bool PrintStatistics(bool detailed = true);
23324ae1
FM
134
135 /**
136 Tells the memory allocator to check all previous memory blocks for errors.
137 By default, this is @false since it slows down execution considerably.
3c4f71cc 138
4cc4bfaf 139 @see GetCheckPrevious()
23324ae1 140 */
da1ed74c 141 static void SetCheckPrevious(bool check);
23324ae1
FM
142
143 /**
144 Sets the current checkpoint: Dump and PrintStatistics operations will
145 be performed from this point on. This allows you to ignore allocations
146 that have been performed up to this point.
3c4f71cc 147
7c913512 148 @param all
ba1d7a6c
FM
149 If @true, the checkpoint is reset to include all memory allocations
150 since the program started.
23324ae1 151 */
da1ed74c 152 static void SetCheckpoint(bool all = false);
23324ae1
FM
153
154 /**
ba1d7a6c
FM
155 Sets the debug mode on or off.
156
157 If debug mode is on, the wxObject new and delete operators store or use
158 information about memory allocation. Otherwise, a straight malloc and free
159 will be performed by these operators.
160
23324ae1
FM
161 By default, debug mode is on if __WXDEBUG__ is defined. If the application
162 uses this function, it should make sure that all object memory allocated
ba1d7a6c
FM
163 is deallocated with the same value of debug mode. Otherwise, the delete
164 operator might try to look for memory information that does not exist.
3c4f71cc 165
4cc4bfaf 166 @see GetDebugMode()
23324ae1 167 */
da1ed74c 168 static void SetDebugMode(bool debug);
23324ae1
FM
169
170 /**
ba1d7a6c
FM
171 Sets the current debug file and creates a stream.
172 This will delete any existing stream and stream buffer.
173
174 By default, the debug context stream outputs to the debugger (Windows)
175 or standard error (other platforms).
23324ae1
FM
176 */
177 bool SetFile(const wxString& filename);
178
179 /**
ba1d7a6c
FM
180 Sets the debug level (default 1).
181
182 The debug level is used by the wxTraceLevel function and the WXTRACELEVEL
183 macro to specify how detailed the trace information is; setting
23324ae1 184 a different level will only have an effect if trace statements in the
ba1d7a6c
FM
185 application specify a value other than one.
186
187 @deprecated
23324ae1 188 This is obsolete, replaced by wxLog functionality.
3c4f71cc 189
4cc4bfaf 190 @see GetLevel()
23324ae1 191 */
da1ed74c 192 static void SetLevel(int level);
23324ae1
FM
193
194 /**
ba1d7a6c
FM
195 Installs a function to be called at the end of wxWidgets shutdown.
196 It will be called after all files with global instances of
197 wxDebugContextDumpDelayCounter have run their destructors.
198
23324ae1
FM
199 The shutdown function must be take no parameters and return nothing.
200 */
da1ed74c 201 static void SetShutdownNotifyFunction(wxShutdownNotifyFunction func);
23324ae1
FM
202
203 /**
204 Sets the debugging stream to be the debugger (Windows) or standard error (other
205 platforms).
ba1d7a6c 206
23324ae1 207 This is the default setting. The existing stream will be flushed and deleted.
ba1d7a6c
FM
208
209 @deprecated
23324ae1
FM
210 This is obsolete, replaced by wxLog functionality.
211 */
212 bool SetStandardError();
213
214 /**
215 Sets the stream and optionally, stream buffer associated with the debug context.
ba1d7a6c
FM
216 This operation flushes and deletes the existing stream (and stream buffer if any).
217
218 @deprecated
23324ae1 219 This is obsolete, replaced by wxLog functionality.
3c4f71cc 220
7c913512 221 @param stream
4cc4bfaf 222 Stream to associate with the debug context. Do not set this to @NULL.
7c913512 223 @param streamBuf
4cc4bfaf 224 Stream buffer to associate with the debug context.
23324ae1 225 */
4cc4bfaf 226 void SetStream(ostream* stream, streambuf* streamBuf = NULL);
23324ae1
FM
227};
228
229
e54c96f1 230
23324ae1
FM
231// ============================================================================
232// Global functions/macros
233// ============================================================================
234
ef477678
BP
235/** @ingroup group_funcmacro_log */
236//@{
237
23324ae1 238/**
ef477678
BP
239 @deprecated Use one of the wxLogTrace() functions or one of the
240 wxVLogTrace() functions instead.
241
242 Calls wxTrace() with printf-style variable argument syntax. Output is
243 directed to the current output stream (see wxDebugContext).
244
245 @header{wx/memory.h}
23324ae1 246*/
ef477678 247#define WXTRACE(format, ...)
23324ae1
FM
248
249/**
ef477678
BP
250 @deprecated Use one of the wxLogTrace() functions or one of the
251 wxVLogTrace() functions instead.
252
253 Calls wxTraceLevel with printf-style variable argument syntax. Output is
254 directed to the current output stream (see wxDebugContext). The first
255 argument should be the level at which this information is appropriate. It
256 will only be output if the level returned by wxDebugContext::GetLevel is
257 equal to or greater than this value.
258
259 @header{wx/memory.h}
23324ae1 260*/
ef477678 261#define WXTRACELEVEL(level, format, ...)
23324ae1
FM
262
263/**
ef477678
BP
264 @deprecated Use one of the wxLogTrace() functions or one of the
265 wxVLogTrace() functions instead.
266
267 Takes printf-style variable argument syntax. Output is directed to the
268 current output stream (see wxDebugContext).
269
270 @header{wx/memory.h}
23324ae1 271*/
ef477678
BP
272void wxTrace(const wxString& format, ...);
273
274/**
275 @deprecated Use one of the wxLogTrace() functions or one of the
276 wxVLogTrace() functions instead.
277
278 Takes @e printf() style variable argument syntax. Output is directed to the
279 current output stream (see wxDebugContext). The first argument should be
280 the level at which this information is appropriate. It will only be output
281 if the level returned by wxDebugContext::GetLevel() is equal to or greater
282 than this value.
283
284 @header{wx/memory.h}
285*/
286void wxTraceLevel(int level, const wxString& format, ...);
287
288//@}
23324ae1 289