Book a Demo

Author Topic: template binding  (Read 5695 times)

llavayssiere

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
template binding
« on: February 10, 2006, 09:05:35 am »
How to realize a template binding with EA? It's easy to create a Parameterized Classes but i not found how to create a template binding (dependency link with <<bind>> stereotype is not appropriate) or a bound class or anonymous bound class as specified in the UML 2.0 Superstructure OMG Document.

llavayssiere

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: template binding
« Reply #1 on: February 10, 2006, 10:01:19 am »
more precisely, i just want to model the following C++ classes :

template <class T> class A
{
  T* m_t;
};

class B : public A<C>
{
};

No problem to model the class A with parameterized classes functionnality. But how to easily model the class B and the association link (m_t) between the instantiated template class A<C> and the class C (C replaces the template) parameter T).


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: template binding
« Reply #2 on: February 12, 2006, 01:20:12 pm »
A can be modelled by creating a class.
Opening the class properties to the default tab.
Setting the type to Parameterised.
Adding a single parameter T with type class.

B can be modelled by creating a class.
Create a generalization to A.
Opening the class properties to the default tab.
Setting the type to Instantiated.
Entering C in the arguments field.

llavayssiere

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: template binding
« Reply #3 on: February 13, 2006, 02:15:20 am »
I have already modeled A and B setting type to parameterised  for A and setting type to instantiated for B with the required parameters and with a generalization link between A and B.  But the UML 2.0 Superstructure OMG Document give a template binding example with a <<bind>> link follwed with the parameters to be bound to the template parameters or with an anonymous bound class (chapter 17.5.4, figures 17.19 and 17.20). I have not found how to model this <<bind>>. I just found a dependency link with <<bind>> stereotype, but attributs and methods are not inherited with such a link (line type (dashed line) is conform with UML 2.0 but arrowhead is not conform (should be a generalization arrowhead)). A realization link can also be used with a stereotype <<bind>> but this is the same problem : line type and arrowhead are conform with UML 2.0 but attributs and methods are not inherited. And if a generalization link with a <<bind>> stereotype is used to model the template bindind functionnality, attributs ans method are inherited but line type is not conform with UML 2.0 (should be dashed line).

I have also another problem to model the association link between instantianted template A<C> and C class. I think an association link should appear between the class C (T is substituted with C for the m_t attribut) and the instantianted template A<C>.


Tuser

  • EA User
  • **
  • Posts: 45
  • Karma: +0/-0
  • So much stuff to do, so little time...
    • View Profile
Re: template binding
« Reply #4 on: February 13, 2006, 07:58:33 am »
Use a 'Role Binding'.

Create a collaboration diagram with the parameterized class A inside.

Then create a class B and make a 'Role Binding' association, 'pointing' from B to A.
« Last Edit: February 13, 2006, 07:59:13 am by Tuser »

SF_lt

  • EA User
  • **
  • Posts: 216
  • Karma: +1/-0
  • The Truth Is Out There
    • View Profile
Re: template binding
« Reply #5 on: February 13, 2006, 08:50:25 am »
actually, I would place dependency from B to C, as A is only a template

Personally, I'm not sure, if I agree with the OMG's notation for your A and B classes example. Realization and generalization are not interchangable - these are different for me

I summon Paolo and Jeshaw2 for this issue  ;D
« Last Edit: February 13, 2006, 08:50:54 am by SF_lt »
registertm everything to SparX

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: template binding
« Reply #6 on: February 13, 2006, 08:59:01 am »
Quote
I summon Paolo and Jeshaw2 for this issue  ;D
You make us sound like the forces of darkness...  :-X

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

SF_lt

  • EA User
  • **
  • Posts: 216
  • Karma: +1/-0
  • The Truth Is Out There
    • View Profile
Re: template binding
« Reply #7 on: February 13, 2006, 09:52:40 am »

it's believed, that there are forces of darkness and light  ;)
registertm everything to SparX

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: template binding
« Reply #8 on: February 13, 2006, 10:01:12 am »
Actually, you should probably invoke them.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: template binding
« Reply #9 on: February 13, 2006, 01:28:46 pm »
What I said is how EA handles it.  (At least for code engineeing)

If you just want the correct appearance.  Create a generalization connector and stereotype it <<bind>>.

Open the constraints tab and enter T=C.

Finally, create whatever associations/dependencies you want.

It won't show types updated types if you show inherited attributes/operations.  But other than that it should look ok.

bboyle

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: template binding
« Reply #10 on: June 05, 2006, 09:16:11 am »
I'm having the same problem and posted a query about this to the support group. I'll post their reply when I get it. In any case, this is a problem for me as well, as it should be for anyone doing any C++ development whatsoever. I don't have this problem with the IBM-Rational Developer product, or Telelogic's Tau-G2, or even Visio 2002 or later.

llavayssiere

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: template binding
« Reply #11 on: June 06, 2006, 01:36:25 am »
I'm waiting for you next post bboyle (perhaps a good solution to this problem). It's not practical to model instantiated template classes with EA, and effectively, in c++, this is an important functionnality, and i'm using it in all my c++ projects.

bboyle

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: template binding
« Reply #12 on: June 06, 2006, 06:51:23 am »
Well, tech support pointed me back here...  :P In any case, the suggestion from simonm works as far as adorning the <<bind>> link with the template arguments by using constraints is concerned (this should not be necessary, and REALLY means something else). However, the template class code generator is bogus! It doesn't create the function bodies either inline in the class definition or as inline functions after the class definition in the .h file, even if you define a code body in the method definition itself. I haven't yet tried to see what it would do by adding them by hand in the source header file and then syncing the code & model. I guess that's the next step.