Une image contenant texte, signe

Description générée automatiquement

Rhapsody Model Transformers

 

Model Transformers

Much like Model Simplifiers, Model Transformers are a step in the code generation process (and usually invisible to the user). Both Model Transformers and Model Simplifiers allow manipulation of the generated code/executable model through helpers without modifying the original user model. Model Transformers are invoked before Model Simplifiers and there may be multiple transformations, for example:

 

 

 

Whereas simplifiers create a ‘flattened’ version of the model containing only artifacts that are directly related to code, Model Transformers create a full copy* of the model, allowing greater flexibility in model manipulation as part of the generation process.

 

*Typically, this copy does not contain diagrams that are not related to code generation (for example sequence diagrams).

Applying Model Transformers

Model Transformers are activated through a property applied to the Component/Configuration (typically this is achieved through application of a stereotype):

CPP_CG.Configuration.TransformationSequence

Chaining Transformers

The Power Pack has several Model Transformers and supplies a stereotype for each however if multiple transformations are required then the property should be locally overridden instead either directly through properties or through the application of a user-defined stereotyped. The property should contain all Model Transformers as a comma separated list, for example:

A screenshot of a computer

AI-generated content may be incorrect.

Viewing the Transformed Model(s)

By default, the transformed model is not visible to the user. Viewing the transformed model is not necessary for the functionality to work but may be of interest to the advanced user. To view the transformed model, add an asterisk to the transformation Sequence property, for example:

transformInheritedInterfaceBlocks*

A screenshot of a computer

Description automatically generated

The next time code is generated (or the model executed in Rhapsody Systems Designer) the transformed model will be retained in the model browser:

A computer screen shot of a computer program

Description automatically generated

If multiple transformers are used then each one may optionally be retained, for example:

Transformed models are then nested:

A screenshot of a computer program

AI-generated content may be incorrect.

The Transformed Model Stereotype

Rhapsody dynamically creates a Transformed Model stereotype that overrides several properties:

A screenshot of a computer

Description automatically generated

All Rhapsody Power Pack Model Transformers override the GeneratePackageCode property and reset it back to ‘Smart’ to ensure the code is generated correctly.