~ubuntu-branches/ubuntu/trusty/gnustep-base/trusty

« back to all changes in this revision

Viewing changes to Headers/GNUstepBase/NSObject+GNUstepBase.h

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung
  • Date: 2012-11-21 13:56:22 UTC
  • mfrom: (8.1.5 experimental)
  • Revision ID: package-import@ubuntu.com-20121121135622-1w035dpxneardw8q
Tags: 1.24.0-1ubuntu1
Backport upstream fix for recent libxml2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
96
96
 
97
97
@end
98
98
 
 
99
/** This is an informal protocol ... classes may implement the method and
 
100
 * register themselves to have it called on process exit.
 
101
 */
 
102
@interface NSObject(GSAtExit)
 
103
/** This method is called on exit for any class which implements it and which
 
104
 * has called +registerAtExit to register it to be called.<br />
 
105
 * The order in which methods for different classes is called is the reverse
 
106
 * of the order in which the classes were registered, but it's best to assume
 
107
 * the method can not depend on any other class being in a usable state
 
108
 * at the point when the method is called (rather like +load).<br />
 
109
 * Typical use would be to release memory occupied by class data structures
 
110
 * so that memory usage analysis software will not think the memory has
 
111
 * been leaked.
 
112
 */
 
113
+ (void) atExit;
 
114
@end
 
115
 
 
116
/** Category for methods handling leaked memory cleanup on exit of process
 
117
 * (for use when debugging memory leaks).<br />
 
118
 * You enable this by calling the +setShouldCleanUp: method (done implicitly
 
119
 * by gnustep-base if the GNUSTEP_SHOULD_CLEAN_UP environment variable is
 
120
 * set to YES).<br />
 
121
 * Your class then has two options for performing cleanup when the process
 
122
 * ends:
 
123
 * <p>1. Use the +leak: method to register objects which are simply to be 
 
124
 * retained until the process ends, and then either ignored or released
 
125
 * depending on the cleanup setting in force.  This mechanism is simple
 
126
 * and should be sufficient for many classes.
 
127
 * </p>
 
128
 * <p>2. Implement a +atExit method to be run when the process ends and,
 
129
 * within your +initialize implementation, call +shouldCleanUp to determine
 
130
 * whether cleanup should be done, and if it returns YES then call
 
131
 * +registerAtExit to have your +atExit method called when the process
 
132
 * terminates.
 
133
 * </p>
 
134
 * <p>The order in which 'leaked' objects are released and +atExit methods
 
135
 * are called on process exist is the reverse of the order in which they
 
136
 * werse set up suing this API.
 
137
 * </p>
 
138
 */
 
139
@interface NSObject(GSCleanup)
 
140
 
 
141
 
 
142
/** This method simply retains its argument so that it will never be
 
143
 * deallocated during normal operation, but keeps track of it so that
 
144
 * it is released during process exit if cleanup is enabled.<br />
 
145
 * Returns its argument.
 
146
 */
 
147
+ (id) leak: (id)anObject;
 
148
 
 
149
/** This method retains the object at *anAddress so that it will never be
 
150
 * deallocated during normal operation, but keeps track of the address
 
151
 * so that the object is released and the address is zeroed during process
 
152
 * exit if cleanup is enabled.<br />
 
153
 * Returns the object at *anAddress.
 
154
 */
 
155
+ (id) leakAt: (id*)anAddress;
 
156
 
 
157
/** Sets the receiver to have its +atExit method called at the point when
 
158
 * the process terminates.<br />
 
159
 * Returns YES on success and NO on failure (if the class does not implement
 
160
 * the method or if it is already registered to call it).<br />
 
161
 * Implemented as a call to +registerAtExit: with the selector for the +atExit
 
162
 * method as its argument.
 
163
 */
 
164
+ (BOOL) registerAtExit;
 
165
 
 
166
/** Sets the receiver to have the specified  method called at the point when
 
167
 * the process terminates.<br />
 
168
 * Returns YES on success and NO on failure (if the class does not implement
 
169
 * the method ir if it is already registered to call it).
 
170
 */
 
171
+ (BOOL) registerAtExit: (SEL)aSelector;
 
172
 
 
173
/** Specifies the default cleanup behavior on process exit ... the value
 
174
 * returned by the NSObject implementation of the +shouldClanUp method.<br />
 
175
 * Calling this method with a YES argument implicitly calls the +enableAtExit
 
176
 * method as well.<br />
 
177
 * The GNUstep Base library calls this method with the value obtained from
 
178
 * the GNUSTEP_SHOULD_CLEAN_UP environment variable when NSObject is
 
179
 * initialised.
 
180
 */
 
181
+ (void) setShouldCleanUp: (BOOL)aFlag;
 
182
 
 
183
/** Returns a flag indicating whether the receiver should clean up
 
184
 * its data structures etc at process exit.<br />
 
185
 * The NSObject implementation returns the value set by the +setShouldCleanUp:
 
186
 * method but subclasses may override this.
 
187
 */
 
188
+ (BOOL) shouldCleanUp;
 
189
 
 
190
@end
 
191
 
99
192
#endif  /* OS_API_VERSION */
100
193
 
101
194
#if     defined(__cplusplus)