Jump to content

SomClassFromId: Difference between revisions

From EDM2
Created page with "{{DISPLAYTITLE:somClassFromId}} This method finds a class object, given its somId, if it already exists. Does not load the class. For backward compatibility, this method does..."
 
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==
Line 10: Line 10:


==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 of the class. This can be obtained from the name of the class using the somIdFromString function.
; classId (somId) : The somId of the class. This can be obtained from the name of the class using the somIdFromString function.


==Return Code==  
==Return Code==  
; rc (SOMClass) : Returns a pointer to the class, or NULL if the class object does not yet exist.
;rc (SOMClass): Returns a pointer to the class, or NULL if the class object does not yet exist.


==Remarks==
==Remarks==

Latest revision as of 16:33, 12 October 2022

This method finds a class object, given its somId, if it already exists. Does not load the class.

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

Original Class
SOMClassMgr

Syntax

SOMClass somClassFromId (SOMClassMgr receiver, somId classId)

Parameters

receiver (SOMClassMgr)
Usually SOMClassMgrObject (or a pointer to an instance of a user-supplied subclass of SOMClassMgr).
classId (somId)
The somId of the class. This can be obtained from the name of the class using the somIdFromString function.

Return Code

rc (SOMClass)
Returns a pointer to the class, or NULL if the class object does not yet exist.

Remarks

Finds a class object, given its somId, if it already exists. Does not load the class.

Use the somClassFromId method instead of somFindClass when you do not want the class to be automatically loaded if it does not already exist in the current process.

Example Code

#include <som.h>

main () {
    SOMClass myClass;
    char *myClassName = "Animal";
    somId animalId;

    somEnvironmentNew ();
    animalId = somIdFromString (myClassName);
    myClass = SOMClassMgr_somClassFromId (SOMClassMgrObject,
                                                             animalId);
    if (!myClass)
        somPrintf ("Class %s has not been loaded.\n", myClassName);
    SOMFree (animalId);
        }

This program produces the following output:

Class Animal has not yet been loaded.

Related

Methods