Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Papyrus Designer for C++: how to use builtin parameterized types?
Papyrus Designer for C++: how to use builtin parameterized types? [message #1764050] Wed, 24 May 2017 10:57 Go to next message
Vadim K. is currently offline Vadim K.Friend
Messages: 10
Registered: April 2017
Junior Member
Hi all.

What is a correct way to create a property of parameterized type? For example, a property to become "std::vector<MyClass> vmc;" in C++ code.

Currently I using a awkward workaround: a PrimitiveType called "std::vector<MyClass>".
Re: Papyrus Designer for C++: how to use builtin parameterized types? [message #1764245 is a reply to message #1764050] Sat, 27 May 2017 07: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
You need to create a template signature for vector, add an owned template parameter (e.g. named T), Then you create a new class with a template binding relationship to vector. The parameter substitution of this relationship replaces T with MyClass. Please have a look at the two threads from Philip (https://www.eclipse.org/forums/index.php/t/1083587/ , https://www.eclipse.org/forums/index.php/m/1764244/#msg_1764244)
Re: Papyrus Designer for C++: how to use builtin parameterized types? [message #1764803 is a reply to message #1764245] Fri, 02 June 2017 10:37 Go to previous messageGo to next message
Vadim K. is currently offline Vadim K.Friend
Messages: 10
Registered: April 2017
Junior Member
Thanks for answer.

I think I having troubles understanding at least codegenerator behavior. Please, see my class diagram attached.

"string" and "vector" both have "External" stereotype applied, with appropriate headers references.

What I've currently got:

1) VStrings.h contains definition 'typedef vector<wstring> VStrings'.
2) VStrings.h contains '#include "RootElement/vector.h"', but there is no 'vector.h' file generated;
3) There are neither '#include "vector"' nor '#include "string"' tokens anywhere in generated code;
4) Property 'VStrings _vss' always generated as 'public', regardless Association's Visibility.

What I expected to achieve:
1) '#include<vector>' and '#include<string>' in VStrings.h;
2) Type definition with namespace specification: typedef std::vector<std::wstring> VStrings;
3) Code generator to respect Association's Visibility.
4) No odd includes such as '#include "RootElement/vector.h"'.

Could you point to my mistakes and possible solutions?
  • Attachment: diag1.png
    (Size: 10.12KB, Downloaded 117 times)
Re: Papyrus Designer for C++: how to use builtin parameterized types? [message #1764827 is a reply to message #1764803] Fri, 02 June 2017 13:15 Go to previous messageGo to next message
Stephen Blackwell is currently offline Stephen BlackwellFriend
Messages: 138
Registered: March 2014
Senior Member
I think I can help you with the 1st point.
Add the <<Include>> stereotype to your VStrings class. This is in the C_Cpp profile which I'm sure you have already applied.
Expand the <<Include>> stereotype and add the appropriate #defines to the header element. When you regenerate you should see those includes in VStrings.h

HTH
Steve
Re: Papyrus Designer for C++: how to use builtin parameterized types? [message #1764874 is a reply to message #1764827] Fri, 02 June 2017 18:21 Go to previous messageGo to next message
Vadim K. is currently offline Vadim K.Friend
Messages: 10
Registered: April 2017
Junior Member
Thanks, Stephen. I know about <Include>, but <External> is much more convenient. I thought it should do the job in my scenario. I wonder, is it code generator issue or my misunderstanding.
Re: Papyrus Designer for C++: how to use builtin parameterized types? [message #1764880 is a reply to message #1764874] Fri, 02 June 2017 19:55 Go to previous messageGo to next message
Stephen Blackwell is currently offline Stephen BlackwellFriend
Messages: 138
Registered: March 2014
Senior Member
When the #include you want is exactly the same as the class name you are deriving from, then you can expand the <<External>> stereotype and put the name there.
Then you get an automatically generated #include. In your case I think that almost what is what you want.

I say almost because you will get:
#include "vector"
and not
#include <vector>

I don't know how to fix that.

In my case I am using GoogleTest and so I needed to derive from ::testing::Test but the include file name required is "gtest/gtest.h" so I had to use the <<Include>> stereotype method.

Steve
Re: Papyrus Designer for C++: how to use builtin parameterized types? [message #1764883 is a reply to message #1764880] Fri, 02 June 2017 20:19 Go to previous message
Vadim K. is currently offline Vadim K.Friend
Messages: 10
Registered: April 2017
Junior Member
Like I said, "string" and "vector" both have "External" stereotype applied, with appropriate headers references - I mean "wstring" has "string" and "vector" has "vector" specified. Somehow it wasn't enough in my case.

[Updated on: Fri, 02 June 2017 20:20]

Report message to a moderator

Previous Topic:InstanceSpecification drawing help
Next Topic:label font size in e.g. Properties tab?
Goto Forum:
  


Current Time: Sat Apr 20 03:30:32 GMT 2024

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

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

Back to the top