1-154 SOMobjects Base Toolkit: Programmer’s Reference Manual
somRespondsTo Method
Purpose
Tests whether the receiving object supports a given method. Not generally overridden.
IDL Syntax
boolean somRespondsTo (in somId methodId);
Note: For backward compatibility, this method does not take an Environment parameter.
Description
The somRespondsTo method tests whether a specific (static or dynamic) method can be
invoked on the receiver object. This test is equivalent to determining whether the class of
the receiver supports the specified method on its instances.
Parameters
receiver A pointer to the object to be tested.
methodId A somId that represents the name of the desired method.
Return Value
The somRespondsTo method returns TRUE if the specified method can be invoked on the
receiving object, and FALSE otherwise.
C Example
/* -----------------------------------------------
: Animal supports a setSound method;
Animal does not support a doTrick method.
----------------------------------------------- */
#include <animal.h>
main()
{
Animal myAnimal;
char *methodName1 = ”setSound”;
char *methodName2 = ”doTrick”;
myAnimal = AnimalNew();
if (_somRespondsTo(myAnimal, SOM_IdFromString(methodName1)))
somPrintf(”myAnimal responds to %s\n”, methodName1);
if (_somRespondsTo(myAnimal, SOM_IdFromString(methodName2)))
somPrintf(”myAnimal responds to %s\n”, methodName2);
_somFree(myAnimal);
}
/*
Output from this program:
myAnimal responds to setSound
*/
Original Class
SOMObject
Related Information
Methods: somSupportsMethod
Comentários a estes Manuais