Classes, enumerations, and interfaces that UML-to-C++ transformations transform

Several factors determine how the UML-to-C++ transformation generates C++ elements from classes, enumerations, and interfaces.

UML classes

The transformation generates a header file, and optionally, a body file, for each class that is specified in the source of the transformation configuration. By default, a body file has .cpp as a file name extension. To specify a different file name extension, set the BODY_FILE_EXTENSION system property in the eclipse.ini file. For example, to generate files that have .cc as a file name extension, add the following code to the eclipse.ini file: -DBODY_FILE_EXTENSION=.cc.The transformation generates C++ structs, unions, and typedefs from UML classes that have the «cpp_struct», «cpp_union», or «cpp_typedef» stereotype applied. You must apply the C++ transformation profile before you can apply these stereotypes to elements in your model. The transformation does not generate body files for the following items:
  • Classes that have the «cpp_typedef» stereotype applied
  • Classes that have «cpp_struct», «cpp_typedef», or «cpp_union» stereotype applied, and do not contain operations
  • Classes that have «cpp_struct», «cpp_typedef», or «cpp_union» stereotype applied, and contain only operations that are abstract
The transformation assigns the name of the class to the header file and the body file. If the name of the class does not conform to C++ naming rules, or if the name is not unique, the transformation assigns a new name to the header and body file. The generated body file contains an #include directive for the corresponding header file.

UML enumerations

The transformation generates a C++ enum for each UML enumeration that you specify in the source of the transformation configuration. If necessary, the transformation assigns a unique name that conforms to C++ rules; otherwise, the generated C++ enumeration has the same name as the UML enumeration. The transformation transforms UML enumeration literals into C++ enumeration literals.

UML interfaces

The transformation transforms UML interfaces into C++ classes. UML operations in the interface are transformed into pure virtual C++ methods.

Nested UML classes, enumerations, and interfaces

The transformation does not generate a separate header and body file for nested elements. Instead, the transformation adds information about the nested elements to the header and body file of the class that contains the nested elements.


Feedback