SOM_Resolve
This macro obtains a pointer to a method procedure.
- Note
- For backward compatibility, this method does not take an Environment parameter.
Contents
Syntax
SOMObject objPtr; <token> className; <token> methodName; RC somMethod; somMethod = SOM_Resolve(objPtr, className, methodName);
Parameters
- objPtr (SOMObject)
- A pointer to the object to which the resolved method procedure will be applied.
- className (<token>)
- The name of the class that introduces methodName. This name should be given as a simple token, rather than a quoted string (for example, Animal rather than "Animal").
- methodName (<token>)
- The name of the method to be resolved. This name should be given as a simple token, rather than a quoted string (for example, setSound rather than "setSound").
Return Code
- somMethod
- (RC)
Remarks
The SOM_Resolve macro invokes the somResolve function to obtain a pointer to the static method procedure that implements the specified method for the specified object. This pointer can be used for efficient repeated casted method invocations on instances of the class of the object on which the resolution is done, or instances of subclasses of this class. The name of the class that introduces the method and the name of the method must be known to use this macro. Otherwise, use the somResolveByName, somFindMethod or somFindMethodOk method.
The SOM_Resolve macro can only be used to obtain a method procedure for a static method (one defined in the IDL specification for a class); not a dynamic method. Unlike the SOM_ResolveNoCheck macro, the SOM_Resolve macro performs several consistency checks on the object pointed to by objPtr.
Expansion
The SOM_Resolve macro uses the className and methodName to construct the method token for the specified method, then invokes the somResolve function. Thus, the macro expands to an expression that represents the entry-point address of the method procedure. This value can be stored in a variable and used for subsequent invocations of the method.
Example Code
Animal myObj = AnimalNew(); somMethodProc *procPtr; procPtr = SOM_Resolve(myObj, Animal, setSound); /* note that procPtr will need to be typecast when it is used */
Related
Macros
- SOM_ResolveNoCheck
Functions
- somResolve
- somClassResolve
- somResolveByName
Methods
- somFindMethod
- somFindMethodOk
- somDispatch
- somClassDispatch