To specify the information
that the transformation uses to generate the output that you expect,
you use the New Transformation
Configuration wizard and the transformation configuration
editor, which guide you through the configuration.
About this task
A transformation configuration
has .tc as a file name extension, and contains the information that
the transformation uses to generate the output that you expect. A
transformation configuration also contains information that is specific
to a particular type of transformation. To edit an existing transformation
configuration, in a view that shows the workspace resources, double-click
a transformation configuration file, which opens the transformation configuration
editor.
To simplify
working with the transformation configuration file, save the configuration
file in the project that contains the elements to transform.
Procedure
- Depending on the view that you are working
in, complete one of the following steps:
- In the Pattern Explorer view, right-click
a transformation; then click New Configuration.
- In other views, click . If Transformation Configuration is not a menu item, click .
- Specify the details
of the configuration. In the New Transformation
Configuration wizard, on the Specify a Configuration
Name and Transformation page, complete the following steps:
- In the Name field, specify a name for the configuration.
- In the Configuration file destination field, specify the destination for the transformation
configuration file. The destination is a relative path in your current
workspace. You can specify a fully qualified project name or folder
name. If you specify a folder in a project, you must prefix the folder
name with a forward slash (/).
- From the Transformation list, select a transformation.
Note: To display the transformations that are
installed, but not enabled, click Show all transformations. A transformation must be bound to a capability
to be displayed in this list.
- In the Protocol section, specify the modeling protocol, which is also
called the design contract management protocol (DCMP). The value that
you select determines whether to synchronize the source and target
of the transformation.
- If the source model is the primary
engineering artifact, select Conceptual. Any changes to the source model are propagated
to the target model.
- If the target model is the primary engineering
artifact, click Mixed. The transformation converts the source artifacts
to visual representations that are directly connected to the target
artifact. Select this option to work in the target domain instead
of with the source model, or to retain the artifacts for analysis.
The transformation output becomes the primary engineering artifact.
- If the architecture that the source
artifacts represent evolves independently from the target, select Reconciled. Selecting this option enables the reverse
transformation, which you can use to compare the source and target,
and to reconcile changes. You might also select this option if different
teams implement, develop, or maintain the architecture.
Note: When you select this option, additional properties
become available in the "Reverse transformation" section of the Main page. For some transformations, additional options or
pages become available in the transformation configuration
editor. For information about configuring the reverse transformation,
see the related link below.
- Click Next.
- Specify the source and target elements
for the transformation. For a list of valid source and target elements,
see the related concept topic for this transformation. On the Source and Target page, complete the following steps:
- In the Selected source pane, select the source element for the transformation
to transform.
- In the Selected target pane, select the destination of the transformation output.
To create a new destination for the output, click Create Target Container.
- Click Next.
- Optional: Specify the overwrite options for
the transformation output. You can also specify whether the transformation
deletes obsolete files, which might occur as a result of renaming
classes in the source UML model. On the UML to C++ Properties page, under Overwrite existing files, complete
one of the following steps:
When you rerun the UML-to-C++ transformation, the transformation
deletes files that do not contain any C++ language content.
- Optional: Specify how the transformation generates
standard operations by selecting options on the UML to
C++ Properties page, under Generate operations:
- To generate constructors, select the Constructor check box.
- To generate copy constructors, select the Copy
constructor check box.
- To generate assignment operators, select the Assignment check box.
- To generate destructors, select the Destructor check box.
- To generate virtual destructors in the target classes, select
the Virtual destructor check box.
- To generate getter and setter methods for the attributes of
the generated classes, structs, or unions, select the Getters
and setters check box.
- To generate inline getter and setter methods, select the Inline check box.
- To generate getter and setter methods that pass parameters
and return values by using references, select the By reference check box.
- Optional: Specify preferences for the generation
of the transformation output by selecting options on the UML to C++ Properties page, in the Code generation
properties section:
If you select the Create separate folders for
header and source files check box, in the source file
folder that you specify, the transformation generates the files in
the same hierarchy as the source UML model. The transformation does
not preserve the source model hierarchy for header files. For example,
assume that a UML model contains a package called Package1, which
contains a class called Class1. If you specify HeaderFolder and SourceFolder
as the folder names for the generated header and source files, the
transformation generates a file called Class1.h in the HeaderFolder
folder structure of the target project, and a file called Class1.cpp
in the SourceFolder/Package1 folder structure of the target project.
- Optional: Specify how the transformation generates
include directives. By default, the generated include directives specify
the relative path of the imported file.
On the UML to C++ Properties page, under Internal
inclusion, select an option from the table below. If the
imported class is part of the transformation source and it does not
have the «cpp_internal_inclusion» stereotype applied to it, the transformation
generates include directives by using the value that you specify.
Under External inclusion, select an option
from the following table. If the imported class is not part of the
transformation source and it does not have the «cpp_external_inclusion»
stereotype applied to it, the transformation generates include directives
by using the value that you specify.
| Option |
Description |
| None |
This option suppresses the generation of include directives. |
| Suppress path names in include directives |
This option suppresses the full path name of header files
in the generated code. The path name that you specify in the include option of the makefile is implied in the include directive. For
example, if the full path name of the header file is Package1/header1.h
and you click this option, the generated include directive is #include
"header1.h".
|
| Generate include directives that
contain the relative path name to the including file |
This option generates include directives that specify the
relative path of the imported file. |
| Generate an include directive that contains
the following file name |
For this option, specify a relative or absolute path of a
file name to import. For example, if you specify "..\includefile.h"
in this field, the generated include directive is #include "..\includefile.h".
|
| Generate include directives that are
relative to this folder |
This option generates include directives that specify the
path of the imported class relative to the specified folder. The folder
that you specify must exist in the current workspace. |
- Optional: To override the default JET transformation
that generates the C++ code, in the Use the following JET
transformation to generate C++ code field, specify the
identifier of the overriding JET transformation.
For
example, you might override the default JET transformation to customize
the comments in the code. The identifier of the JET transformation
typically follows an inverted domain-naming schema, as in this example:
my.company.my.jet.project. For more information about this function,
see the related concept topic for this transformation.
- Click Next.
- Optional: If the transformation that you configure supports mapping, you can
specify alternate names for the artifacts that the transformation
generates by creating a mapping model. To use a new or existing mapping
model, complete the following steps:
- On the Mapping page, select the Enable the mapping functionality for
this configuration check box.
- In the Mapping model file name field, specify the name of a new or existing
mapping model.
- Click Finish. The transformation configuration
editor opens, and the contents of the configuration are displayed.
- Optional: To generate
debugging information, on the Main page, select the Generate a debug log check box. The
next time that you run the transformation, the log file is generated
as an XML file in the folder that you specify in the transformation
preferences. If you do not specify a location for the log files, the
transformation generates the log file in the .metadata folder in your workspace.
Tip: To set preferences for transformations,
click ; then expand Modeling and click Transformations.
The log file
provides information about the source elements, the target elements,
and the rules that the transformation applies to transform the source
elements. If the transformation transforms many elements, you might
experience decreased performance while the transformation generates
the log file; therefore, you should only generate a log file for debugging
purposes.
- Optional: To prevent new dialog boxes from opening while a transformation runs,
on the Main page, select the Run the forward transformation silently check box.
Running a transformation in silent
mode suppresses all dialog boxes that the transformation generates.
The transformation applies default rules and behavior, which might
generate unexpected or incorrect transformation output. You should
only run a transformation in silent mode to validate that the transformation
runs, instead of validating the transformation output. For example,
you might run a transformation in silent mode as part of an automated
task or automated test suite.
Setting the transformation to run in silent mode overrides the file-overwrite
options that you specify, and overwrites files if necessary.
If the C++-to-UML transformation is available, you can select
the Run the reverse transformation silently check box. Specifying that the C++-to-UML,
or reverse transformation runs in silent mode suppresses the merge
editor. If a conflict occurs during the merge, the transformation
stops and you must rerun the transformation with the silent options
cleared.
- Optional: To create a traceable relationship between the transformation
source and target, on the Main page, select the Create trace relationships check box. This check box is enabled only if you select the Conceptual Models Seed Concrete Models
and Conceptual Models Drive Development or Reconciled
Modeling protocols.
You can use trace
relationships and the visual development tools to understand the relationships
between source model elements and transformation output. This function
is useful in large projects that might contain multiple models and
transformation configurations. The transformation does not alter the
source model.
To
view the list of elements for which traceable relationships can be
created, see the related transformation concept topic link at the
end of this topic.
- Optional: To generate the inherited methods
in the target classes, select the Inherited operations option. To generate the inherited methods by using the
UML-to-C++ transformation, you must create a class and an interface
in the source UML model, draw an Interface Realization or Realization relationship between the class
and interface, and select the Create trace relationships check box.
- Optional: To
display the errors that occurred when the transformation ran, on the Main page, select the Open the Report dialog box when the transformation
is complete check box. Selecting this check box displays
only the generated errors. The same information is also written to
the error log, which you can view by clicking .
To display the warnings
that occurred when the transformation ran, select the Show warnings in the Report dialog
box check box.
- Optional: Specify documentation
about the transformation configuration. This field is useful for communicating
information about a configuration that multiple users share. On the Main page, in the Documentation field, specify additional information about
the transformation configuration.
- Click .
Results
The options are applied the next time that
you run the transformation.