Book a Demo

Author Topic: getters/setters for associations  (Read 4242 times)

vezza

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • Ciao!
    • View Profile
getters/setters for associations
« on: May 06, 2005, 02:30:43 am »
I am trying EA and need to generate C++ code.
I know you can use the property settings for attributes to generate the Get/Set methods. But what about class members produced by associations? I have found no way to create setters and getters for them.
Is there a way to make this automatic?
Also, is there a general setting to tell EA to ALWAYS generate Get/Set methods for any attribute? Going on evey attribute in every class is a long operation...
Thanks a lot,
  Luca
« Last Edit: May 06, 2005, 02:43:49 am by vezza »

alexander

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: getters/setters for associations
« Reply #1 on: May 06, 2005, 06:20:07 am »
You must make the relationship 'role' as an attribute in the desired class.
Create a property with the name you wish the relationship to appear as in the class, mark it as propoerty (select the getter and setter).
Then in the relationship go to the role of the associated class and use the property you just created (it should appear in the drop down combo box).

The generator should now create the setter and getters the way you want

vezza

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • Ciao!
    • View Profile
Re: getters/setters for associations
« Reply #2 on: May 06, 2005, 07:26:00 am »
Mmm... not too sure I've got it. I seem to understand from the doc that you can only create properties for attributes. Now, an association role will be turned into a class member when generating code, but it is not an attribute; therefore I see no way of creating a property for it. What am I missing?
Can you provide a step-by-step example of how to do it?
Thanks a lot.
  Luca

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: getters/setters for associations
« Reply #3 on: May 08, 2005, 03:10:44 pm »
You're not missing anything.  That's exactly how it works.

Simon

vezza

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • Ciao!
    • View Profile
Re: getters/setters for associations
« Reply #4 on: May 09, 2005, 01:33:53 am »
Ok, thanks. So I assume that means there is no way to automatically create Get/Set methods for class members defined via associations.
Any plan to have this feature in future releases? Do you think it would make sense first of all? If not, why?
Thanks,

   Luca

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: getters/setters for associations
« Reply #5 on: May 09, 2005, 02:06:13 am »
Quote
Mmm... not too sure I've got it. I seem to understand from the doc that you can only create properties for attributes. Now, an association role will be turned into a class member when generating code, but it is not an attribute; therefore I see no way of creating a property for it. What am I missing?
Can you provide a step-by-step example of how to do it?
Thanks a lot.
   Luca


Luca,

Under UML 2, a navigable association with role IS an attribute... 8)

See the Superstructure specification in at least 2 places!

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!