Jump to content

SomFindClsInFile: Difference between revisions

From EDM2
Created page with "{{DISPLAYTITLE:somFindClsInFile}} This method finds a class object for a class. For backward compatibility, this method does not take an Environment parameter. ; Original Cl..."
 
Ak120 (talk | contribs)
mNo edit summary
 
Line 4: Line 4:
For backward compatibility, this method does not take an Environment parameter.
For backward compatibility, this method does not take an Environment parameter.


; Original Class : [[SOMClassMgr]]
;Original Class : [[SOMClassMgr]]


==Syntax==
==Syntax==
<PRE>
SOMClass somFindClsInFile (SOMClassMgr receiver, somId classId,
SOMClass somFindClsInFile (SOMClassMgr receiver, somId classId,
                            long majorVersion, long minorVersion, string file)
long majorVersion, long minorVersion,
string file)
</PRE>


==Parameters==
==Parameters==
; receiver (SOMClassMgr) : Usually SOMClassMgrObject (or a pointer to an instance of a user-supplied subclass of SOMClassMgr).  
;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.
; 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.
; majorVersion (long) : The class's major version number.  
;file (string) : A string representing the filename to be used if dynamic loading is required.
 
; minorVersion (long) : The class's minor version number.  
 
; file (string) : A string representing the filename to be used if dynamic loading is required.


==Return Code==
==Return Code==
; rc (SOMClass) : A pointer to the requested class object, or NULL if the class could not be found or created.
;rc (SOMClass) : A pointer to the requested class object, or NULL if the class could not be found or created.


==Remarks==
==Remarks==
Line 71: Line 64:


==Related==
==Related==
===Methods===
;Methods
* [[somFindClass]]
* [[somFindClass]]


[[Category:SOMClassMgr]]
[[Category:SOMClassMgr]]

Latest revision as of 18:15, 12 October 2022

This method finds a class object for a class.

For backward compatibility, this method does not take an Environment parameter.

Original Class
SOMClassMgr

Syntax

SOMClass somFindClsInFile (SOMClassMgr receiver, somId classId,
                           long majorVersion, long minorVersion, string file)

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.
file (string)
A string representing the filename to be used if dynamic loading is required.

Return Code

rc (SOMClass)
A pointer to the requested class object, or NULL if the class could not be found or created.

Remarks

The somFindClsInFile method returns the class object for the specified class. This method is the same as somFindClass except that the caller provides the filename to be used if dynamic loading is needed.

If the requested class has not yet been created the somFindClsInFile method attempts to load the class dynamically by loading the specified library and invoking its "new class" procedure.

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 loads a class and creates    */
 /*  an instance of it without requiring the   */
 /*  binding (.h) file for the class.          */
 /*                                            */
void main()
{
   SOMObject myAnimal;
   SOMClass animalClass;
   char *animalName = "Animal";

        /*
         * Filenames will be different for AIX and OS/2
         * Set animalfile to "C:\\MYDLLS\\ANIMAL.DLL" for OS/2.
         * Set animalfile to "/mydlls/animal.dll" for AIX.
         */

   char *animalFile = "/mydlls/animal.dll";     /* AIX filename */

   somEnvironmentNew();
   animalClass = _somFindClsInFile (SOMClassMgrObject,
                                    somIdFromString(animalName),
                                    0, 0,
                                    animalFile);
   myAnimal = _somNew (animalClass);
   somPrintf("The class of myAnimal is %s.\.n",
       _somGetClassName(myAnimal));
   _somFree(myAnimal);
}
   /*   Output from this program:  */
   /*   The class of myAnimal is Animal. */

Related

Methods