Metaclass Framework Reference 4-5
sommBeforeMethod Method
Purpose
Specifies a method that is automatically called before execution of each client method.
IDL Syntax
boolean sommBeforeMethod (
in SOMObject object,
in somId methodID,
in va_list ap);
Description
The sommBeforeMethod specifies a method that is automatically called before execution
of each client method. The sommBeforeMethod method is not called directly by the user.
To define the desired “before” method, sommBeforeMethod must be overridden in a
metaclass that is a subclass (child) of SOMMBeforeAfter. The default implementation does
nothing until it is overridden.
Warning: somDefaultInit is among the methods that get before/after behavior, which
implies that the following obligation is imposed on the programmer of a
sommBeforeMethod. Specifically, care must be taken to guard against
sommBeforeMethod being called before the somDefaultInit method has executed and the
object is not yet fully initialized.
Parameters
Refer to the diagram in the following section for further clarification of these arguments.
receiver A pointer to an object (class) of metaclass SOMMBeforeAfter representing
the class object that supports the method (such as, “myMethod”) for which
the “before” method will apply.
ev A pointer where the method can return exception information if an error is
encountered. The dispatch method of SOMMBeforeAfter sets this
parameter to NULL before dispatching the first sommBeforeMethod.
object A pointer to the instance of the receiver on which the method is invoked.
methodId The SOM ID of the method (such as, “myMethod”) that was invoked.
ap The list of input arguments to the method (“myMethod”).
Return Value
A boolean that indicates whether or not before/after dispatching should continue. If the
value is TRUE, normal before/after dispatching continues. If the value is FALSE, the
dispatching skips to the sommAfterMethod associated with the preceding
sommBeforeMethod. This implies that the sommBeforeMethod must do any
post-processing that might otherwise be done by the sommAfterMethod. Because
before/after methods are paired within a SOMMBeforeAfter metaclass, this design
eliminates the complexity of communicating to the sommAfterMethod that the
sommBeforeMethod returned FALSE.
Komentarze do niniejszej Instrukcji