Sparx Systems Forum
Enterprise Architect => General Board => Topic started by: dandrus on December 22, 2016, 07:31:41 am
-
I am new to EA but have spent weeks reading the excellent documentation. My goal is to extend the C++ code generation to directly generate code that can link with our existing virtual platform libraries/framework/patterns. I was encouraged at first by the Code Template Editor and the promise from the documentation that it was "fully configurable", but am now stuck.
Specifically, I want to modify the templates involved in statemachine generation. I found this page (http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_domains/codegen_macros_execstm.html) which lists all the templates, but how do I edit them? The code output in the EventProxy even has a message suggesting this is possible...
// You can customize the template "Stm Signal Attribute Assignment" to generate initializer for "xyz"
As a side note, the documentation doesn't explain the relationship between the template substitution macro names e.g. %ClassBody% and the template names listed in the editor e.g. "Class Body". Was whitespace just added for readability? If so IMHO this creates more confusion than clarity.
-
Go to Package/Code Engineering/Code Generation Templates (in a pre-13 version). Don't ask me where the ribbon did put it.
From my experience you should no put too much effort in coding via EA. Code is better handled in an IDE. Use EA to design and implement an interface so your programmers get the idea and can code.
q.
-
As I understand it, all the listed templates are 'standard' or system-supplied templates. You can't edit standard templates themselves. You can, however, use them as the base for your own customized templates.
Basically, the template editor helps you create and edit your own templates, largely based on copies of the standard templates.
The ribbon path is 'Code > Source Code > Configure > Code Template Editor'.
-
Thank you both for your replies. I am familiar with the Code Template Editor and the base templates. This page of the EA User Guide (http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_domains/codegen_macros_execstm.html) describes the templates that perform the guts of the executable state machine code generation, and none of these are visible from the Code Template Editor that I can see.
When generating executable state machines EA produces extra "framework" files that implement a base class StateMachineContext and a companion file EventProxy.cpp. I want to modify the templates that generate these files. The EA developer who created these templates output a comment that appears in EventProxy.cpp where they haven't finished the template:
// You can customize the template "Stm Signal Attribute Assignment" to generate initializer for "xyz"
implying that these templates (http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_domains/codegen_macros_execstm.html) are user editable, but I don't see how.
The question of whether I should even be attempting to do this is another matter for which I will start a separate thread.
Thanks again!
Don
-
Well, some of the things listed on that page are templates, and some are MACROS. And unfortunately that is the only intelligent thing I can say about any of them. I will track down the person who looks after them and see what he suggests.
-
Make a copy of the templates (since they are what their names says) and work on your own copies.
q.
-
I found the templates in the Code Template Editor under Language: STM_C++_Structured