Book a Demo

Author Topic: Code Generation Get Set Constructor De~  (Read 3481 times)

Ralph Mücke

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
  • I havn't done it.
    • View Profile
Code Generation Get Set Constructor De~
« on: February 02, 2007, 06:35:11 am »
Hi, I'm just trying to do something with the code generation of EA 6.5.803.

I generated two classes and an association between them. OK, that fine. (That's also fairly simple)

I tried to implement in the code generation templates the corresponding get and set function for the member variable to access the other class.

Furthermore I tried to improve the constructors and destructors of classes by initializing member variables.

If I model e.g. int index is initialized to zero, then this is just in the model and not in the code.

Do I expect too much? Can I do this on my own? If yes, how?
:-/

Best Regards Ralph
--
Best Regards Ralph

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Generation Get Set Constructor De~
« Reply #1 on: February 04, 2007, 01:10:45 pm »
You should be able to modify the templates in the ways you mentioned.  What language are you using?

Ralph Mücke

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
  • I havn't done it.
    • View Profile
Re: Code Generation Get Set Constructor De~
« Reply #2 on: February 04, 2007, 11:44:49 pm »
Hi Simon,

modifying the templates seem to be the way.

I'm using C++ and C.

Is there a usable description available too?

I'm using 6.5.803

Thanks
Best Regards Ralph

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Generation Get Set Constructor De~
« Reply #3 on: February 05, 2007, 01:14:36 pm »
Documentation for code templates is at http://www.sparxsystems.com.au/EAUserGuide/index.html?codetemplates.htm.  You'll need to use custom code templates (http://www.sparxsystems.com/EAUserGuide/index.html?customtemplates.htm).

First create a custom template of type Attribute called Impl (The name could actually be anything).

You can list over this template in the Class Body Impl template by calling the following list.

Code: [Select]
%list="Attribute__Impl" @separator="\n" @indent="" attStatic=="T"%
The basis for this template would be something like the following.
Code: [Select]
%PI=" "%
%attQualType%
%PI=""%
%classQualName%::%attName%
%attDefault ? " = " value%
;

You'll need to extend that for non-primitive types yourself.  A similar list where default constructors are generated in the Class Body Impl template could be used to add initialisation for those members.  This is normally handled by the "initializer" tag when constructors are modelled, although there isn't anything to stop you from overwriting this.

The attributes are generated from associations in the Linked Attribute template, so look there to generate properties.