Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » [isQuery=true] property on passive class function does not reflect on source file
[isQuery=true] property on passive class function does not reflect on source file [message #1795449] Sun, 23 September 2018 04:15 Go to next message
Md. Abu Faisal is currently offline Md. Abu FaisalFriend
Messages: 3
Registered: January 2018
Junior Member
Hi

While developing a project using Papyrus-RT, I have found a weird scenario in implementing a Passive class with readonly (const) behaviour. By looking into the properties panel, I came to know that there is a property named isQuery that can apply const modifier to the respective class/member.

First I tried on class then got compilation error saying member functions are not const type. Then I applied on member getter function. It works only in header file however the source *.cc file definition of that member does not match the declaration in header file, e.g.

I have a readonly class called Person with a member function getType() with isQuery set to true.

In *.h file getType() is generated with const modifier but in *.cc file the getType() function definition does not have const modifier.

Thats why I again got compilation error because getType() is not matching with header file declaration. Now I need to manually apply the const modifier on that getter function every time the Person class is generated.

Does anybody know any workaround to this problem?

Thanks in advance.

-Faisal
Re: [isQuery=true] property on passive class function does not reflect on source file [message #1795517 is a reply to message #1795449] Mon, 24 September 2018 15:54 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 381
Registered: March 2011
Senior Member
Hi. I'm not sure what you mean by "isQuery" on a class. "isQuery" is an attribute of operations (i.e. methods) only. But you are right about the generated code being incorrect. In fact we already have a bugzilla entry for it: Bug 528160.

Unfortunately the only workarounds for now are:

1) Manually add the const to the method signature in the generated code, but this will be removed if you re-generate code,
2) Apply the PassiveClassProperties stereotype to the class and use one of the <X>Declarations properties (privateDeclarations, protectedDeclarations, publicDeclarations) to add the full method, including its signature with const

Note however, that the "const" qualifier applied to a method means that in the method's body the 'this' pointer is treated as const, and you can only call const member functions in theory, but being C++, you can always "break the law" and also call non-const functions with a const_cast [1]. So the const qualifier doesn't do all that much. It may be used by the compiler to do some optimizations, but not much else. So, as long as you are disciplined in the method's implementation, it shouldn't matter all that much. In general, one can live without it.

[1] https://en.cppreference.com/w/cpp/language/member_functions#const-.2C_volatile-.2C_and_ref-qualified_member_functions
Re: [isQuery=true] property on passive class function does not reflect on source file [message #1796440 is a reply to message #1795517] Sat, 13 October 2018 05:10 Go to previous message
Md. Abu Faisal is currently offline Md. Abu FaisalFriend
Messages: 3
Registered: January 2018
Junior Member
Hi

Thanks a lot for your reply. Yes I am aware about the fact that we can easily do casting in C++. However, as per my limited knowledge, model-driven development should be independent of these low-level code dependencies. That's why, I have asked this question, if there is any way to do this with respect to Papyrus-RT.

Thanks again for your nice reply.

Regards.
Faisal
Previous Topic:Problems saving changes
Next Topic:Customize generated code folder
Goto Forum:
  


Current Time: Wed Jul 17 20:21:43 GMT 2019

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

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

Back to the top