Default Value and Code Generation [message #1796113] |
Fri, 05 October 2018 06:05  |
Eclipse User |
|
|
|
Hello,
I would know if the "default value" field in a property is used by the C++ code generator? If yes, how can I set it to initialize correctly a property?
Thanks.
Yoann.
[Updated on: Mon, 08 October 2018 02:42] by Moderator
|
|
|
|
Re: Default Value and Code Generation [message #1796212 is a reply to message #1796195] |
Mon, 08 October 2018 07:58   |
Eclipse User |
|
|
|
Hi Ansgar,
Thanks for your reply.
I did like you describe, and even with an InstanceValue for enumeration literal. In the model, no problem. But the result of the C++ code generation was not in accordance with the model and I think I found the reason. The class I tried to generate has a "classifier behavior" and the state machine can be monitored. This brings that the constructor of the class looks like something like this (in .cpp file):
MyClass::MyClass() {
monitorSocket = socket(AF_INET, SOCK_DGRAM, 17);
monitorAddress.sin_addr.s_addr = inet_addr("127.0.0.1");
monitorAddress.sin_family = AF_INET;
monitorAddress.sin_port = htons(4445);
startBehavior();
}
But there is absolutely no trace of property initialization.
Now if I delete the classifier behavior of the class and retry to generate the code, I obtain a method like this in the header (.h file ):
MyClass() :
hello(Inactive), myInt(0), activeVariable(Active), Myvar(
Active), test(1) {
}
Here it 's ok for the default value.
I think there is an issue in the generation when using behaviored class ( or monitored state machine maybe) and the initialisation of properties in the constructor.
Yoann
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.26801 seconds