UML models

You can apply the cpp_namespace stereotype to a model. You can use the stereotype's NamespaceName attribute to specify the namespace for all elements in the model.

UML packages

UML packages become folders in the target project (and, correspondingly, folders on the file system). The transformation places the elements of the package in the package folder.

The transformation ignores packages that are marked as analysis packages. A user marks a package as an analysis package by applying the <<perspective>> stereotype to it, or by applying a keyword of "analysis" or "Analysis".

Similar to models, you can apply the cpp_namespace stereotype to a package to specify the namespace for all elements in the package. The transformation does not currently support nested namespaces. The namespace specified on the inner package supersedes the namespace specified on the outer package.

If two UML packages have the same name at the same model level, the transformation creates only one folder on the file system and places the contents of both UML packages in that folder.

UML classes

For UML classes, the transformation generates a pair of files: a header file and a body file. If necessary, the transformation converts the name of the class to conform to C++ rules and to ensure that the name is unique. The body file always contains the include directive for the corresponding header file. By default, the generated header file has the file name <ClassName>.h and the generated body file has the file name <ClassName>.cpp. 

Generalization and association relationships affect code generation. For more information, see "UML association relationships" and "UML generalization relationships."

You can apply the following stereotypes to UML classes:

·         cpp_struct: This stereotype generates C++ struct instead of class.

·        cpp_union: This stereotype generates C++ union instead of C++ class. The C++ profile allows a nested union to be anonymous. By default, no standard operations are generated for unions.

·        cpp_typedef: This stereotype generates C++  typedef instead of C++ class. You should use the stereotype's "ImplementationType" attribute to specify the signature of the type that is being defined.

UML enumerations

The transformation transforms UML enumeration into C++ "enum". The name of the C++ enumeration is taken from the UML enumeration. If necessary, the transformation converts the name of the enumeration to conform to C++ rules and to ensure that the name is unique. The transformation generates UML attributes as C++ attributes, and applies the default values from the model.

Unlike UML classes, the transformation only generates the header file for enumerations.

UML interfaces

The C++ transformation transforms UML interfaces into C++ classes. Processing of interfaces is similar to the processing of UML classes except that UML operations are generated as pure virtual C++ methods. The processing of standard operations (default constructor, copy constructor, destructor, and assignment operator) is the same for interfaces as for classes.

Nested UML classes, enumerations, and interfaces

Classes can have nested classes, enumerations, and interfaces. The transformation generates nested objects similarly to their non-nested counterparts. However, the transformation does not create separate header and body files for nested objects; it adds to the header and body files of the class that contains them.

Nested objects also have these differences:

·         Visibilities of the nested elements are tracked in their parents

·         Include directives for the nested elements are added to include directives of the classes that contain them

·         Operation bodies for nested elements are prefixed with the names of the classes that contain them

·         Definitions of static attributes for nested elements also include the names of the classes that contain them

Top

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