Setting preferences for UML-to-C++ transformations

You can set warning and code formatting preferences for UML-to-C++ transformations. For example, you can specify C++ preface and closing comments, and specify indentation style preferences.

About this task

You can specify the comments that the transformation inserts at the beginning and end of the files that it generates. The text that you specify is inserted into the source code exactly as it appears in the text area. You must include the appropriate C++ comment notation. For example, you can specify copyright information, or other authoring information that must appear in each source file. You can also select formatting preferences for tab spacing, the display order of class attributes and operations, and indentation styles.

To set preferences for the UML-to-C++ transformation:

Procedure

  1. Click Window > Preferences.
  2. In the Preferences window, expand Modeling > Transformations.
  3. Optional: To specify comment and code formatting preferences, click UML to C++ transformation, and complete one or more of the following steps:
    • To generate include directives that contain the name of the header file that corresponds to the Standard Template Library (STL) class that a model references, select the Include standard header files for Standard Template Library classes check box. For example, if a model contains a reference to the STL class named vector<>, the transformation generates the following include directive: #include <vector>. By default, this option is selected.

      If you clear this check box, the generated include directive specifies the name of the STL header file that contains the declaration of the referenced STL class. Including these header files might cause compilation errors because the header file might not be complete.

    • To specify file preface and closing comments, click the General tab, and type the comments in the appropriate text field.
    • To set code formatting preferences, click the Edit styles tab, and complete one or more of the following steps:
      • To display class attributes followed by operations, with both sorted by C++ visibility rules, click Sort by visibility.
      • To display class attributes and operations in the same order as they are stored in the UML model, click Sort by storage.
      • To specify an indentation style for the code that the transformation generates, click an option in the Indentation styles pane. The style that you select, combined with the value that you specify for the Tab spaces field, determines the actual indentation of the code that the transformation generates.
  4. Optional: To specify that the transformation display a warning message before replacing source UML model elements with pointers to the generated elements, click UML Visualization and select the Show warning when replacing UML elements check box.
    Note: If you select this check box, for the appropriate transformation configuration, on the Main page of the transformation configuration editor or the Specify a Configuration Name and Transformation page of the New Transformation Configuration wizard, you must also click the Mixed radio button.
  5. Click Apply and click OK.

Results

The transformation applies the preferences the next time that you run the transformation.

Feedback