Jump to content

SomLookupmethod

From EDM2
Revision as of 18:02, 13 October 2017 by Martini (talk | contribs) (Created page with "{{DISPLAYTITLE:somLookupMethod}} Performs name-look method resolution. Not generally overridden. For backward compatibility, this method does not take an Environment paramete...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Performs name-look method resolution. Not generally overridden.

For backward compatibility, this method does not take an Environment parameter.

Original Class
SOMClass

Syntax

somMethodPtr somLookupMethod (SOMClass receiver,
somId methodId)

Parameters

receiver (SOMClass)
A pointer to the class whose instance method for the indicated method is desired.
methodId (somId)
A somId of the method whose method-procedure pointer is needed.

Return Code

rc (somMethodPtr)
A pointer to the method procedure that supports the method indicated by methodId. Or, if the method is not supported by the receiving class, then an error is returned, and execution is halted.

Remarks

The somLookupMethod method uses name-lookup resolution to return the address of the method procedure that supports the indicated method on instances of the receiver class. The method may be either static or dynamic. The SOM C and C++ usage bindings support name-lookup method resolution by invoking somLookupMethod on the class of the object on which a name-lookup method invocation is made.

The somLookupMethod method is like somFindSMethodOK except that dynamic methods can also be returned. If the method is not supported by the receiving class, then an error is returned and execution is halted. To check the existence of a method, somFindMethod can be used.

As always, in order to use a method procedure pointer such as that returned by somLookupMethod, it is necessary to typecast the procedure pointer so that the compiler can create the correct procedure call. This means that a programmer making explicit use of this method must either know the signature of the identified method, and from this create a typedef indicating system linkage and the appropriate argument and return types, or make use of an existing typedef provided by C or C++ usage bindings for a SOM class that introduces a static method with the desired signature.

Example Code

#include <somcls.xh>
#include <somcm.xh>
void main()
{
   somId fcpId = somIdFromString("somFindClass")
   somId animalId = somIdFromString("Animal");
   SOMClassMgr *cm = somEnvironmentNew();
   somTD_SOMClassMgr_somFindClass findclassproc =
         (somTD_SOMClassMgr_somFindClass)
             _SOMClassMgr->somLookupMethod(fcpId);
   SOMClass *aCls = findclassproc(cm,animalId,0,0);
   ...
   somFree(fcpId);
   somFree(animalId);
}

Related

Methods