You can synchronize any changes that you make to the code
with your capsule-based model. When you change the generated source
and save it, the system synchronizes the generated source with the
model snippets. A dialog box shows all the changes, and you can commit
the changes to the model.
About this task
The system monitors any changes that you make to generated
sources files, and automatically attempts to keep your model snippets
synchronized with any changes to the generated source that you make
within the generated user tags. The system provides the list of changed
model elements and you choose whether to save each change. The selected
changes are saved to the model. You can undo the save operation to
return the model to its original state; however, the generated source
code remains unchanged. To undo the code changes in the model, you
must have the model open.
To synchronize C++ code with a capsule-based
model:
Procedure
- Set the synchronization preferences:
- Click .
- In the Preferences window, select .
- In the Code To Model Synchronization window, preview
the differences between the generated source code and the model. Double-click
an element to show a specific change. In some cases, the
transformation can duplicate the code in the generated source if you
use a modeling pattern. If you edit more then one copy of the duplicated
code, you see all the changes that you made, but you can select only
one change to copy to the model. You can save only one change because
both changes refer to the same model element. If you try to select
more than one change, you receive an error.
- Click Apply, and click OK.
- Modify the C++ code and save your changes. The system searches
the changes to the code and, according to the preferences that you
set, might prompt you to open any affected model elements. If you
are prompted, click Yes to synchronize the
changes with the model.
- In the Code To Model Synchronization window, preview the
differences between the generated source code and the model. Double-click
an element to show a specific change.
In some cases,
the transformation can duplicate the code in the generated source
if you use a modeling pattern. If you edit more then one copy of the
duplicated code, you see all the changes that you made, but you can
select only one change to copy to the model. You can save only one
change because both changes refer to the same model element. If you
try to select more than one change, you receive an error.
- In the Code To Model Synchronization window, accept or
reject the code changes.
- To save the changes, select the changes to merge, and
click Commit.
- To return to the code synchronization window, click Cancel.
- Optional: To undo the changes that you applied
to the model, click . You can delete a code snippet but leave the user tags in the
code. In the Code To Model Synchronization window, the deleted code
appears as an empty string, and after you commit the change, the model
element is associated with an empty string. Model elements that have
empty strings are not deleted.