Book a Demo

Author Topic: reverse engeneering of vector in C++  (Read 5268 times)

jorn

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
reverse engeneering of vector in C++
« on: December 20, 2004, 05:09:52 am »
Is it possible to reverse engeneer C++ code which use catainers like list or vector and get the correct assosiation in EA ?

  using namespace std;  
  vector <myClass> class1;
  vector <myClass>::iterator Iter;

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: reverse engeneering of vector in C++
« Reply #1 on: December 21, 2004, 01:33:20 pm »
EA won't create an association unless you have in your model a class called "vector <myClass>" but it should set that as the type of the attribute without any problem.

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: reverse engeneering of vector in C++
« Reply #2 on: December 21, 2004, 11:29:27 pm »
I got similar questions from my developers.
this is rather problematic.is it posible to make EA recognise STL containers (by creating some kind of profile maybe)?

also I would like and Idea of how to model such a list.

Thanks!
Recursion definition:
If you don’t understand the definition read "Recursion definition".

jorn

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: reverse engeneering of vector in C++, code ...
« Reply #3 on: December 22, 2004, 02:41:00 am »
Here is an example.
I would expect a visual assosiation when reverse engeneered.

#include <vector>
#include "MyClass.h"

using namespace std;  

class MyContainer
{
public:
 MyContainer(void);
 virtual ~MyContainer(void);

 vector <MyClass> v1;
 vector <MyClass>::iterator Iter;

};


class MyClass
{
public:
 MyClass(int startValue);
 ~MyClass(void);

int _myValue;
};

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: reverse engeneering of vector in C++
« Reply #4 on: December 22, 2004, 11:21:26 pm »
no answer from Sparxs?
Recursion definition:
If you don’t understand the definition read "Recursion definition".

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: reverse engeneering of vector in C++
« Reply #5 on: December 23, 2004, 01:37:24 pm »
You example isn't clear as to what you are actually expecting, but I'll take a stab and guess that you want two association links from MyContainer to MyClass?

The simple answer is that EA's reverse engineering can't do that for you.

However, you are able to model it so that it will be generated like that.

Create your two classes and two association links between them.  Open the properties of MyClass and in the detail tab click on "Collection Classes".  (Alternatively you could do this for all C++ classes by default in Tools | Options | Generation | C++ Specifications | Collection Classes)  In the "Default Collection Class" field type vector<#TYPE#> and in the "Collection Class for Ordered Multiplicity" type vector<#TYPE#>::iterator.

Then edit the target role of your two links.  In one set the role to "v1" and the multiplicity to "1..*".  In the other set the role to Iter, the multiplicity to "1..*" and check "Multiplicity is Ordered".

When you generate that code you will get what you want.  For more information please look as "Setting Collection Classes" in the help.

Simon

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: reverse engeneering of vector in C++
« Reply #6 on: December 26, 2004, 12:15:54 am »
it wasn't exactly what I expected.
this is what I modeled by your instructions:


this is the code I got:


class Myiterator
{

public:
Myiterator();
virtual ~Myiterator();
vector<Myclass> *v1;

};
it is not an iterator, just a wraper class.

class Myclass
{

public:
Myclass();
virtual ~Myclass();
vector<Myiterator>::iterator *iter;

};

the vector shouldnt be from class iterator...

have I done somthing wronge?
Recursion definition:
If you don’t understand the definition read "Recursion definition".

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: reverse engeneering of vector in C++
« Reply #7 on: December 26, 2004, 01:50:07 am »
got my mistake..... :-X
Recursion definition:
If you don’t understand the definition read "Recursion definition".

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: reverse engeneering of vector in C++
« Reply #8 on: December 29, 2004, 09:26:20 pm »
Does that last post mean you got it to work?

Martin Terreni

  • EA User
  • **
  • Posts: 672
  • Karma: +0/-0
  • Sorry, I can't write
    • View Profile
Re: reverse engeneering of vector in C++
« Reply #9 on: December 29, 2004, 10:14:33 pm »
sort of...it works fine for code generation, but when i reverse-engineer the generated code it doesnt recognize any connection between them.

I think this is what you answered avobe, a pitty...
« Last Edit: December 29, 2004, 10:15:50 pm by MartinT »
Recursion definition:
If you don’t understand the definition read "Recursion definition".