C++ roundtrip

The C++ code roundtrip is a plug-out directly written in C++

The C++ code roundtrip updates from sources the classes of the model, add missing ones and remove useless classes (after confirmation). If you use Bouml to generate C++ code it is not recommended to also use the C++ roundtrip because you will loose preprocessing forms and C functions and other forms not representable in UML. The roundtrip is mainly dedicated to update a model used for documentation purpose.

The behavior of the C++ code roundtrip plug-out depends on the kind of the element it is applied :

The sources read by the C++ code roundtrip are the ones having the extension specified in the generation settings. The tree formed by the directories and sub-directories produce an equivalent tree of sub-packages, on whose the needed class view and artifact view are made to support the classes and artifacts. The preprocessing phase is not made by the C++ code roundtrip whose ignore all the preprocessor forms, but some substitutions may be asked, see at the end of this chapter.

The reverse/roundtrip setting dialog of the modeler allows to specify through regular expression the files and / or directories whose must not be taken into account during a reverse and roundtrip, for instance to bypass test programs.

Obviously the C++ code roundtrip tries to produce the definitions made in BOUML at the artifact / class / operation / relation / attribute levels. When it is possible it creates a relation rather than an attribute.

Except for the special case of the templates class definition like vector<bool>, a artifact is created for each type definition, then a future C++ code generation may not produce a list of files similar to the reversed ones.

A C function cannot be specified in UML, the C++ code roundtrip loses them (generating a warning) except the ones declared friend in a class.

The C++ code roundtrip works in four steps, during the first step all the project is upload, in the second step the elements to roundtrip are prepared, in the third step it scans all the files to establish the list of defined types, then the last step may roundtrip/reverse the files. The third phase tries to replace the missing #include management, but it is not enough because the files whose are not under the selected directory (for instance the standard headers files !) are never taken into account and the synonym types are confusing.

The trace window is used to indicate the steps, the updated classes and possible problems for instance when it reads a C function definition it produces a warning in the trace window. The trace window is automatically opened by BOUML, it may also be manually opened through the Tools menu.

To do simple substitution on the read files : edit the project (top level package) to add a user property (through the tab 'Properties') with the key #file and the value must be the absolute pathname of a file. Each line of the specified file must contain :

Warning : the lines must not contains spaces or tabs.

Previous : C++ reverse

Next : C generator