Book a Demo

Author Topic: Understanding Collection classes  (Read 3497 times)

StephaneGuerin

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
  • humm....
    • View Profile
Understanding Collection classes
« on: October 25, 2005, 05:46:52 am »
I have to following code in C++:
Code: [Select]

class MyObject
{
public:
  MyObject()  {  };
};

public class MyObjectContainer
{
public:
 ArrayList *m_MyObjectList;  // This is a dynamic array of LoadedComponent
};


When I reversed engineer it,  EA created an attribure m_MyObjectList in class MyObjectContainer.  I did not expect the system to "guess" the relation between ObjectContainer and MyObject.  However, I would like to specify manually to the system to treat m_MyObjectList as a collection of MyObject.  I would like also to keep that relation after my next reverse engineering import.
Can somebody clarify how this is suppose to work?  I'm a little bit loss right now.

Thank you!

Stephane Guerin

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Understanding Collection classes
« Reply #1 on: October 25, 2005, 11:06:04 pm »
You can set up ArrayList as the default collection class for C++.

That means that EA will generate the appropriate thing from a 1..* association to MyObject, and the association also won't be deleted on subsequent reverse engineering.

StephaneGuerin

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
  • humm....
    • View Profile
Re: Understanding Collection classes
« Reply #2 on: October 27, 2005, 07:05:05 am »
So, if I understand well:
- Reverse engineer will create an Attribute for me (m_MyObjectList in my case).  The Type of the attribute is going to be the container type (ArrayList in my case)
- I need to manually add an Association between my class.  The Target role of this association should have the same name as my Attribute (m_MyObjectList).  The member type of the Target role should be the container type (ArrayList).

Did I get it right?

Thank you

Stephane Guerin

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Understanding Collection classes
« Reply #3 on: October 27, 2005, 03:39:34 pm »
Well, sort of.

You also need to set a multiplicity of > 1 to use any collection class.

There are other collection classes that you can set.  For each language, and each class you can set different collection classes for default, ordered and qualified multiplicity.

I was originally just talking about the language level collection classes.

See http://sparxsystems.com.au/EAUserGuide/index.html?settingcollectionclasses.htm for more information on how to set each collection class and when they are used.

StephaneGuerin

  • EA Novice
  • *
  • Posts: 12
  • Karma: +0/-0
  • humm....
    • View Profile
Re: Understanding Collection classes
« Reply #4 on: October 28, 2005, 04:29:55 am »
Ok, thank you.  That's more clear now.