Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Map in model and code generation
Map in model and code generation [message #1816990] Wed, 13 November 2019 13:19 Go to next message
Yoann Farre is currently offline Yoann FarreFriend
Messages: 116
Registered: November 2017
Senior Member
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 14:32 Go to previous messageGo to next message
Stephen Blackwell is currently offline Stephen BlackwellFriend
Messages: 138
Registered: March 2014
Senior Member
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 08:04 Go to previous message
Yoann Farre is currently offline Yoann FarreFriend
Messages: 116
Registered: November 2017
Senior Member
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.
Previous Topic:Problem with Papyrus Compare and an embedded profile?
Next Topic:AssociationClass link disappearing on digrams
Goto Forum:
  


Current Time: Sat Dec 14 23:20:55 GMT 2019

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

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

Back to the top