In addition to macros for accessing instance variables, the implementation header file that the SOM Compiler generates also contains definitions of macros for making "parent method calls." When a class overrides a method defined by one or more of its parent classes, often the new implementation simply needs to augment the functionality of the existing implementation(s). Rather than completely re-implementing the method, the overriding method procedure can conveniently invoke the procedure that one or more of the parent classes uses to implement that method, then perform additional computation (redefinition) as needed. The parent method call can occur anywhere within the overriding method. (See Example 3 of the SOM IDL tutorial.)
The SOM-generated implementation header file defines the following macros for making parent-method calls from within an overriding method:
<className>_parent_<parentClassName>_<methodName>
(for each parent class of the class overriding
the method), and
<className>_parents_<methodName>.
For example, given class "Hello" with parents "File" and "Printer" and overriding method somInit (the SOM method that initializes each object), the SOM Compiler defines the following macros in the implementation header file for "Hello":
Hello_parent_Printer_somInit Hello_parent_File_somInit Hello_parents_somInit
Each macro takes the same number and type of arguments as <methodName>. The <className>_parent_<parentClassName>_<methodName> macro invokes the implementation of <methodName> inherited from <parentClassName>. Hence, using the macro "Hello_parent_File_somInit" invokes the File's implementation of somInit.
The <className>_parents_< methodName> macro invokes the parent method for each parent of the child class that supports <methodName>. That is, "Hello_parents_somInit" would invoke File's implementation of somInit, followed by Printer's implementation of somInit. The <className>_parents_<methodName> macro is redefined in the binding file each time the class interface is modified, so that if a parent class is added or removed from the class definition, or if <methodName> is added to one of the existing parents, the macro <className>_parents_<methodName > will be redefined appropriately.