Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Adding Container To Class Diagram
Adding Container To Class Diagram [message #1791763] Thu, 05 July 2018 06:12 Go to next message
Ron Potashnik is currently offline Ron PotashnikFriend
Messages: 7
Registered: May 2018
Junior Member
I am new in papyrus(Eclipse C/C++ on linux) and i want to write a class that have a vector of type double.

So i created a new class, and in properties i add new Owned atrribute.
i find the double type but i cant find out how to add the vector container.
Re: Adding Container To Class Diagram [message #1791766 is a reply to message #1791763] Thu, 05 July 2018 06:41 Go to previous messageGo to next message
Carsten Pitz is currently offline Carsten PitzFriend
Messages: 479
Registered: May 2015
Location: Germany
Senior Member
Hi Ron,

there is nothing like a vector container in UML.

But you have several choices to express multiplicity

1. you want to completely abstract away the fact multiplicity is provided by using a vector container. In that case you just have to choose "0..*" as multiplicity of the attribute.

2. you want to express multiplicity is somehow provided by using a vector container. In this case I would suggest you to define a "Vector" stereotype and apply that very stereotype to the attribute.

3. you want to express some or all of the the operations of the vector container. In this case I would suggest you to provide the vector container's interface as UML Interface.

/Carsten
Re: Adding Container To Class Diagram [message #1791771 is a reply to message #1791766] Thu, 05 July 2018 07:11 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

"you just have to choose "0..*" as multiplicity of the attribute"

You should also ensure that the "ordered" and "unique" attributes of the vector attribute correspond to your needs.Probably ordered=true, unique=false.

In UML "container" normally applies containment. However double or rather Real is a primitive DataType which cannot and does not need to be contained; each instance uses a separate area of memory.

Regards

Ed Willink
Re: Adding Container To Class Diagram [message #1791786 is a reply to message #1791771] Thu, 05 July 2018 09:25 Go to previous messageGo to next message
Carsten Pitz is currently offline Carsten PitzFriend
Messages: 479
Registered: May 2015
Location: Germany
Senior Member
Hi Ed,
simply thanks for your comment, I somehow forgot to explicitly state the ordered and unique attributes.
/Carsten
Re: Adding Container To Class Diagram [message #1791935 is a reply to message #1791786] Sun, 08 July 2018 05:22 Go to previous messageGo to next message
Ron Potashnik is currently offline Ron PotashnikFriend
Messages: 7
Registered: May 2018
Junior Member
Ok, Thank's!
Re: Adding Container To Class Diagram [message #1791991 is a reply to message #1791935] Mon, 09 July 2018 11:41 Go to previous messageGo to next message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
There has been a similar thread here. Papyrus SW designer contains a small subset of the C++ STL library, including the vector class. However, the STL model library is just a set of empty classes within a package tagged as "ExternLibrary" which assures that a suitable #include will be produced. You can find this library via "import registered library", if SW designer and C++ support is installed. From a pragmatical viewpoint, you can define bound types such as vector<double> by creating a new empty class with a suitable name (vector<double>) and add a "TemplateBinding" relationship towards the class vector from the STL library. Make sure that the new type is in a package with ExternLibrary as well to assure that no code will be generated for it (il will still be referenced using its name in application classes that use it).
However, this is not very clean as the template binding cannot contain a suitable parameter substitution, since vector in the STL model library has currently no template signature (as it probably should).
Re: Adding Container To Class Diagram [message #1816473 is a reply to message #1791991] Tue, 29 October 2019 19:14 Go to previous messageGo to next message
Stephen Blackwell is currently offline Stephen BlackwellFriend
Messages: 138
Registered: March 2014
Senior Member
Hi Ansgar,
Do we still have the same state of affairs regarding the STL library today? ie the STL model library still has no template signature.
I tried to follow your suggestion and created a class that I called "vector<boost::any>" on a class diagram and attempted to add a Template Binding edge to the vector class from the std ExternalLibrary package but I get the "Stop sign" icon.
Did I misunderstand you post or is this a bug?

Thanks,
Steve
Re: Adding Container To Class Diagram [message #1816573 is a reply to message #1816473] Thu, 31 October 2019 15:30 Go to previous message
Ansgar Radermacher is currently offline Ansgar RadermacherFriend
Messages: 461
Registered: March 2011
Location: Paris Saclay, France
Senior Member
Hi Steve,

yes, this is still the case. In the Papyrus for Robotics customization, we use template signatures for communication patterns and enable the automatic creation of an actual and a template binding from the palette. If I find the time, I can do something similar for STL.

Concerning the 2nd part of your message: some time ago it was possible (I think) to create a template binding towards a class without a template signature. This is apparently no longer possible, but this is rather good and not a bug as a template binding makes only sense in in the presence of a template class. Except that the pragmatical work-around does not work any more, i.e. it would be much better to add the missing template signatures.

Ansgar

[Updated on: Thu, 31 October 2019 15:41]

Report message to a moderator

Previous Topic:Minor Designer issue
Next Topic:Context menu in diagrams broken in 4.5.0?
Goto Forum:
  


Current Time: Fri Apr 19 22:18:37 GMT 2024

Powered by FUDForum. Page generated in 0.03473 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top