Skip to content

CPP Code Generation

Dániel Segesdi edited this page Jul 2, 2015 · 15 revisions

Usage

Note: If you are generating CPP code from the UML model, the model elements should be in a component, because the codegeneration runs only on components.

From Papyrus editor

  1. Open the UML diagram in papyrus
  2. Right click on the blank area in the editor and select Generate CPP code for selected UML model

From xtuml editor

  1. Use the UML-Integration to generate xtUMLrt model from UML
  2. Open the xtUMLrt model (with Sample Reflective Ecore Editor)
  3. Right click on any XTComponent and select Generate CPP code for selected XTComponent

After the code generation

PingPong example model

If you have generated code from the PingPong example UML model you can follow these steps to build and run the generated cpp code:

  1. The code snippets for the XTClasses will be generated into an emdw-cpp-gen folder next to the model file
  2. The snippets can be copied to the prepared C++ project found in tests/Test_Ping_Pong
  1. Delete the contents of the /Test_Ping_Pong/model/emdw-cpp-gen directory if it exists.
  • It contains the generated code which can cause compile errors
  1. Compile and run the code to see trace information on the standard output

Test_FSM example model

If you have generated code from a single class containing a statemachine you can follow these steps to build and run the generated cpp code:

  1. The code snippets for the XTClasses inside the XTComponent will be generated into an emdw-cpp-gen folder next to the model file
  • If the model is not in the workspace, a new project called com.ericsson.emdw.cpp.generated.code is created and the snippets are saved under a folder with the same name as the model file (e.g. model.xtuml)
  1. The snippets can be copied to the prepared C++ project found in tests/Dummy_StateMachine
  • Insert the content of the generated files between the // GENERATED CODE START and // GENERATED CODE END comments of TEST.cc and TEST.hh in Test_FSM/Main_Package/Test_Component
  • Note that you will have to edit Test_FSM.cc and Test_Package_decl.hh if your XTClass is not called TEST. Additionally you have to edit the namespaces and the fully qualified names if the class is not in the ::Test_FSM::Test_Component::Test_Package namespace.
  1. Compile and run the code to see trace information on the standard output

Example models

You can find a simple example that contains a single TEST class here.
You can find the PingPong example model here You can find more example models here

Clone this wiki locally