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 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 C/C++ Development Tools (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.
| C++ template class | UML element |
|---|---|
| Template class definition |
|
| Template class instantiation in a typedef definition |
|
| Template class instantiation not in a typedef definition |
|
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.
If the type of the C++ member variable is a user-defined type, the transformation sets the UML Type property to the value of a UML element that corresponds to the user-defined type in the target UML model. If the transformation cannot determine the UML element in the model that corresponds to the user-defined type, the transformation creates a UML primitive type with the same name as the UML element, and sets the Type of the UML property as equal to the name of the new UML primitive 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 CDT project.
| C++ code sample | Value of the Type property |
|---|---|
| CDTProject1 project contains a class named Class1. CDTProject2 project 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
constructor methods in the C++ code are overloaded, for each constructor
method in the code, the transformation generates a corresponding constructor
method in the target model. If the transformation encounters duplicate constructor methods in the code, the transformation generates a constructor method for the first one that it encounters. |
| CopyConstructor | The transformation applies the «cpp_copy_constructor»
stereotype. If the
copy constructor methods in the C++ code are overloaded, for each
copy constructor method in the code, the transformation generates
a corresponding copy constructor method in the target model. If the transformation encounters duplicate copy constructor methods in the code, the transformation generates a copy constructor method for the first one that it encounters. |
| Destructor | The transformation applies the «cpp_destructor»
stereotype. If the
destructor methods in the C++ code are overloaded, for each destructor
method in the code, the transformation generates a corresponding destructor
method in the target model. If the transformation encounters duplicate destructor methods in the code, the transformation generates a destructor method for the first one that it encounters. |
| 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 sets the isStatic property to true. |
| Virtual | The transformation applies the «cpp_operation» stereotype, and sets the isVirtual property 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. |