Book a Demo

Author Topic: Can EA support templated collections?  (Read 3218 times)

andylarder

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Can EA support templated collections?
« on: September 11, 2003, 02:45:10 pm »
Hi,

I'm in the process of evaluating EA, and cannot at the moment generate code or reverse engineer for the types of collection and references I use.

For instance (simplified):

class Object
{
   ...
};

typedef Reference<Object> ObjectRef;

class ContainingObject
{
   ...
   vector<ObjectRef> objects;
};

I need the above to be correctly round-tripped - is this possible?

Cheers,
Andy.

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: Can EA support templated collections?
« Reply #1 on: September 11, 2003, 08:40:45 pm »
Hi Andy,

When reversing something like:
vector<ObjectRef> objects;

EA creates a class attribute with type set to: vector<ObjectRef>

So if you're round-tripping, create your stl collection based attribute in the same way, ie. specify the template container as part of the class attribute type.

If you are only forward generating, there are alternative ways to achieve this, using the Attribute | Details dialogue in combination with EA's code generation templates.

Also note: typedefs are currently ignored by the c++ import facility.

Let us know how you get on.

Regards,
Ben

andylarder

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Can EA support templated collections?
« Reply #2 on: September 12, 2003, 01:41:36 am »
Ben,

I can see what you are saying, but surely this means the 1 to many relationship that exists does not appear on the model? What I need is some way of reverse engineering the code above into a correct and full class model. Then after drawing some more one to many relationships, have them generated using the code above.

Andy.

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: Can EA support templated collections?
« Reply #3 on: September 14, 2003, 05:55:56 pm »
Hi Andy,

That's right- "objects" would be modelled as an attribute with cardinality 1 and be of type "vector<ObjectRef>".  I believe this is correct, but as you say, the 1-many aspect of the "objects" attribute is not explicitely modelled.

In short, STL collections are not reversed as EA collections.

Sorry I can't be of more help at this stage.

Regards,
Ben