somFindClass
This method finds the class object for a class.
For backward compatibility, this method does not take an Environment parameter.
- Original Class
- SOMClassMgr
Syntax
SOMClass somFindClass (SOMClassMgr receiver, somId classId, long majorVersion, long minorVersion)
Parameters
- receiver (SOMClassMgr)
- Usually SOMClassMgrObject (or a pointer to an instance of a user-supplied subclass of SOMClassMgr).
- classId (somId)
- The somId representing the name of the class.
- majorVersion (long)
- The class's major version number.
- minorVersion (long)
- The class's minor version number.
Return Code
- rc (SOMClass)
- A pointer to the requested class object, or NULL if the class could not be found or created.
Remarks
The somFindClass method returns the class object for the specified class. This method first uses somLocateClassFile (see paragraph below) to obtain the name of the file where the class's code resides, then uses somFindClsInFile.
If the requested class has not yet been created, the somFindClass method attempts to load the class dynamically by loading its dynamically linked library and invoking its "new class" procedure.
The somLocateClassFile method uses the following steps:
- If the entry in the Interface Repository for the class specified by classId contains a dllname modifier, this value is used as the file name for loading the library. (For information about the dllname modifier, refer to the topic "Modifier statements" in Chapter 4, "SOM IDL and the SOM Compiler," of the SOM Programming Guide.
- In the absence of a dllname modifier, the class name is assumed to be the file name for the library. Use the somFindClsInFile method if you wish to explicitly pass the file name as an argument.
If majorVersion and minorVersion are not both zero, they are used to check the class version information against the caller's expectations. An implementation is compatible with the specified version numbers if it has the same major version number and a minor version number that is equal to or greater than minorVersion.
Example Code
#include <som.h> /* * This program creates a class object * (from a DLL) without requiring the * usage binding file (.h or .xh) for * the class. */ void main () { SOMClass myClass; somId animalId; somEnvironmentNew (); animalId = somIdFromString ("Animal"); /* The next statement is equivalent to: * #include "animal.h" * myClass = AnimalNewClass (0, 0); */ myClass = SOMClassMgr_somFindClass (SOMClassMgrObject, animalId, 0, 0); if (myClass) somPrintf ("myClass: %s\n", SOMClass_somGetName (myClass)); else somPrintf ("Class %s could not be dynamically loaded\n", somStringFromId (animalId)); SOMFree (animalId); }