The UML-to-C++ transformation converts UML model elements to C++ code.
The following table lists how the UML-to-C++ transformation converts UML model elements into C++ code.
UML model element | C++ code element |
---|---|
Package | Folder |
Class | Class (.h and .cpp files) |
Generalization relationship | Class inheritance |
Association relationship | Class attribute |
Property | Class attribute |
Enumeration | Enum (.h file) |
Operation | Operation |
Parameter | Operation argument |
Usage relationship | Inclusion |
Template parameter | Parameter for a parameterized class |
Template binding relationship | Instantiated class (.h file) |
Standard operations are constructors, copy constructors, destructors, and assignment operators. You can specify which of the standard operations the UML-to-C++ transformation generates. You can also add a stereotype, which represents one of the standard operations, to the operation of a class in your model. The UML-to-C++ transformation applies the visibility of the UML operation to the generated standard operations, but ignores the name and parameters of the UML operation. The UML-to-C++ transformation generates standard operations for unions that you add to a UML model.
The UML-to-C++ transformation can only output C++ code files to C++ projects and C++ project folders.
You can use the mapping feature to specify alternate names for files that the transformation generates without modifying the source model. You can specify absolute and relative file names. Absolute file names must specify an existing project. The transformation creates parent directories that do not already exist. The transformation replaces file name extensions with standard C++ file name extensions such as .h or .cpp.
The transformation bases the names of UML visualization diagrams on the name of the package that contains them. Mapping artifacts do not directly affect the naming of UML visualization diagrams.