Kernel SDK Developer's Guide > Run-Time Type Identification > Concept of RTTI Technology
Concept of RTTI Technology

Run-time type identification (RTTI) technology provides the ability to dynamically identify a class and get various information about it at run-time. RTTI allows developers to:

  • Check whether the instance belongs to a specified class.
  • Check whether conversion of pointers to a specified type is correct before processing of data.
  • Check whether application of a function or method is correct for the specified instance.
  • Select the manner of data processing subject to the class type of the specified instance.
  • Get description information about the specified class.
  • Develop more flexible program code that can be adapted for different data types.

If an instance belongs to or is derived from the specified class, a pointer to the instance can be converted to the specified class type and applying methods is correct for the instance. After identification of the instance, a developer can perform the specific processing of its data, can call the specific functions or methods, and can apply the admissible operations.

The idea of run-time type identification is to use the special structure of data that stores information about a class and refer to this structure from instances of the class. Each instance of the class derived from the OdRxObject class stores the raw pointer to the structure that describes its class. Information about a class is stored in the special structure. Using the pointer to the describing structure, the instance can get information about its own class at any time. Additionally, each derived class must define the methods that allow its own object to get the pointer to the describing structure, check whether it belongs to the class or its subclass, verify the parent class, and obtain the identity information. All describing structures are usually united in a dictionary of classes; repeating the description of a single class is not necessary.

The implementation of the run-time type identification technology includes declaring and implementing the special classes that store the descriptions of classes, declaring and implementing the methods for getting and checking the class information of classes derived from the OdRxObject class, declaring and implementing the special functions for registering and unregistering class types, and implementing the function for manipulating the describing structures. One instance of the describing structure stores information about one class type. Multiple instances of a class type can refer to one describing structure. Each describing structure stores a reference to the structure that describes its own parent in the hierarchy of classes. The implementation also includes a special dictionary that relates the class name with its describing structure.

The implementation of run-time type identification technology provides the following functionality:

  • Gets the class name at run-time.
  • Gets information about parent class.
  • Gets the dxf class name and associates it with a class.
  • Gets the application class name and associates it with a class.
  • Gets information about the module in which a class resides.
  • Checks whether a class is derived from a specified class.
  • Gets or sets the pseudo-constructor for a class.
  • Gets or sets the callback function called when a drawing is being saved to a file.
  • Gets the class versions.
  • Gets the proxy and custom flags.
  • Uses the dictionary of classes.
  • Provides the "protocol extension" technology.

See Also

RTTI Technology

Overview of Classes that Implement RTTI

Understanding Pseudo-Constructors

Understanding the Dictionary of Classes

Registering and Unregistering Classes in a Program

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.