UML operations

The transformation generates a UML operation as a method of its class, and uses the following UML properties: 

Property

C++

Name

Name of the method (name validation applies)

Visibility

Determines the visibility of the method

IsAbstract

Generates the method as a pure virtual method

IsQuery

Generates the method as const (adds "const" to the suffix of the operation)

IsStatic

Generates the method with class instead of instance scope (adds static keyword to the prefix of the operation)

The type of the UML operation return parameter becomes the type of the generated C++ method. If no return parameter exists, the method's return type is assumed to be void (except for standard operations). A warning appears for operations with no return parameters or with more than one return parameter. 

You can specify several C++ -specific properties by applying the cpp_operation stereotype to the UML operation:

·         isInline: The transformation generates the operation as inline (adds the operation body to the header)

·         isVirtual: Declares the operation as a virtual function

·         isFriend: Generates a friend operation

C++ does not allow a static qualifier to be combined with either a virtual or friend qualifiers. For code generation purposes, the transformation prefers a static qualifier.

UML parameters

The transformation transforms UML parameters into the arguments of C++ operations. The transformation does not generate parameters with a "return" type, but uses them as an indicator of the operation return type. The transformation transforms the type of the parameter into the type of an argument.

The transformation transforms parameters having an "out" or "in/out" direction into references (meaning, it adds a "&" qualifier to the type specification).

The transformation uses the default value of the parameter to specify the default value of the C++ operation's argument. 

Optionally, you can apply the cpp_type stereotype to a UML parameter. This stereotype has a qualifier attribute that you can use to enter any string as a qualifier for the generated type. 

The following examples show how certain conditions affect the resulting code: 

·        If the operation type is specified (for example, Class1), and you do not specify the qualifier or do not apply the stereotype, the generated code for the attribute is "Class1 <ArgumentName>". 

·         If the operation type is not specified, you apply the cpp_type stereotype and set the qualifier string to "int ", the generated code is "int <ArgumentName>". 

·         If the operation type is specified (Class1), you apply the cpp_type stereotype and set the qualifier string to " * const ", the generated code is "Class1 * const <ArgumentName>". 

The transformation adds UML classes that are used by parameters to the inclusion list.

The transformation generates parameters in the order that the Model Server provides.

Top

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