By default, the transformation generates UML elements that have the same name and visibility as the source C++ elements. If the transformation cannot transform a C++ element, it ignores the element. The following table lists the output that the transformation generates when it transforms C++ code elements into UML model elements.
The transformation does not transform global variables and global functions in the C++ code because these C++ elements cannot be represented in UML.
The transformation does not transform preprocessor directives in the C++ code because these C++ elements cannot be represented in UML. You must specify user-defined preprocessor directives in the user-defined section in the C++ source files.
If the source CDT project includes a template instantiation that instantiates a class that does not exist in the source CDT project, the transformation transforms the template instantiation into a UML primitive type. The transformation transforms the references to the template instantiation into the appropriate reference to the UML primitive type in the target model.
class Class1{
int x;
}
The transformation creates a mapping between the type of the
property x in the UML class named Class1, and the int C++
primitive type. The C++ type library contains the int primitive type.The following tables list how the transformation sets the Type property if the type of the C++ member variable is a user-defined type.
The example in the following table lists how the transformation sets the value of the UML Type property when the type of the C++ member variable references a type that is defined in a different C/C++ Development Tools (CDT) project.
| C++ code sample | Value of the Type property |
|---|---|
| CDTProject1 contains a class named Class1. CDTProject2 contains a class named Class2: #include "CDTProject1/Class1"
class Class2{
Class1 x;
};
|
The transformation creates a mapping between the type of the UML property x to the visual element that corresponds to the class named Class1 in the C++ source project named CDTProject1. |
The following table lists additional information that the transformation generates for specific member variables.
| C++ member variable | Additional characteristics of the transformation output |
|---|---|
| const | isStatic property is true |
| mutable | The transformation applies the «cpp_type» stereotype to the property; the isMutable property of the stereotype is set to true |
| static | isStatic property is true |
| volatile | the transformation applies the «cpp_type» stereotype to the property; the isVolatile property of the stereotype is set to true |
The transformation transforms a C++ member function in a class, struct, or union into a UML operation in the corresponding UML class. The UML operation that the transformation generates has the same name and visibility as the C++ member function. The following table lists the additional information that the transformation generates for specific function parameters.
| C++ member function | Additional characteristics of the transformation output |
|---|---|
| Assignment | The transformation applies the «cpp_assignment» stereotype; the generated operation has the same name and visibility as the = assignment operator |
| Const | The transformation sets the isQuery property to true |
| Constructor | The transformation applies the «cpp_constructor» stereotype; if the transformation transforms multiple constructors, it appends a number to the constructor name to uniquely identify the constructor |
| Copy | The transformation applies the «cpp_copy_constructor» stereotype; if the transformation transforms multiple copy constructors, it appends a number to the constructor name to uniquely identify the copy constructor |
| Destructor | The transformation applies the «cpp_destructor» stereotype; if the transformation transforms multiple destructors, it appends a number to the destructor name to uniquely identify the destructor |
| Friend | The transformation applies the «cpp_operation» stereotype, and sets the isFriend property to true |
| Inline | The transformation applies the «cpp_operation» stereotype, and sets the isInline property to true |
| Pure virtual | The transformation sets the isAbstract property to true |
| Static | The transformation applies the «cpp_operation» stereotype, and sets the isVirtual property to true |
| Virtual | The transformation sets the isStatic property set to true |
class one{
int op(int x=5);
}
The transformation sets the default value of the generated UML
parameter x, in the operation op, to 5.| C++ function parameter | Transformation output |
|---|---|
| Reference | The transformation sets the Direction property to inout |
| Return | The transformation sets the Direction property to return |
| Regular (not reference or return parameters) | The transformation sets the Direction property to in |
C++ member variables, member functions, and parameters might specify type modifiers, such as pointers to types, reference types, and array types. These type modifiers cannot be represented in UML. The following table lists how the transformation transforms type modifiers.
| Type modifier | Transformation output |
|---|---|
| Pointer to a C++ type | The transformation applies the «cpp_type» stereotype
to the UML parameter or property that it generates, and sets the qualifier
attribute to a pointer operator. Consider the following C++ code:class MyClass {
private: char* name;
};
The transformation generates a UML class named MyClass that contains a name variable with the following properties: ![]() |
| Reference to a C++ type | The transformation sets the qualifier attribute to a
reference operator. The transformation only applies the «cpp_type» stereotype when it transforms multiple reference types in the source code. If the transformation transforms a C++ parameter that is a reference type, it sets the direction attribute of the UML parameter to inout. Consider the following C++ code: class MyClassClone {
private:
MyClassClone clone(MyClassClone& copy);
};
The transformation generates a UML class named MyClassClone that contains a return parameter with the following properties: ![]() |
| Array | For a single-dimension array, the transformation sets the multiplicity of the UML parameter or property as equal to the value of the single dimension. The transformation only applies the «cpp_type» stereotype when it transforms multiple dimensional arrays in the source code. The following example shows how the transformation sets the multiplicity for an attribute of type int x[10]: ![]() The transformation sets the lower and upper bound of the multiplicity property to the value of the single dimension of the attribute. |