Standard operations 

In the C++ transformation, the term "standard operations" collectively refers to constructors, copy constructors, destructors, and assignment operators.

You can control the automatic generation of standard operations through the Eclipse plug-in properties. To access the properties, click Window > Preferences. To access the properties for the C++ transformation, expand Modeling, expand Transformations, and click UML to C++ Transformation.

The transformation generates constructors and copy constructors by default.

You can further control how the transformation generates standard operations by adding operations with specific stereotypes to the UML model. If you create an operation under a class and assign it one of the standard operation stereotypes, the transformation generates the standard operation instead of the specified operation. 

You can use the following stereotypes to generate standard operations: 

·         Constructor: You can use the cpp_constructor stereotype to specify whether the constructor is explicit or inline. The transformation assigns UML default values to class attributes in the generated constructors.

·         Copy constructor: You can use the cpp_copy_constructor stereotype to specify whether the copy constructor is explicit or inline. The transformation assigns UML default values to class attributes in the generated copy constructors.

·         Destructor: You can use the cpp_destructor stereotype to specify whether the destructor is virtual or inline.

·         Assignment: You can use the cpp_assignment stereotype to specify whether an assignment operation is inline. The transformation assigns values to class attributes based on the assigned class in the generated assignment operators. 

The transformation applies the visibility of the UML operation to the generated standard operations, but ignores the name and parameters of the UML operation. 

Constructors have initialization strings for attributes with specified default values. Copy constructors create attributes based on the attributes that are being duplicated. The bodies of the generated assignment operators contain assignment instructions that are appropriate for their class attributes.

If a class specifies a particular type of standard operation, its properties overwrite the default properties of the transformation. 

The transformation does not generate standard operations for unions, unless you explicitly add them to a UML model.

Top

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