Book a Demo

Author Topic: Code Template Framework Help  (Read 2947 times)

MikeOrmerod

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
  • Simplyfying building the worlds best biz apps
    • View Profile
Code Template Framework Help
« on: February 03, 2005, 02:16:48 am »
Hi

I'm currently in the process of adding a new language to the CTF.  All is working well in terms of code generation for single classes.  Now, for the language I'm generating, I've added a new stereotype for a Dependency link.  What I'd like to be able to do is based upon a link of this type, generate certain code statements.  Now I'm not sure if I'm in the right place but I've been playing with the LinkedAttribute, LinkedClass Base etc, but I can't seem to determine if this is the right place.

So in a nut shell, if I have a dependency between two classes  of a certain stereotype I wish to generate some code, any ideas how I do this?

Many Thanks

Mike

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: Code Template Framework Help
« Reply #1 on: February 03, 2005, 02:21:20 pm »
Hi Mike

Using stereotypes and or tagged values on the link to achieve this kind of customization would be ideal, but is not currently possible in the code templates - we're working on it though.

If you can get away without the stereotype info, then the following may of help :

Quote
There is a way to make EA generate include files from dependency links - though it involves some customization of EA's default code generation templates for C++ (see the help file for details on doing this).

Basically you can replace EA's default ImportSection template with the following:

$includes = %fileImports% + %list="Import__Dependency" @separator="\n"% %REMOVE_DUPLICATES($includes, "\n")% \n

Then create a new custom template called "Dependency". Its contents might be as follows :

%if importFromDependency == "T"%
$file = "#include " + %qt% + %importClassName% + ".h" + %qt% $file %endIf%


Otherwise, you may wish to invoke the automation interface from within the code templates to overcome the limitation. See the related threads:

http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.cgi?board=general;action=display;num=1088595585;start=3#3

http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.cgi?board=Automation;action=display;num=1094146636

(In your case you would be using the automation interface to iterate over the class' connectors.)

I hope this helps.

Regards,
Ben

MikeOrmerod

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
  • Simplyfying building the worlds best biz apps
    • View Profile
Re: Code Template Framework Help
« Reply #2 on: February 04, 2005, 01:38:10 am »
Thanks Ben

I'll ahve a play and see how I get on with the workaround you suggested, otherwise yes I may have to look at the automation stuff.

Mike

MikeOrmerod

  • EA Novice
  • *
  • Posts: 7
  • Karma: +0/-0
  • Simplyfying building the worlds best biz apps
    • View Profile
Re: Code Template Framework Help
« Reply #3 on: February 09, 2005, 02:36:45 am »
Ok,

I've used the sample code provided (Thank you) and now have my code generating include file definitions.  My next question is to whether or not it is possible to determine the stereotype of the dependency link. Again I've tried the linkStereotype but that just comes back as blank.  I need this because although I can now output the class name as an include, I wish to vary my output slightly depending on the type of dependency.

Cheers

Mike