3 Code Generator

When calling up the IDM with the option –writecpp in connection with the option-merge, the code generator for the C++ code is called simultaneously. The code generator checks all records (no matter if default, model or instance) and generates C++ code for every record containing functions.

The code for a C++ class consists of a definition and an implementation segment. The attributes of the records appear as member variables (analogously to the trampoline-generation), functions as C++ methods in the definition part. The implementation part of the class comprises code for the link of the class.

The implementation section of the class contains code for the binding of the class, a method for the calling up of methods from the Rule Language to the C++ method and code that allows for the instancing and releasing directly from the IDM. Likewise, the necessary record-information-structures for the transferring of attributes can be found in the implementation section.

Figure 5-4: Hierarchical division of the generated C++ code

The generated code is not written in a file, but rather it is memorized internally. The code is split up into text passages which have been previously marked. These marks again are structured hierarchically, yet they might appear several times on the same hierarchy level. Thus, such a marked text is only a fragment from the entire generated code. In addition, within the text passage a sub-area is marked. A text area can be extracted only once.

Figure 5-5: Structure of the definition segment in hierarchy nodes

The illustration above exemplifies this principle of the code generated from the IDM-record “Rec”. This record itself contains attributes and functions:

The application programmer is to decide for himself what is to be taken from the generated code and where it is to be employed, and if any supplements need to be added.

In addition, the programmer should basically specify the “path” in his output file which then automatically removes the desired paragraphs from the hierarchically arranged generated C++ code.

Through the further qualification of a sub-section, requests, such as the defining and implementing of a class in the same data or the immediate implementation of methods without having to declare them first (i.e. do not include them at the end, but rather write them directly into the code { } ), can be realized.

The following table provides detailed information about possible paths in the hierarchy and their use. Words written in italics refer to symbolic names. Here, the signifiers from the dialog file are meant.

Node Name

Content and Intention

INCLUDE

Contains #include-line for the IDMcpp.h-file.

CLASS

Comprises all class definitions.

CLASS/Record

Class definition of a particular class comprising definitions of the attributes and methods.

Sub-passage: Contains only the class name in order to indicate a superclass of its own (without {}).

CLASS/Record/MEMBER

Contains the definition of all member variables (attributes) of a particular class.

CLASS/Record/MEMBER/Attribute

Contains the definition of a particular member variable (attribute)

Sub-passage: without ; -end

CLASS/Record/METHOD

Contains the definition of all methods (functions) of a particular class.

CLASS/Record/METHOD/Function

Contains the definition of a particular method (function)

Sub-passage: without ; -end

IMPL

Contains the implementation segment of all classes (link to the IDM).

IMPL/Record

Contains the implementation part of a particular class (link to IDM).