UML-to-C++ transformation

The UML-to-C++ transformation converts UML model elements to C++ code.

What you can convert to C++ code

The UML-to-C++ transformation can convert the following UML model elements into C++ code:
  • Model
  • Package
  • Class
  • Enumeration
  • Component
  • Artifact
You can use components and artifacts to organize the elements of a model that you want to convert to C++ code. If you select an artifact or component the UML-to-C++ transformation converts related packages and classes to C++ code when any of the following relationships exist:
  • An artifact has a manifestation relationship to components and the components have a usage relationship to packages and classes
  • An artifact has a manifestation relationship to packages or classes
  • A component has a usage relationship to packages and classes

How source model elements are transformed into 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)

How the transformation generates C++ standard operations

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.

C++ visualization diagrams

You can generate UML visualization diagrams at the same time that you generate C++ code from your UML model. You can use UML visualization diagrams to view a graphical representation of your C++ code which you can edit at a graphical or code level. The UML-to-C++ transformation creates a UML visualization diagram for each UML package. The UML visualization diagram contains the non-nested classes, structures, unions, and enumerations that the UML-to-C++ transformation generates for the UML package.
Note: The generation of UML visualization diagrams increases both the time it takes to generate C++ code and memory consumption.

Where the transformation generates output

The UML-to-C++ transformation can only output C++ code files to C++ projects and C++ project folders.

Alternate names for generated output

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.

The UML-to-C++ transformation prohibits the following characters in mapping file and directory names:
  • Asterisk (*)
  • Question mark (?)
  • Quotation marks (")
  • Less than symbol (<)
  • Greater than symbol (>)
  • Vertical bar ( | )
Note: The transformation replaces prohibited characters with an underscore (_).
Related tasks
Generating C++ code from UML models
Applying the UML-to-C++ transformation profile
Related reference
Installed transformations
Feedback
(C) Copyright IBM Corporation 2004, 2005. All Rights Reserved.