UML association relationships

The transformation transforms association relationships into member variables in C++ code. For non-composition associations, the transformation adds the pointer sign (*) to the type qualifier of the attribute. If you specify multiplicity and set it to a specific number (with the same low and high ranges), the transformation adds an array specification to the attribute.

The transformation uses the following association end properties to generate code: 

Property

C++

Name

Creates a new member variable with the specified name (performs name validation)

Visibility

Determines the visibility of the generated member variable

UML generalization relationships

By default, the transformation generates public inheritance for the UML generalization relationship's target. The transformation automatically includes the header file for the target in the generated header file. The C++ transformation supports multiple inheritances. 

You can apply the cpp_generalization stereotype to specify the visibility (public, protected, private, and default) of the given generalization relationship. 

UML "Usage" relationships

Typically, a "Usage" relationship indicates reference to the class or enumeration. By default, a usage relationship transforms into a forward reference in the generated header file and an "include" directive in the body file. 

If you apply the cpp_dependency stereotype and set it's isInclusionInHeader attribute to true, the transformation generates the inclusion directive in the header. 

You can use a "Usage" relationship to indicate "friendship" relationships between classes by applying the cpp_friend stereotype to the relationship. The transformation includes the "friend" clause in the generated header file (for example, "friend class Class1;"). The transformation does not generate a body stub for the "friend" functions and automatically adds a dependency on the friend class to the generated code. 

UML "Implements" relationships

A UML class can implement a UML interface. This relationship becomes a public inheritance on C++ class.

UML template parameters

The transformation transforms a UML class with template parameters into a template class.

UML "Binding" relationships (instantiated classes)

The transformation considers a UML class with a "Binding" relationship with a target of Class1 as an instantiation of the template class Class1. The transformation uses the parameter substitution that the binding relationship specifies to resolve formal parameters into actual parameters.

A warning appears if a class has more than one "Binding" relationship. If a class has more than one binding relationship, the transformation uses the first one to generate code.

The transformation adds data types of actual parameters to the instantiated class inclusion list.

The following figure illustrates the instantiation relationship that the transformation supports, in which one class is a parameterized class and another class is an instantiated class.

The transformation does not support more complex usage patterns of template classes, including static variables in templates and parameterized classes that are used as formal parameters.

Top

Terms of use | Feedback
(C) Copyright IBM Corporation 2004. All Rights Reserved.