Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » [C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ?
[C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ? [message #1849263] Mon, 10 January 2022 14:36 Go to next message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
Hello,

I would use the mechanism of slot in the deployment plan to init a property that has a multiplicity *. Unfortunately, by setting several values (Literal String) to the slot (see joined picture), I just get the override of the property value.

Component
    std::vector<String> config;
    ....

BootLoader
BootLoader::init() {
	component.config = "key1:value1";
	component.config = "key2:value2";
        component.run();
}


It results in a build error of course but I would know if there is a proper way to init such property or if I have to use a workaround?

Regards.
Yoann.



  • Attachment: slot.png
    (Size: 1.71KB, Downloaded 107 times)
Re: [C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ? [message #1849266 is a reply to message #1849263] Mon, 10 January 2022 17:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The Eclipse EMF / UML2 tooling often uses a pragmatism that -1 denotes * as the upperbound so for a [*] multiplicity try [0..-1].

Regards

Ed Willink
Re: [C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ? [message #1849267 is a reply to message #1849263] Mon, 10 January 2022 17:03 Go to previous messageGo to next message
Carsten Pitz is currently offline Carsten PitzFriend
Messages: 479
Registered: May 2015
Location: Germany
Senior Member
Hi Joann,

I am no C++ expert at all, but what about?

BootLoader::init() {
        auto it = component.config.begin();
	component.config.insert(it++, "key1:value1");
	component.config.insert(it++, "key2:value2");
        component.run();
}


/Carsten
Re: [C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ? [message #1849283 is a reply to message #1849267] Tue, 11 January 2022 09:14 Go to previous messageGo to next message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
Hello,

I think the multiplicity is well managed by the code generator for the property as a vector is generated for the property "config". I would expect something which looks like what you propose Carsten but it is not generated like this currently and I would know if it is an error of modeling or a missing feature in the code generator.
Yoann.
Re: [C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ? [message #1849319 is a reply to message #1849283] Wed, 12 January 2022 18: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 Yoann,
I would vote for the issue is with the generator.
But this bias is more driven by feeling than by in depth analysis ;-)
/Carsten
Re: [C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ? [message #1849356 is a reply to message #1849319] Thu, 13 January 2022 15:34 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
Hi Yoann,

you're right, the C++ code generator currently does not properly support the initialization of a multi-valued attribute. One problem, is that this initialization code depends on the specific mapping which can be configured via the ListHint stereotype. Eventually, the hint also needs to provide information how to access an element. Feel free to create a bug.
In cases of a mapping to arrays, a workaround is the initialization with a single slot, e.g. "{ value1, value2, ... , valueN }". But this does not work for a mapping to std::vector, which needs an initialization in the constructor (vector<...> vect{ value1, value2, ... }) - there are many other ways to do it, of course.

Ansgar
Re: [C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ? [message #1849357 is a reply to message #1849356] Thu, 13 January 2022 15: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
<removed duplicate response>

[Updated on: Thu, 13 January 2022 15:44]

Report message to a moderator

Re: [C++ Gen] Is there a way to initialize a slot with a defining feature of multiplicity * ? [message #1849368 is a reply to message #1849357] Fri, 14 January 2022 09:36 Go to previous message
Yoann Farré is currently offline Yoann FarréFriend
Messages: 235
Registered: November 2017
Senior Member
Hi,

Thanks for the answers. I understand the difficulty, it strongly depends on the chosen implementation of list. Nevertheless, I fill a bug to trace it. Bug578212

Regards.
Yoann.
Previous Topic:StateInvariant visualization (StateMachine Diagram)
Next Topic:What is the language used for the field "Expression" in Edit Image dialog for a stereotype
Goto Forum:
  


Current Time: Thu Apr 25 01:00:40 GMT 2024

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

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

Back to the top