Book a Demo

Author Topic: Bind a Parameterized Class to a specific type?  (Read 3936 times)

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Bind a Parameterized Class to a specific type?
« on: April 27, 2011, 01:38:24 am »
EA 8.0

In a class diagram, I have a template class (or parameterized class) called "GraphicsScaleWidget".

How do I bind the template parameter of GraphicsScaleWidget to a specific type? I would like e.g. to create a GraphicsScaleWidget<float> (in C++ speak), but I am unable to find the <<bind>> stereotype, or anything comparable.

When I create a composition relation to GraphicsScaleWidget, I do not find any place in the relation dialog to specify the concrete type "float" that I want to use with the template class.

A colleague suggested to create an instantiated class, but even after realizing GraphicsScaleWidget with a class that uses "instantiated", the code generated shows me EA has not the same understanding of my class model that I do.

Help is no help, because it does tell me
"For an instantiated template, select Instantiated and add the arguments in the Arguments field. "
...but not how to achieve that.

How do I properly use a template class, so the code generated will show "GraphicsScaleWidget<float>& m_GraphicsScaleWidget" in my parent class?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Bind a Parameterized Class to a specific type?
« Reply #1 on: April 27, 2011, 09:48:02 am »
Have a play with EA 9 and see if that will meet your need when it is released.

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Bind a Parameterized Class to a specific type?
« Reply #2 on: April 27, 2011, 06:00:22 pm »
Does this imply it won't work with EA 8?

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Bind a Parameterized Class to a specific type?
« Reply #3 on: April 27, 2011, 08:55:44 pm »
I've found the new TemplateBinding relationship in EA 9. I still can't do what I really want to do (that is, define a template parameter binding in a composition relationship), and I can't seem to create a TemplateBinding between a class and an instance of that class (which seemed the logical alternative), but I do have more possibilities that I can try out.

However, since our whole development team is on EA 8, and I don't know what our upgrade strategies are, is there any trick to get a binding done in EA 8?

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Bind a Parameterized Class to a specific type?
« Reply #4 on: April 28, 2011, 09:13:09 am »
The association connector also allows binding to be specified for the target end. (Which in terms of UML is a shorthand for an association to an anonymous class with a binding relationship to the target class.) Use one of these with the aggregation on the Source end set to 'composite'.

Template Binding only exists in version 8 by specifying the arguments on a class that inherited from a template class. Other than that it is by explicitly adding template arguments into the type field of an attribute.

Asperamanca

  • EA User
  • **
  • Posts: 91
  • Karma: +0/-0
    • View Profile
Re: Bind a Parameterized Class to a specific type?
« Reply #5 on: April 28, 2011, 05:21:34 pm »
Quote
Template Binding only exists in version 8 by specifying the arguments on a class that inherited from a template class.

...but I would only be able to do so by setting the "Type" in "Details tab / Templates" to "Parameterized", "Instanciated" or "Both", correct?

So in the case where a non-template non-instantiated class inherits from a template class, I cannot do such a thing, or can I?

Quote
Other than that it is by explicitly adding template arguments into the type field of an attribute.

This was one of my first ideas, but strangely, when adding a composition, the relationship does not result in an added attribute as expected (however, the attribute is correctly generated in code).

How do I update the list of attributes for changes in relationships, so I can change attribute names and, in this case, template parameters?