Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Deleted assignment operator overloading getting overwritten/changed (C++)?
Deleted assignment operator overloading getting overwritten/changed (C++)? [message #1852411] Sat, 14 May 2022 20:16 Go to next message
Manuel Malagon is currently offline Manuel MalagonFriend
Messages: 81
Registered: December 2011
Member
I don't know if I'm doing this correctly but I suppose I am not because my declaration is automatically changed when I generate the code or do any other change somewhere else. I'm trying to declare a deleted assignment operator for my class like this:

void operator=(const Main & /*in*/main) = delete;


And to do so I'm doing the following:
index.php/fa/42065/0/

So far so good. The deleted assignment operator overloading is created successfully and everything looks good. Bu then the declaration changes as soon as I hit "save". It is changed for this:
index.php/fa/42066/0/

BUT! The code in Main.h is still the same. I would be ok if I didn't execute a "(right click) > Designer > Generate code" but that sometimes is necessary at some point and that would screw up my code because that unintended change in the diagram would propagate to the code.

Am I doing something wrong when adding an operator overloading? Or is this a bug?

Thanks!
Re: Deleted assignment operator overloading getting overwritten/changed (C++)? [message #1852594 is a reply to message #1852411] Wed, 25 May 2022 15:36 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
Dear Manuel,

this looks like a bug in the synchronization code. I'll try to reproduce it.

Ansgar
Re: Deleted assignment operator overloading getting overwritten/changed (C++)? [message #1852653 is a reply to message #1852594] Mon, 30 May 2022 07:07 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
A deleted method or operator does not have code and should therefore have no associated behavior in UML: the operation should not have a method. For some reason (copy/pasting an operation?), the deleted operator in your model references the ~Main behavior as "method". Simply delete the "method" reference.
This error in the model should not be harmful, but confuses the synchronization code.
Re: Deleted assignment operator overloading getting overwritten/changed (C++)? [message #1852940 is a reply to message #1852653] Sat, 11 June 2022 18:29 Go to previous messageGo to next message
Manuel Malagon is currently offline Manuel MalagonFriend
Messages: 81
Registered: December 2011
Member
Ansgar

Thank you so much for helping! Thanks for noticing that! Although, even if I remove the ~Main behavior from the methods, it gets changed when I save the model. Here is how to reproduce it on the attached project:

1- Open the project and have the arrangement of the windows similar to the sample images. You will see first that the operator= references the ~Main method and please notice the correct implementation of ~Main on the Main.cpp file
index.php/fa/42168/0/

2- Remove the ~Main method from the operator=. As soon as you remove the method this happens.
* - The correct implementation of ~Main on the Main.cpp is deleted leaving and emtpy ~Main.
* - A strange artifact appears in both Main.cpp and Main.h files
index.php/fa/42169/0/

3- This persists and nothing changes even after saving the .di file.

4- Go to both Main.cpp and Main.h files and press ctrl+z to recover the original implementation of ~Main and save the files. So far so good.

5- The problem appears again if you perform a Designer > Generate code, (as I sometimes would have to do). After generating the code, the correct implementation of ~Main on the Main.cpp file is deleted and the wild artifacts appear again.
index.php/fa/42170/0/

I include my project so you can reproduce the issue. You can use it since it is a personal project and nothing really secret or finished for that matter.

[Updated on: Sat, 11 June 2022 18:31]

Report message to a moderator

Re: Deleted assignment operator overloading getting overwritten/changed (C++)? [message #1853223 is a reply to message #1852940] Thu, 23 June 2022 11:57 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
Dear Manuel,

I can (mostly) reproduce the issue. There are multiple elements
1. A behavior can only be assigned to at most one operation, otherwise its specification reference would be non deterministic. Therefore, the UML2 plugin removes a method from an existing operation, if you add it to another. This is correct.
2. When a class has an owned behavior without specification, the C++ generator emits the information "// opaque behavior without specification" prior to a C++ method declaration that uses the name and parameters of the opaque behavior instead of an associated operation. However, in my case, I get the original code instead of an empty one. It can be discussed whether the generator should ignore a behavior without specification. Anyway, the behavior of the generator in this case needs to be documented which is currently not the case.
3. The synchronization mechanism does not establish the link between an operation and a method of the same name, if the link does not already exist. In can be discussed as well, whether the synchronization mechanism should do that automatically.

Ansgar

[Updated on: Thu, 23 June 2022 13:11]

Report message to a moderator

Re: Deleted assignment operator overloading getting overwritten/changed (C++)? [message #1853278 is a reply to message #1853223] Sat, 25 June 2022 19:11 Go to previous message
Manuel Malagon is currently offline Manuel MalagonFriend
Messages: 81
Registered: December 2011
Member
Ansgar

Ok, yeah, there are lots of behaviors of papyrus I don't fully understand. I thought that the association was made just by name but as you mention that is not the case.

I was able to fix my issue with the three points you provided. I just realized that indeed my ~Main behavior didn't have its correct specification and that is what was causing all the mess. As soon as I added its specification then all the "problems" I described in this forum post stopped happening!!

I just have one more observation though. After adding the correct specification to the ~Main behavior and the code was not automatically changed anymore the only issue I still had was the Main::~Main() method code was still being erased. The way I solve this was to paste the code in the C++ text box from the behavior properties as shown here:
index.php/fa/42231/0/

I guess that's fine because now everything works well but I just wanted to ask, is this required? Shouldn't I be able to just normally type the code in the CDT editor and save the file as opposed to write it, copy it, and paste it in the properties window in order to not have it deleted when I execute Designer > Generate code>?

[Updated on: Sat, 25 June 2022 19:13]

Report message to a moderator

Previous Topic:My experience with Papyrus on a M1 based MacBook
Next Topic:Association Link between Instance Specification
Goto Forum:
  


Current Time: Wed Apr 24 17:57:18 GMT 2024

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

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

Back to the top