RA-Consulting-GmbH / openscenario.api.test

Apache License 2.0
39 stars 12 forks source link

_isSet... member of mandatory attributes is not cloned #207

Open arauschert opened 4 months ago

arauschert commented 4 months ago

Describe the bug When parsing a scenario which refers to a catalog element, then the IsSet...() method of attributes referenced from the catalog always returns "false" for mandatory attributes (cardinality 1...1) no matter if they were set or not in the scenario.

To Reproduce For example see the "visualRange" attribute in the "Fog" class.

If you construct a scenario with an EnvironmentAction, where the Environment (with Fog&visualRange) is referenced from a catalog and call IsSetVisualRange() on the parsed Fog class, it will return false.

Seems this is valid for all imported attributes and visualRange is only one example.

Expected behavior IsSetVisualRange() returns true, if the attribute was set in the catalog element.

Desktop (please complete the following information): Ubuntu 20.04 (should be irrelevant)

Additional context The problem is in the cloning of elements from catalogs while importing. See e.g. in FogImpl::Clone()
https://raw.githubusercontent.com/RA-Consulting-GmbH/openscenario.api.test/master/cpp/openScenarioLib/generated/v1_2/impl/ApiClassImplV1_2.cpp

Only the value of visualRange is set directly (public member?) without using the Setter method, which would also set the _isSetVisualRange member.

Therefore the boolean member _isSetVisualRange isn't cloned and keeps its init value (false).

The generator probably needs to be changed here: https://github.com/RA-Consulting-GmbH/openscenario.api.test/blob/master/generator/de.rac.openscenario.generator/src/main/resources/templates/cpp/v1_2/ImplClassSource.tpl#L370-L373