Book a Demo

Author Topic: C++ Code generation for aggregations duplicated  (Read 4479 times)

Ilde

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
C++ Code generation for aggregations duplicated
« on: May 08, 2009, 06:43:56 pm »
Hello

Having an aggregation between two classes: CompositeClass and AggregateClass. Let's say that Composite has 10 Aggregates (an array). I expect the generated code of the attribute be something like:

AggregateClass aggregates[10];

How is the correct way of UML modeling to get this C++ code generated.

I've created a role named aggregates[10], and get that code generated, but each time I generate the code, a new attribute exactly equal appears in the code and I have to delete it manually.

Is this a bug?, Is this behaviour because I model the aggregation in a wrong way?


This is the code I get:

class CompositeClass
{

public:

protected:
      AggregateClass aggregates[10];
      AggregateClass aggregates[10];

};

Regards.

Ilde.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ Code generation for aggregations duplicate
« Reply #1 on: May 11, 2009, 01:20:42 pm »
It's happening because EA is looking for an attribute named 'aggregates[10]' in the code.  It doesn't find one (because it finds 'aggregates').

Ilde

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: C++ Code generation for aggregations duplicate
« Reply #2 on: May 12, 2009, 08:04:22 am »

I see, but is there a workaround or should it be reported as a bug?

Regards.

Ilde.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ Code generation for aggregations duplicate
« Reply #3 on: May 12, 2009, 09:49:18 am »
Don't include the array definition in the name.  You may only be able to generate that code from an attribute instead of an aggregation.

Ilde

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: C++ Code generation for aggregations duplicate
« Reply #4 on: May 13, 2009, 12:25:11 am »
I know that using an attribute with "Attribute is a Collection" checked in Attibute Detail Tab, and Container Type : aggregates[10] is a way to generate that code.

But shouldn't container type property be supported in aggregation roles too?

I know I can use the attribute, but the way I model an UML class diagram class shouldn't be forced by the code generator.

So, taking in account there is no other way to re-generate the role without duplicating it, I think it should be considered as a bug, don't you?

Regards.

Ilde.