Book a Demo

Author Topic: Class1 : public Class2<int>  (Read 3903 times)

llavayssiere

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Class1 : public Class2<int>
« on: February 17, 2007, 03:26:49 pm »
How to generate the following C++ line of code with a class diagram :

Class1 : public Class2<int>

I found no way to generate this C++ code without creating an intermediate typedef class for Class2<int>. Perhaps C++ templates code generation must be modified ? In general, with EA, template binding relationships is not giving satisfaction for C++ generation code.

AdamC

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Class1 : public Class2<int>
« Reply #1 on: February 19, 2007, 12:19:57 am »
I find the easist way when you are stuck like this is to enter the code and then reverse engineer it.

In your case the code was(I think)

template < int o_int >
class one
{
   one();
};


class two : public one < 7 >
{
   two();
};

When you import this class one's detail tab has the templates section set to paramitised and the int o_int specified.

When you look at class two the detail tab has the template section set to instatiated and the value "7" set in the Arguments text box

llavayssiere

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Class1 : public Class2<int>
« Reply #2 on: February 19, 2007, 01:44:02 am »
Effectively, i tried to know how to generate C++ code with the reverse engineering functionnality of EA. In this case, reverse engineering works well, but only for 1 inherited class. For example, if you tried to reverse the following code :

template <class T> class Class1 {};

template <class T> class Class2 {};

class Class3 : public Class1<int>, Class2<float> {};

Enterprise architect create 1 generalization link between Class3 and Class1 and 1 generalization link between Class3 and Class1 but only 1 argument (float argument) appears for the instantiated template parameters of Class 1. Multiple inerited links are not taken into account with EA in case of inherited template classes. Arguments for instantied template should be associated with the generalization link. The actual management of instantiated template arguments works only for Java (no multiple ineritance) and not for C++.

sl@sh

  • EA User
  • **
  • Posts: 85
  • Karma: +0/-0
    • View Profile
Re: Class1 : public Class2<int>
« Reply #3 on: June 18, 2007, 06:36:40 am »
*bump*

I ran into a problem that is closely related, i. e. a class that is both derived from a templated class and a 'normal', non-templated class:
Code: [Select]
class A {};
template <int i> class B { double values[i]; };
class C : public A, public B<3> {};


When I import the relevant code the template initialization argument list correctly shows the instantiation parameters used for the inheritance of the templated class.

However, nowhere in the class details is any reference to the base class these initializers refer to! As a result, when I regenerate the code, the initializers also get inserted to the non-templated class:
Code: [Select]
class A {};
template <int i> class B { double values[i]; };
class C : public A<3>, public B<3> {};


Is this already officially reported as a bug, or perhaps even fixed in EA 7.0?

Is there a way to suppress the faulty code generation (shown above) whenever I regenerate the code because of changes in the model?