Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
Runtime Types

The

SoType class keeps track of runtime type information in Inventor. When initialized, many classes request a unique SoType. You can then use this type to find out the actual class of an instance when only its base class is known, or to create an instance of a particular class, given its type or name. Useful type-related methods, which are provided by the macros for implementing most classes, include

getClassTypeId() a static method that returns the type identifier for a specific class
getTypeId() a virtual method that returns the type identifier for an entity (for example, a node, field, or action) whose class is unknown
isOfType() returns TRUE if this entity (for example, node, field, or action) is of the specified type or is derived from that type

All nodes, node kits, manipulators, actions, elements, fields, engines, events, and details in Inventor must have a static method to initialize the class. This method, which must be called initClass(), sets up the type-identifier and file-format name information for the class. Standard Inventor classes are initialized during SoDB::init(), SoInteraction::init(), SoNodeKit::init(), or SoXt::init(). For extender classes, the initClass() method must be called after the database is initialized and before any instance of the class is constructed. The order for initializing is elements first, actions, then nodes.

For any new class that supports runtime typing, the initClass() method must be defined in the header file and implemented in the source file. Most classes have associated macros that can be used within the initClass() method.

Symetrically to the initClass() method, all Inventor classes that register their type information define an exitClass() method to unregister these informations and free some internal static memory.

This is mostly useful to avoid reports of memory leaks from analyzers. Unregistering a class before deleting all of its instances causes an error message when the instances are deleted, as the class's type informations will no longer be registered and will be in an uninitialized state.