Skip to content

Dependencies

Include

Import/Usage

To specify dependencies between classes or to external libraries, add the existing classes to a class diagram and import external libraries into your model first.

Info

You can also use packages with use dependencies.

  • Whenever you model a Usage from a Package to a Class, it means that every Class in the package has a Usage to this Class.
  • When you model a Usage to a Package, it means that every Class in the Package is included.

You can now specify dependencies, by using either Dependency or Usage connectors between these elements. Code generation will add the appropriate include directives to the generated classes. Dependency

By applying the stereotype global to a Usage connector the include directive will be generated with brackets instead of quotes.

#include <test.h>

#include "test.h"

Include storage generation

You can influence to where the include shall be generated by changing the Generate includes in .c file Setting or by using the IncludeStorage Stereotype and the Storage tagged value.

The new IncludeStorage feature can be used on Packages, Class and/or Usage links.

Child or nested elements will inherit the Storage set from its parent but can be overwritten anytime. The IncludeStorage/Storage tagged value can also be directly used on a Usage links.

The current implementation will use the following generation strategy:

  • The generation file will be determined if the IncludeStorage stereotype and Storage tagged value is set in either Package, Class or use link.
  • If this is not set, the Generate includes in .c file Setting is used.
  • Otherwise/by default all includes will be generated into the declaration file (.h).

Order of dependencies/includes

By default, the dependencies are ordered as they are read from your Model. Usually the order is by date of creation, so the first dependency you model will also be the first dependency #include line in the generated source code.

To alter this behavior, you can name your dependencies. They will be sorted by their name alphanumerically from lowest to highest. In case of two dependencies with the same name, the internal ordering of your model is used:

Dependency Dependency

You can also use the Order usings feature implemented in the diagram menu to help you see all the Usages linked to the current element and how they are ordered.

Dependency

Realization

You can also use Realization dependencies between a class and an interface to implement the Interface in a class:

Dependency

In this example, the class Mouse realizes the interface MouseHandler. In this case, the following files will be generated by Embedded Engineer:

File Content
Mouse.c Contains the implementation of Mouse class.
Mouse.h Contains the function declarations for the Mouse class, except for the HandleMouse function
MouseHandler.h Contains the function declaration for the HandleMouse function

Because of the realization relation from Mouse to MouseHandler, the declaration of the realized function is used from the interface.

Info

This also means that the name of the HandleMouse function will not be altered when generating code for the Mouse class. See Operations - Naming for more information.

Example

To create a realization and implement the functions of an existing Interface use the Realization link.

Dependencies

After this you will get the Overrides & Implementations dialog where you can select the operation for implementation.

Dependencies

This will result in a new operation with two Implementation Tagged Values which link the Operation inside the Class with the Interface.

Dependencies

Info

These Implementation Tagged Values are needed to flag the Operation so that it will keep its name/signature during code geneartion.

To create a realization and implement the functions of an existing Interface use the Realization link.

Dependencies

After this you can "reuse/copy" the needed function via dragging/dropping it with the Ctrl key pressed, into the Implementation Class.

Finally you will need to set the "Redefined Operation" of the Implementation Operation to refer to the original Interface Operation.

Dependencies
Dependencies