Book a Demo

Author Topic: parameterised class  (Read 2154 times)

Kaneda

  • EA User
  • **
  • Posts: 38
  • Karma: +0/-0
    • View Profile
parameterised class
« on: August 01, 2005, 07:45:50 am »
Hi,

I am quite lost here, so please bear with me trhough this rather long issue:

I'm trying to model a parameterised class in my PIM class diagram for my MDA process. The idea is, that during the C# transformation, it gets turned into an Arraylist. The type should be a datatype which I created ("ReceiptDesigns"), which itself will be transformed in to a struct.

So after code generation I would like to end up with an ArrayList filled with ReceiptDesign structs.

I am note quite sure how to do this.
I created a parameterised class simply called "List".
It has a parameter T of type class. How many objects it can contain is irrelevant (to the application, not to the model?).
Its attribute "theList" is of type T, with a multiplicity [0..*].

I addition, I created a class ReceiptDesignsList.
It is connected via a Dependency to the class "List", with the dependancy stereotype "bind" (how to I tell that dependancy that ReceiptDesignsList is the parameter?).

The "normal" class, which in the end should contain such a list is called "Receipt" and connected with a normal, directed 1:1 association to ReceiptDesignsList.

So it looks somehow like this:

Receipt--1------1-->ReceiptDesignsList- - - - <<bind>>- - - - >List[class T]


well after code generation I end up with two classes (Receipt, ReceiptDesignList), which looks pretty good, except that the attribute theList in ReceiptDesignList is of type "T" ?

I checked out this link
http://www.sparxsystems.com.au/cgi-bin/yabb/YaBB.pl?board=suggestions;action=display;num=1050317385;start=4#4
but I am not quite sure how far that is only for the  "real" C++ templates, anyway I tried it and the result was a failure....


That the code gen produces a ArrayList is probably a matter of altering the transformation template, which is fine by me.

But I somehow have the feeling that the whole  "construction" mentioned above is totally wrong.
Maybe EA can't create the "theList" attribute probably, maybe I jsut have to adjust the template, but maybe, I messed a couple of things up.
So any feedback on the discrebed above is much appreciated (and needed :) )

And yes I know that I can easily create an ArrayList attribute in my PSM by hand, but this "project" I am doing is just a MDA-demo application (more: a snapshot of a previous developed app this time developed with MDA), so its a lot about model and code generation and the customization of transormation templates.

Any help is as always greatly appreciated!
« Last Edit: August 01, 2005, 07:47:20 am by Kaneda »
There are 10 types of people in this world. Those who understand binaries and those who don't...