Book a Demo

Author Topic: Custom Function Code Generation (C++)  (Read 3208 times)

jasen

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Custom Function Code Generation (C++)
« on: April 25, 2014, 06:36:02 am »
I've done a little with the custom code generation but
I would like to find an example or get some help creating a custom code generation template which creates a function body with one function call for each attribute in the class.
For example maybe the function registers each attribute of the class with a Blackboard object. Thus the final generated code maybe

Class foo
{
Public:

Double      m_my_value1;
Double      m_my_value2;

….

Void Fn()
{
// I want to autogenerate this code below in the function body
M_blackboard.Add(“Double”, m_my_value1);
M_blackboard.Add(“Double”, m_my_value2);

}

Any ideas is it possible with EA?

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Custom Function Code Generation (C++)
« Reply #1 on: April 25, 2014, 02:01:02 pm »
YOu can look at the C# Transformation templates and see how a Property is created for each attribute (Public)

The approach will be
1. Add a new Custom Template of type Attribute (e.g. Attribute__mymethod)
2. Write your logic in the new template.
3. call this for all attributes using %list%, e.g. %list="Attribute__mymethod" @separator="\n" @indent="  " %


jasen

  • EA Novice
  • *
  • Posts: 6
  • Karma: +0/-0
    • View Profile
Re: Custom Function Code Generation (C++)
« Reply #2 on: April 29, 2014, 07:12:07 am »
Wow this worked great. Thanks so much for the help!