somGetClass

From EDM2
Jump to: navigation, search

This method returns a pointer to an object's class object. Not generally overridden.

Original Class 
SOMObject

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

Syntax

SOMClass somGetClass (SOMObject receiver)

Parameters

receiver (SOMObject) 
A pointer to the object whose class is desired.

Return Code

rc (SOMClass) 
A pointer to the object's class object. This return value is cast as a (SOMClass*). In C++, you may have to explicitly cast this to a pointer of a specific class type (when different from SOMClass).

Remarks

somGetClass obtains a pointer to the receiver's class object. The somGetClass method is typically not overridden.

Important Note: For C and C++ programmers, SOM provides a SOM_GetClass macro that performs the same function. This macro should only be used only when absolutely necessary (i.e., when a method call on the object is not possible), since it bypasses whatever semantics may be intended for the somGetClass method by the implementor of the receiver's class. Even class implementors do not know whether a special semantics for this method is inherited from ancestor classes. If you are unsure of whether the method or the macro is appropriate, you should use the method call.

Example Code

#include <animal.h>
main()
{
  Animal myAnimal;
  int numMethods;
  SOMClass animalClass;

  myAnimal = AnimalNew ();
  animalClass = _somGetClass (myAnimal);
  SOM_Test(animalClass == _Animal);
}

Related

Macros