UML-to-Real-Time-C++ transformations

The UML-to-Real-Time-C++ transformation generates real-time C++ code from UML model elements.

When you create a C++ capsule development project, the UMLRealTime transformation profile is applied automatically to the UML model that is created inside the UML development project. Stereotypes from the UMLRealTime transformation profile are applied automatically to model elements that you add to the model. You model the application in state machine and structure diagrams and can use property sets, such as RT properties, to control aspects of transformation output.

Valid transformation sources

The UML-to-Real-Time-C++ transformation can convert the following UML source objects into real-time C++ code:
  • Models
  • Packages
  • Capsules
  • Protocols
  • Classes
  • Enumerations
  • Interfaces

You must specify the model elements that the transformation should convert to C++ code when you create or edit a transformation configuration. Selected model elements cannot serve as the source for a transformation.

Top-level capsules

You can transform any capsule in the model into real-time C++ code. Each UML-to-Real-Time-C++ transformation configuration with an artifact type of C++ executable and an environment of C++ TargetRTS must specify a top-level capsule to compile. The top-level capsule represents the highest scope of the executable that you want to create. All classes and capsules that the top-level capsule references, directly or indirectly, are also compiled.

Because you can compile any set of UML elements in the model, you do not have to compile the entire model all the time. The capsule or selection of elements that you decide to transform might form only a subset of the whole system. This segmentation enables easier unit testing.

Valid names for transformation sources

Because the names for UML elements are transformed into the names of C++ code source elements, you must select a name for transformation sources that are valid in C++. The following best practices provide basic guidelines for valid names of UML elements.

Names for UML source elements can begin with a lowercase letter, uppercase letter, or an underscore (_). The subsequent characters can be lowercase letters, uppercase letters, or numbers. You can use a colon (:) in an operation name to specify fully qualified names for friend functions. You must prefix a destructor operation name with a tilde (~). In state machines, state and transition names have no constraints.

The transformation prefixes a name that begins with a number or an invalid character with an underscore (_). The transformation checks that names in a relevant namespace are unique; if the names are not unique, the transformation assigns the duplicate name a suffix of _<number>.

Valid transformation targets

A valid transformation target is a C++ project or any of its folders. If you create a new target container, you can create a standard make C++ project, which uses either a makefile that you create or an existing makefile, or you can create a managed make project, which generates the makefile for you automatically.

Transformation configuration inheritance and prerequisite transformations

You can specify one or more transformation configurations as prerequisite transformations, which are transformations that must run to generate the output required for the current transformation to run.

You can also specify one or more transformation configurations from which the current configuration inherits properties. For example, transformation configurations can inherit their property values from the properties in a default transformation configuration. Therefore, if a default property set is changed, all the transformation configurations in the system that use that property set inherit the changes.

A transformation configuration can have multiple inheritance parents, and the order in which they are specified dictates which have priority when the inherited transformation configurations specify the same properties. In addition, if the target projects are subsequently generated from the transformation configuration, the same properties are applied for the CDT project configurations.

A transformation configuration can have multiple inheritance parents, and the order in which they are specified dictates which take priority in the case where the inherited transformation configurations specify the same properties. In addition, if the target projects are subsequently generated from the transformation configuration, the same properties are applied for the CDT project configurations.

In transformation configurations that inherit other configurations, you can override or revert inherited values for many properties. When you right-click a property in the Transformation Configuration editor, a pop-up menu provides you with current options for the selected property. For example, for a property in which you have overridden the inherited value, you can choose to revert to the inherited value.

Transformation of UML model elements

The following table lists how the UML-to-Real-Time-C++ transformation transforms UML model elements into C++ code.

UML model element C++ code element
Association relationship, navigable ends only (see Property) Class attribute
Class or capsule Class (.h and .cpp files)
Dependency relationship Inclusion, forward reference, or none. Settings on the RT Properties page of the Properties window determine what is generated in the header and implementation files.
Enumeration Enum (.h and .cpp files)
Generalization relationship Class inheritance. Visibility, set on the RT Properties page of the Properties window determine whether base classes are public, private, or virtual.
Operation Operation
Package Ignored; no effect on code generation
Parameter Operation argument; direction: in, out, inout, return. Generates an exception in C++ if the IsException property on the Advanced page of the Properties window is selected.
Property Class attribute
Protocol Messages exchanged between a set of capsules.
Template binding relationship Not supported
Template class Not supported

C++ standard operations

Standard operations are constructors, copy constructors, virtual and non-virtual destructors, assignment operators, and getter and setter methods. You can specify which standard operations the transformation generates. You can also add a stereotype, which represents one of the standard operations, to the operation of a class in your model. The transformation applies the visibility of the UML operation to the generated standard operations, but ignores the name and parameters of the UML operation. The transformation generates standard operations for classes, structs, and unions that you add to a UML model.

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 in a class and assign it one of the standard operation stereotypes, the transformation generates the standard operation that you specified.

Location of transformation output

The transformation generates C++ code files in the C++ project or C++ project folder that you specify as the target of the transformation.

UML development projects and generated code

A UML development model is a type of UML model that is associated with a set of active domain language transformations and that implements a project build to run the transformations. For example, a UML C++ capsule development model is a kind of UML development model.

UML development projects facilitate model driven development (MDD) by bringing modeling closer to a development-based workflow in IBM® Rational® Software Architect RealTime Edition. This modeling paradigm enables a new theory of forward engineering, model is master. This theory encourages development within the model context by providing the means for development directly through the model and simplifies application development by generating code that is an artifact of the model compilation, or build. The UML model acts as the “code,” while UML state and structure diagrams are the “code editors.”

A UML development project functions as a linkage between Modeling perspective activities and domain specific language development perspectives, such as Java and C++ (Currently, only CDT projects are supported). Transformation configurations contained in each UML development project contain information about the target domain language project for the transformation, code generation options, and more. When a transformation in a project is invoked, either manually or automatically after a model save, code is generated directly into the target domain language project: for example, a CDT project.

Because the generated code is ready to be compiled into a library or executable, you do not have to modify the code source. In general, you should edit the model in the UML editors for state machine and structure diagrams, and add domain code in the associated code view. Any modifications that you make to the code source will be overwritten during future builds of the model.

However, if you make changes directly in the generated code, for example, if you notice an error in the code when you debug the model executable file, you can synchronize the changes with the model. During the next transformation, the software detects manual changes in the C++ source code and prompts you when the code is not synchronized with the model. You then have the option to automatically incorporate any source code changes into the model.

Integration with team support

The transformation provides integration functionality with IBM Rational Team Concert, CVS, Rational ClearCase®, and Rational ClearCase LT version control systems, which enables you to automatically check out files or add new files. You must enable team capabilities to work with configuration management systems.


Feedback