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