Description
Abstract
This PR introduces a simple change where EntityManager
's and API
's member functions obtaining entities have been modified to return a reference to the object, rather than a pointer.
The change mentioned above is interface breaking and thus many cpp mock scenarios as well as openscenario interpreter and random test runner had to be adjusted to accommodate these changes.
Background
This change has been suggested in the discussion under the previous refactoring PR (3/5) in this comment.
Tip
For the bigger picture, please see the whole thread started by the comment linked above.
Details
This PR changes several EntityManager
member function signatures and subsequently all corresponding member functions of API
as they are forwarded using a FORWARD_TO_ENTITY_MANAGER
macro.
Listed below are all changes made to the EntityManager
function signatures.
Obtaining EntityBase with error throwing
Before
https://github.com/tier4/scenario_simulator_v2/blob/59b5887b179293fea3ad5eb993c15520e76b58af/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp#L177-L178
After
https://github.com/tier4/scenario_simulator_v2/blob/f0d702d725bd339bdb7c1e1e3660aa213b970d04/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp#L177-L179
Obtaining EntityBase without error throwing
Before
https://github.com/tier4/scenario_simulator_v2/blob/59b5887b179293fea3ad5eb993c15520e76b58af/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp#L174-L175
After
https://github.com/tier4/scenario_simulator_v2/blob/f0d702d725bd339bdb7c1e1e3660aa213b970d04/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp#L174-L175
Obtaining EgoEntity (only with error throwing)
Before
https://github.com/tier4/scenario_simulator_v2/blob/59b5887b179293fea3ad5eb993c15520e76b58af/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp#L180-L183
After
https://github.com/tier4/scenario_simulator_v2/blob/f0d702d725bd339bdb7c1e1e3660aa213b970d04/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp#L181-L183
Important
After these changes the function that "gets the Ego without providing the name argument" has been replaced with the combination of using getFirstEgoName
and the function that does require a name argument.
Obtaining Ego name
Before
https://github.com/tier4/scenario_simulator_v2/blob/59b5887b179293fea3ad5eb993c15520e76b58af/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp#L224
After
https://github.com/tier4/scenario_simulator_v2/blob/f0d702d725bd339bdb7c1e1e3660aa213b970d04/simulation/traffic_simulator/include/traffic_simulator/entity/entity_manager.hpp#L224
References
Destructive Changes
The return value of the getEntity function has been changed from a shared pointer to a reference.
Therefore, any place where the getEntity function is called is subject to a destructive change.
Known Limitations
--