Introducing variants

Overview of variants

Variants are used to implement and/or customize advanced code generation from a UML model.

This chapter covers the concept of code generation using variants, the syntax of templates, type libraries and other elements, and common techniques used to make the most of the flexibility and customization capabilities of the C++ Designer engine.

Concepts

The C++ Designer engine is based on the following concepts:

Variant’s content example

A variant has a specific directory organization, to make the customization easier. The following image shows the content of the standard variant.


Standard variant content

The “acts” directory groups together all active code templates, the “products” directory contains product definition files, and the “types” directory contains all type libraries.

The “description.txt” file is mandatory, and must contain the variant’s description, which will be displayed at runtime when choosing the current variant for a project.

A variant may redefine only part of the module’s behaviour, as the standard behaviour will be taken into account in other cases.

Note: An empty “__init__.py” file must be created in a variant in order for python ACTs to work correctly.