Consider the following IDL description of the "Hello" class:
#include <somobj.idl> interface Hello : SOMObject { void sayHello(); // This method outputs the string "Hello, World!". };
From this IDL description, the SOM Compiler generates the following C implementation template, hello.c (a C++ implementation template, hello.C or hello.cpp, is identical except that the #included file is <hello.xih> rather than <hello.ih>):
#define Hello_Class_Source #include <hello.ih> /* * This method outputs the string "Hello, World!". */ SOM_Scope void SOMLINK sayHello(Hello somSelf, Environment *ev) { /* HelloData *somThis = HelloGetData(somSelf); */ HelloMethodDebug("Hello","sayHello"); }
The first line defines the "Hello_Class_Source" symbol, which is used in the SOM-generated implementation header files for C to determine when to define various functions, such as "HelloNewClass." For interfaces defined within a module, the directive "#define <className>_Class_Source" is replaced by the directive "#define SOM_Module_<moduleName>_Source".
The second line (#include <hello.ih> for C, or #include <hello.xih> for C++) includes the SOM-generated implementation header file. This file defines a struct holding the class's instance variables, macros for accessing instance variables, macros for invoking parent methods, and so forth.