SomGetRelatedClasses: Difference between revisions
Created page with "{{DISPLAYTITLE:somGetRelatedClasses}} This method returns an array of class objects that were all registered during the dynamic loading of a class. For backward compatibility..." |
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 a pointer to SOMClassMgrObject, or a pointer to an instance of a user-defined subclass of SOMClassMgr. | ||
;classObj (SOMClass) : A pointer to a SOMClass object. | |||
; classObj (SOMClass) : A pointer to a SOMClass object. | |||
==Return Code== | ==Return Code== | ||
; | ;rc (SOMClass *) : Returns a pointer to an array of pointers to class objects, or NULL, if the specified class was not dynamically loaded. | ||
==Remarks== | ==Remarks== | ||
Line 48: | Line 47: | ||
==Related== | ==Related== | ||
;Methods | |||
* [[somGetInitFunction]] | * [[somGetInitFunction]] | ||
[[Category:SOMClassMgr]] | [[Category:SOMClassMgr]] |
Latest revision as of 18:18, 12 October 2022
This method returns an array of class objects that were all registered during the dynamic loading of a class.
For backward compatibility, this method does not take an Environment parameter.
- Original Class
- SOMClassMgr
Syntax
SOMClass *somGetRelatedClasses (SOMClassMgr receiver, SOMClass classObj)
Parameters
- receiver (SOMClassMgr)
- Usually a pointer to SOMClassMgrObject, or a pointer to an instance of a user-defined subclass of SOMClassMgr.
- classObj (SOMClass)
- A pointer to a SOMClass object.
Return Code
- rc (SOMClass *)
- Returns a pointer to an array of pointers to class objects, or NULL, if the specified class was not dynamically loaded.
Remarks
The somGetRelatedClasses method returns an array of class objects that were all registered during the dynamic loading of the specified class. These classes are considered to define an affinity group. Any class is a member of at most one affinity group. The affinity group returned by this call is the one containing the class identified by the classObj parameter.
The first element in the array is either the class that caused the group to be loaded, or the special value -1, which means that the class manager is currently in the process of unregistering and deleting the affinity group (only class-manager objects would ever see this value). The remainder of the array consists of pointers to class objects, ordered in reverse chronological sequence to that in which they were originally registered. This list includes the given argument, classObj, as one of its elements, as well as the class that caused the group to be loaded (also given by the first element of the array). The array is terminated by a NULL pointer as the last element.
Use SOMFree to release the array when it is no longer needed. If the supplied class was not dynamically loaded, it is not a member of any affinity group and NULL is returned.
Example Code
#include <som.h> SOMClass myClass, *relatedClasses; string className; long i; className = SOMClass_somGetName (myClass)); relatedClasses = SOMClassMgr_somGetRelatedClasses (SOMClassMgrObject, myClass); if (relatedClasses && *relatedClasses) { somPrintf ("Class=%s, related classes are: ", className); for (i=1; relatedClasses[i]; i++) somPrintf ("%s ",SOMClass_somGetName (relatedClasses[i])); somPrintf ("\n"); somPrintf ("Class that caused loading was %s\n", relatedClasses[0] == (SOMClass) -1 ? "-1" : SOMClass_somGetName (relatedClasses[0])); SOMFree (relatedClasses); } else somPrintf ("No classes related to %s\n", className);
Related
- Methods