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