Jump to Menu

How to Use C++ Round-Trip Engineering?

Visual Paradigm supports C++ round-trip engineering. It allows you to generate ANSI C++ code from UML class diagram, and to reverse engineer UML class diagram from ANSI C++ code. In this tutorial you will be given a project file, and try to generate ANSI C++ code from it. Then, make change in the code and have the UML class model updated from the code.

Compatible edition(s): Enterprise, Professional, Standard

  • June 24, 2010
  • Views: 45,282
  • PDF

Overview of this Tutorial

In this tutorial, we will show you how to perform round-trip engineering of ANSI C++ with a given project file.

In order to complete this tutorial you must have Visual Paradigm installed. You also need to have basic knowledge in UML modeling with Visual Paradigm.

Generating ANSI C++ Code from Class Diagram

  1. Download Photo-Album-CPP.vpp. You can also find this file at the bottom of this tutorial, under the Resources section.
  2. Open the downloaded project file in Visual Paradigm.
  3. Open the class diagram Photo Album. You should see the class diagram below:
    class diagram
  4. There are few ways you can take to generate ANSI C++ code - generate code from diagram, from selected classes, or for the whole project. In this tutorial let's try to generate code for the whole project. Select Tools > Code > Generate C++ Code from the toolbar.
  5. In the Generate Code window, specify the Source Path. You can specify a path by clicking on the cell and then click on the ... to popup the file chooser for selecting a folder.
    generate cpp
  6. Click OK to generate. Source files are generated to the output path specified.
    generated source files

Updating UML Class Model from ANSI C++

Once you have finished generating code, you can modify it with your IDE or with any text editor. When you've finished the modification, you can reverse the code-base back to the Visual Paradigm for an update of the UML class model. Let's have a try.

  1. Open the generated file Location.h in a text editor.
  2. Let's say we want to add two attributes for the coordinate (x and y) of the location. Let's add two private int attributes x and y.
    editing cpp file
  3. Save the changes.
  4. Let's update our UML model to reflect the change just made. Select Tools > Code > Reverse C++ Code... from the toolbar.
  5. Uncheck Reverse source on demand at the bottom of the Reverse Code window. If you keep it checked, the UML model won't be updated directly. Instead, an index tree will be formed from the source files specified in the source folder. We want our model updated, so let's uncheck it.
    uncheck reverse on demand
  6. Click OK. Now, the class diagram is updated and you should see the two private int attributes x and y added to the Location class.
    attributes added



Turn every software project into a successful one.

We use cookies to offer you a better experience. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.

OK