1-30 SOMobjects Base Toolkit: Programmer’s Reference Manual
somResolveByName Function
Purpose
Obtains a pointer to the procedure that implements a method for a particular SOM object.
Syntax
somMethodPtr somResolveByName (SOMObject obj, string methodName);
Description
The somResolveByName function is used to obtain a pointer to the procedure that
implements the specified method for the specified SOM object. The returned procedure
pointer can then be used to invoke the method. The C and C++ usage bindings use this
function to support name-lookup methods.
This function can be used for invoking dynamic methods. However, the C and C++ usage
bindings for SOM classes do not support dynamic methods, thus typedefs necessary for the
use of dynamic methods are not available as with static methods. The function somApply
provides an alternative mechanism for invoking dynamic methods that avoids the need for
casting procedure pointers.
Parameters
obj A pointer to the object whose method procedure is required.
methodName A character string representing the name of the method to be resolved.
Return Value
A somMethodPtr pointer to the procedure that implements the specified method for the
specified SOM object.
C Example
Assuming the static method “setSound,” is introduced by the class ”Animal”, the following
example will correctly invoke this method on an instance of ”Animal” or one of its
descendent classes.
#include <animal.h>
example(Animal myAnimal)
{
somTD_Animal_setSound
setSoundProc = somResolveByName(myAnimal, ”setSound”);
setSoundProc(myAnimal, ”Roar!”);
}
Related Information
Functions: somResolve, somParentResolve, somParentNumResolve,
somClassResolve
Data Structures: somMethodPtr (sombtype.h), SOMObject (somobj.idl),
string (somcorba.h)
Methods: somDispatch, somClassDispatch, somFindMethod, somFindMethodOk,
somGetApplyStub
Macros: SOM_Resolve, SOM_ResolveNoCheck
Kommentare zu diesen Handbüchern