somDestruct - Remarks

Every class must support the somDestruct method. This is accomplished either by overriding somDestruct (in which case a specialized stub procedure will be generated in the implementation template file), or else SOMobjects will automatically provide a generic procedure that implements somDestruct for the class. The generic procedure calls somUninit (if this was overridden) to perform local uninitialization, then completes execution of the method appropriately.

Because the specialized stub procedure generated by the template emitter is more efficient than the generic procedure provided when somDestruct is not overridden, it is recommended that somDestruct always be overridden. The stub procedure that is generated in this case requires no modification for correct operation. The only modification appropriate within this stub procedure is to uninitialize locally introduced instance variables. See Section 5.5, "Initializing and Unitializing Objects," of the SOMobjects Developer Toolkit Users Guide for further details.

Uninitialization with somDestruct executes as follows: For any given class in the ancestor chain, somDestruct first uninitializes that class's introduced instance variables (if this is appropriate), and then calls the next ancestor class's implementation of somDestruct, passing 0 (that is, false) as the interim dofree argument. Then, after all ancestors of the given class have been uninitialized, if the class's own somDestruct method were originally invoked with dofree as 1 (that is, true), then that object's storage is released.

Note: It is not appropriate to override both somDestruct and somUninit. If this is done, the somUninit code will not be executed. The best way to convert an old class that overrides somUninit to use of the more efficient somDestruct (if this is desired) is as follows: (1) Replace the somUninit override in the class's .idl file with an override for somDestruct, (2) run the emitter to produce a stub procedure for somDestruct in the implementation template file, and then (3) simply call the class's somUninit procedure directly (not using a method invocation) from the somDestruct procedure.


[Back: somDestruct - Parameters]
[Next: somDestruct - Original Class]