Kernel SDK Developer's Guide > Run-Time Type Identification > Implementing the Class Describing Structure
Implementing the Class Describing Structure

The OdRxClass abstract class is the describing structure that stores information about a class. Each class that is registered in the application must have an instance of the class describing structure. All class describing instances form the dictionary of classes (named class dictionary).

The OdRxClass abstract class provides the base interface for getting and storing information about a class and is used only for deriving new classes. You cannot create an instance of the OdRxClass class. The OdRxClass abstract class is a successor of the OdRxObject class and inherits its functionality. It declares the following methods:

  • name() pure virtual method — Returns the class name.
  • dxfName() pure virtual method — Returns the dxf class name.
  • appName() pure virtual method — Returns the application class name.
  • getClassVersion() pure virtual method — Returns the maintenance version.
  • proxyFlags() pure virtual method — Returns the proxy flags.
  • customFlags() pure virtual method — Returns the custom flags.
  • constructor() virtual method — Returns the pseudo-constructor of the class.
  • setConstructor() pure virtual method — Sets the pseudo-constructor of the class.
  • appNameCallbackPtr() pure virtual method — Returns a pointer to the function called when a drawing is being saved to a file.
  • create() pure virtual method — Creates an instance of the class using its pseudo-constructor.
  • module() pure virtual method — Returns the raw pointer to the OdRxModule object associated with this class.
  • myParent() pure virtual method — Returns the raw pointer to the OdRxClass object that is the parent for this class.
  • addX(), delX() and getX() — Adds, deletes, and gets the protocol extension record.

These methods do not have an implementation and are the declaration of the run-time type identification interface. Classes derived from the OdRxClass class must redefine these methods.

The C++ platform has the following classes for implementing pure methods declared by the OdRxClass class:

  • OdRxClassProtocolExtImpl class — Derived from the OdRxClass class, implements the base run-time members and protocol extension functionality and adds the implementation of the addX(), delX() and getX() methods.
  • OdRxBaseClassImpl class — Derived from the OdRxClassProtocolExtImpl class, declares the members that store information about a module and a parent class, associates the described class with its module, and adds the implementation of the module() and myParent() methods.
  • OdRxClassConsImpl class — Derived from the OdRxBaseClassImpl class, declares the member that stores the pseudo-constructor of the class as the OdPseudoConstructorType type and adds the implementation of the create(), constructor() and setConstructor() methods.
  • OdRxNamedClassImpl class — Derived from the OdRxClassConsImpl class, declares the member that stores the class name as the OdString value and adds the implementation of the name() method.
  • OdDxfClassImpl class — Derived from the OdRxNamedClassImpl class, declares the members that store the dxf class name as the OdString value, application class name as the OdString value, maintenance version as the OdUInt16 value, .dwg file version as the OdUInt16 value, proxy flags as the OdUInt32 value, and adds the implementation of the dxfName(), appName(), proxyFlags(), and getClassVersion() methods.

Note: The OdRxClassProtocolExtImpl class also creates the default implementation for the create() method which returns the NULL pointer and does not create an instance, the setConstructor() method that generates the eNotApplicable exception, the dxfName() method that returns an empty string, the appName() method that returns an empty string, and the getClassVersion() method that returns the kMRelease0 (=0) version number.

Note:  The OdRxClassConsImpl class initializes the class describing instance by the empty pseudo-constructor. If the setConstructor() method gets NULL instead of the pseudo-constructor, it sets the empty pseudo-constructor by default. If the class describing instance has an empty pseudo-constructor, the create() method generates the eNotApplicable exception instead of creating an instance.

The OdPseudoConstructorType type is a raw pointer to the function that does not take arguments and returns the non-typified smart pointer to the instance of the class that this function creates. This type has the following definition:

typedef OdRxObjectPtr (*OdPseudoConstructorType)()

Each of the listed classes declares and implements its own init() method that initializes the members of the class by specified values. The OdDxfClassImpl class is generally used.

The listed classes form the following hierarchy:

Usually, you do not need to create an instance of these classes. The RTTI substituting macro automatically generates the implementation of the rxInit() method that calls the newOdRxClass() global function for registering the class in the application. This function automatically creates and initializes the instance of the OdDxfClassImpl class and wraps it with the OdRxObjectImpl class to implement the reference counting methods. The newOdRxClass() function returns a raw pointer to the created class describing instance of the OdRxClass type. The rxInit() method stores this pointer in the g_pDesc member of the instance of the class for which the describing instance is created.

See Also

RTTI Technology

Functionality of RTTI

Implementing RTTI Methods for the Derived Class

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