External Libraries
You can import existing libraries into Enterprise Architect, so you can use them in class diagrams to add dependencies, or to use functions of these libraries in your behavioral models.
This is perfect for integrating legacy code into your application, and also if you're doing split development (one part model-based, one part classical). Before you import your libraries into the model, make sure that you've disabled Object Oriented Support
for C under Tools
Options...
, since this will result ony in a typedef
of the class without any operations or attributes present.
To import the external C libraries into Enterprise Architect, go to Tools
Source Code Engineering
Import C-Files...
and select the libraries you want to import.
The libraries will be imported as classes, but you want them as interfaces instead. To change their type, select the imported classes and go to Element
Advanced
Change Type...
where you can change them to Interfaces. Now you can use the imported operations in your model.
To include references to the libraries in your code, use the Dependency or Usage relations from your class to the interface.
Check
When importing headers with functions, make sure to mark the imported interface as static as described in Classes.
Info
When setting the stereotype standard lib on an external library the code generation will generate a standard library include.
#include <string>
#include <string.h>
contrary to normal include containing the ".h" extension
Warning
Don't put the imported libraries into the package for which you generate code, otherwise Embedded Engineer will generate code for these interfaces as well! Put them somewhere else where you can keep a good overview on your imported interfaces.
If you have to have them in the package, mark them with the NoCodeGen
tagged value as described here.
See also