Skip to main content



      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 09:36 Go to next message
Eclipse UserFriend
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 148 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 12:01 Go to previous messageGo to next message
Eclipse UserFriend
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 12:03 Go to previous messageGo to next message
Eclipse UserFriend
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 04:14 Go to previous messageGo to next message
Eclipse UserFriend
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 13:25 Go to previous messageGo to next message
Eclipse UserFriend
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 10:34 Go to previous messageGo to next message
Eclipse UserFriend
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 10:41 Go to previous messageGo to next message
Eclipse UserFriend
<removed duplicate response>

[Updated on: Thu, 13 January 2022 10:44] by 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 04:36 Go to previous message
Eclipse UserFriend
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: Wed Jul 09 09:08:17 EDT 2025

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

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

Back to the top