Join Ptr<class> and class at reverse

General discussions about code engineering

Moderator: Moderators

Join Ptr<class> and class at reverse

Postby DmP » Mon Jul 10, 2017 1:29 am

In my C++ code, custom smart pointers are used, therefore class members can be of type Ptr<Class>. Then, I also have this Class defined in a separate file (also included in the code engineering set).
However, MagicDraw cannot understand that Ptr<class> and Class are the same and thus the association is not established.
Is there any way to configure MagicDraw in such a way that it understands that Ptr<Class> and Class are the same?
Probably, it is somehow possible to skip "Ptr"?
Forum Newbie
Forum Newbie
Posts: 1
Posts Rating:0
Joined: Thu Jul 06, 2017 4:18 am

Re: Join Ptr<class> and class at reverse

Postby bhoomchai » Wed Jul 12, 2017 3:24 am

By default, C++ reverse engineer will reverse Ptr<ClassA> to a Template class and a class that bind to it using ClassA for template parameter substitution.
However, this behavior can be changed, please try the following instruction.
- Close MagicDraw if opened.
- Go to the folder <MagicDraw Install folder>/data and look for the file, c++.prop.
- Open c++.prop with any text editor.
- Search for the text, Collections_types. You will see the list of collections that MagicDraw reverse engineer will reverse them to the tag, "container" which is what you want. So, from here you can add Ptr=0 to the end of the list.

Your updated text should look like this

Code: Select all
         close_set true
         set (list
         default_value "std.list=0"

- Save the file, start MagicDraw and try to reverse code to see the change.
Customer Support
Customer Support
Posts: 35
Posts Rating:5
Joined: Thu Jan 21, 2010 12:38 am

Re: Join Ptr<class> and class at reverse

Postby » Thu Jul 27, 2017 3:44 am

Hi bhoomchai,

Thank you for the recommendation!
Indeed, I have not realized initially, that Ptr<Class> is a template. Thus, MagicDraw treats that correctly at reverse.

I tried what you suggested and the result is closer to what I wanted, i.e. now I can visualize the relation between classes directly. However, association is shown as one to many, because Ptr is added as collection type. That is not an ideal solution, of course.

Let's say I have ClassA with member variable m_var of type Ptr<ClassB>.
Then, after reverse, MagicDraw will create attribute m_var of type Ptr<ClassB>. Type Ptr<ClassB> is dummy, however, it has Relation "Template Binding" to the correct ClassB. Thus, there is necessary information in the system. On the other hand, there is no direct relation between CalssA and ClassB.
Is there a way still to visualize this Template Binding on the UML Class diagram automatically, i.e. without manual creation of association between ClassA and ClassB?
Forum Newbie
Forum Newbie
Posts: 1
Posts Rating:0
Joined: Wed Jul 12, 2017 3:58 am

Return to Code engineering

Who is online

Users browsing this forum: No registered users and 1 guest