epfl-lasa / control-libraries

A collection of library modules to facilitate the creation of full control loop algorithms, including state representation, motion planning, kinematics, dynamics and control.
https://epfl-lasa.github.io/control-libraries
GNU General Public License v3.0
27 stars 2 forks source link

Mark Parameter getters const #289

Closed eeberhard closed 2 years ago

eeberhard commented 2 years ago
eeberhard commented 2 years ago

Where do we need that?

I was going to justify this and tag reviewers later haha. I think getters should be marked const where applicable, both for clarity and for code safety. Currently any class that holds parameter properties isn't able to read the parameters in const methods. Sometimes you want or need those methods to be const to guarantee that nothing is changed.

For example, validating a parameter requires reading the value. If the validation fails, we don't want the parameter to be updated, so it should be const. If it's not const, a user-defined override might change it anyway which is not intentional.