Map in model and code generation [message #1816990] |
Wed, 13 November 2019 08:19  |
Eclipse User |
|
|
|
Hello everyone,
I have a question about "map" collections. Currently, to generate a compiling code for a map, I use the stereotype "External" on a class which has a name like :
std::map<std::string, std::function<void(my_type)>>
and add "map" in the fields of the stereotype to allow the use of map type.
But this is strongly correlated to the use of C++ language for code generation.
Now, since a previous patch of Papyrus Software Designer, we are able to generate a list with undefined size for example thanks to the use of multiplicity (*) in combination with "ListHint" stereotype and it works pretty well. This avoids the use of type like this : std::vector<std::string> . Should maps be managed by a similar way? What should be the correct way to model (and generate the code) for a map?
Thanks.
Yoann.
|
|
|
Re: Map in model and code generation [message #1816997 is a reply to message #1816990] |
Wed, 13 November 2019 09:32   |
Eclipse User |
|
|
|
Yoann,
If I'm understanding you correctly, it looks like we are both trying to do something similar. See my question here https://www.eclipse.org/forums/index.php/t/1101227/
If you replace my "GenericArray" from my example with "map" and add two template parameters to the template signature, say S and T, then replace "AdddressArray" with you own type, myTemplateType, bind std::string to S and std::function<void(my_type)> to T in the template binding connection, and create a variable "myTemplateType myVar", then when you generate the code you should get a typedef myTemplateType map<std::string, std::function<void(my_type)>
At least that's how I think it works but I'm having difficulties adding the template parameters.
Let me know if you make any progress.
Steve
|
|
|
Re: Map in model and code generation [message #1817020 is a reply to message #1816997] |
Thu, 14 November 2019 03:04  |
Eclipse User |
|
|
|
Hello Stephen,
I didn't try the approach that you describe in your post but it's maybe the good way for a generic way of this question. I'll try and give you some return in case of success or any progress.
Thanks.
Yoann.
|
|
|
Powered by
FUDForum. Page generated in 0.11671 seconds