1-112 SOMobjects Base Toolkit: Programmer’s Reference Manual
somGetInitFunction Method
Purpose
Obtains the name of the function that initializes the SOM classes in a class library.
IDL Syntax
string somGetInitFunction ( );
Note: For backward compatibility, this method does not take an Environment parameter.
Description
The somGetInitFunction method supplies the name of the initialization function for OS/2
class libraries (DLLs) that contain more than one SOM class. The default implementation
returns the value of the global variable SOMClassInitFuncName, which by default is set to
the value “SOMInitModule”.
For AIX, the name of the class initialization function is not important, since AIX class
libraries should always be constructed as shared libraries with a designated entry point
which can be executed automatically by the loader when the class is loaded. Consequently,
the result of this method is not significant on AIX.
Similarly, if an OS/2 class library (DLL) has been constructed with a DLL initialization
function assigned by the linker, you can choose to invoke the <className>NewClass
functions for all of the classes in the DLL during DLL initialization. In this case (as on AIX),
there is no need to export a “SOMInitModule” function. On the other hand, if your compiler
does not provide a convenient mechanism for creating a DLL initialization function, you can
elect to export a function named “SOMInitModule” (or whatever name is ultimately returned
by the somGetInitFunction method).
The OS/2 SOMClassMgrObject, after loading a class library, will invoke the method
somGetInitFunction to obtain the name of a possible initialization function. If this name has
been exported by the class library just loaded, the SOMClassMgrObject calls this function
to initialize the classes in the library. If the name has not been exported by the DLL, the
SOMClassMgrObject then looks for an exported name of the form
<className>NewClass, where <className> is the name of the class supplied with the
method that caused the DLL to be loaded. If the DLL exports this name, it is invoked to
create the named class.
On Windows, the SOM class manager does not call SOMInitModule. It must be called
from the default Windows DLL initialization function, LibMain. This call is made indirectly
through the SOM_ClassLibrary macro.
Regardless of the technique employed, the SOMClassMgrObject expects that all classes
packaged in a single class library will be created during this sequence.
This method is generally not invoked directly by users. User-defined subclasses of
SOMClassMgr, however, can override this method.
Parameters
receiver Usually SOMClassMgrObject (or a pointer to an instance of a
user-supplied subclass of SOMClassMgr).
Return Value
The somGetInitFunction method returns a string that names the initialization function of
class libraries. By default, this name is the value of the global variable
SOMClassInitFuncName, the default value of which is SOMInitModule.
Komentarze do niniejszej Instrukcji