Model level creation operations

The first step in this tour is to create the model shown in figure below, by first creating the "My planner" package inside the root package, and then the "Task management" package inside the "My planner" package.

image
The model you are going to build

We are now going to continue by designating the main entities of our application (Project, Task, Human Resource and Person), and the relationships between these entities.

Let’s create a class to represent, for instance, projects.  For this, create the "Project" class in the "Task Management" package.

image
Creating the "Project" class in the "Task management" package

Steps:

  • Select the "Task management" package.

  • Open the contextual menu, and expand the "Create UML Element " sub menu.

  • Click on the image "Class" icon.  The new class then automatically appears.

  • Enter the name "Project".

Cxx does not provide automatic memory management and garbage collecting features, and its syntax does not permit the initialization of class members in declaration points. In most cases, you have to manually specify the creation and destruction semantics of your classes by writing constructors, destructors, and so on.

In order to avoid you forgetting creation operations for your objects, and to explicitly represent creation semantics at model level, Modelio Cxx Designer automatically constructs UML creation operations when a class is created in the model.  Modelio Cxx Designer follows best Cxx practices and uses a design pattern to create the so-called "Coplien form":

  • The default constructor

  • The copy constructor

  • The assignment operator

  • The destructor

image
Automatically constructed creation operations

For each operation, Modelio Cxx Designer automatically creates Cxx notes with "TODO" comments, suggesting that you provide their Cxx implementation.

This model level pattern is dynamic, meaning that when you rename a UML class, its creation operations are renamed automatically.

image
The names of the creation operations are automatically modified when the class name is modified
First Cxx generation

To generate Cxx code from the application model, select the element to generate and click on the image "Smart generate" button in the Cxx property view.

image
Launching Cxx code generation using the button in the property view

If you have not created your own build project, Modelio Cxx Designer automatically creates a default build project.

The default build project manifests the whole model, meaning that all model elements (except those marked by the "No Code" flag) are translated.

Its Cxx code generation target uses the type library, compilation platform, output directories, header and body file extensions specified by Modelio Cxx Designer parameters.

Its doxygen documentation target uses doxygen options and output directories specified by Modelio Cxx Designer parameters.

Its compilation target uses makefile and compiler options specified by Modelio Cxx Designer parameters.

Note: Default Cxx code, documentation generation and compilation options must be defined using Modelio Cxx Designer parameters, before using it for the first time.