To get the class that an object is an instance of, SOM provides a method
called somGetClass. The somGetClass method takes an object
as its only argument and returns a pointer to the class object of which
it is an instance. For example, the following statements store in "myClass"
the class object of which "obj" is an instance. myClass = _somGetClass(obj);
(for C)
myClass = obj->somGetClass(); (for C++)
Getting the class of an object is useful for obtaining information about the object; in some cases, such information cannot be obtained directly from the object, but only from its class. The section below entitled "Getting information about a class" describes the methods that can be invoked on a class object after it is obtained using somGetClass.
The somGetClass method can be overridden by a class to provide enhanced or alternative semantics for its objects. Because it is usually important to respect the intended semantics of a class of objects, the somGetClass method should normally be used to access the class of an object.
In a few special cases, it is not possible to make a method call on an object in order to determine its class. For such situations, SOM provides the SOM_GetClass macro. In general, the somGetClass method and the SOM_GetClass macro may have different behavior (if somGetClass has been overridden). This difference may be limited to side effects, but it is possible for their results to differ as well. The SOM_GetClass macro should only be used when absolutely necessary.