Book a Demo

Author Topic: Generate Multiple Files  (Read 4831 times)

TomPre

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Generate Multiple Files
« on: October 17, 2006, 02:59:40 am »
Hi I'm currently playing around with the C code template and wanted to know if it is possible to generated multiple source and header files using stereotypes. For example attributes and operations without a stereotype will be generated in a "modulename.h" and "modulename.c". Attributes and operations with the <<cfg>> stereotype will be generated in a "modulename_cfg.h" and "modulename_cfg.c" and so on.
If someone could help me with this I would be very thankful.

Tom

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Generate Multiple Files
« Reply #1 on: October 17, 2006, 03:02:11 pm »
It currently can't be done by the code templates directly.

Something that you could consider that may help you is using a transformation to separate the single class into multiple classes.  You'd have in your class template something like the following.

Code: [Select]
Class
{
 %TRANSFORM_CURRENT()%
 %TRANSFORM_REFERENCE("Class")%
%list="Attribute" @separator="\n" attStereotype!="cfg"%
%list="Operation" @separator="\n" opStereotype!="cfg"%
}

Class
{
 %TRANSFORM_CURRENT("name")%
 %TRANSFORM_REFERENCE("cgf")%
 name=%qt%%className%_cgf%qt%
%list="Attribute" @separator="\n" attStereotype=="cfg"%
%list="Operation" @separator="\n" opStereotype=="cfg"%
}

This way when you generate the two classes that result from this transformation you get the files that you want.

TomPre

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Generate Multiple Files
« Reply #2 on: October 17, 2006, 11:40:43 pm »
Thanks a lot for the answer!  ;D

TomPre

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Generate Multiple Files
« Reply #3 on: October 19, 2006, 05:13:50 am »
Another question: Is it possible to reverse the transformation(merge the generated classes)?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Generate Multiple Files
« Reply #4 on: October 19, 2006, 03:16:56 pm »
It is, but you'll need to call an addin from the templates to look up the second class.  Additionally EA doesn't support reversible transformations so it won't synchronize with your original classes.

You could still do it though.  You would just need to add an entry into the t_xref table that matches the ones created by the TRANSFORM_REFERENCE macro.
« Last Edit: October 19, 2006, 03:17:25 pm by simonm »