It seemed to me that these classes were more complicated than they needed to be, especially with modern C++ features such as lambdas available to us. This tidies them up and, in the process, fixes https://github.com/Brewtarget/brewtarget/issues/560.
Look at Unit.h, Unit.cpp, UnitSystem.h, UnitSystem.cpp first and then all the other consequential changes hopefully make sense.
Essentially, I've got rid of all the subclasses of Unit and UnitSystem because they were repeating code unnecessarily. The differences between different units and unit systems are just data and (simple) formulae, so they don't need a plethora of subclasses. I also removed/fixed some comments that seemed incorrect (eg about the iteration order of QMap).
I think there is still room for some further tidying up of UnitSystem (see comments in that class), but hopefully this is already something of an improvement.
It seemed to me that these classes were more complicated than they needed to be, especially with modern C++ features such as lambdas available to us. This tidies them up and, in the process, fixes https://github.com/Brewtarget/brewtarget/issues/560.
Look at Unit.h, Unit.cpp, UnitSystem.h, UnitSystem.cpp first and then all the other consequential changes hopefully make sense.
Essentially, I've got rid of all the subclasses of Unit and UnitSystem because they were repeating code unnecessarily. The differences between different units and unit systems are just data and (simple) formulae, so they don't need a plethora of subclasses. I also removed/fixed some comments that seemed incorrect (eg about the iteration order of QMap).
I think there is still room for some further tidying up of UnitSystem (see comments in that class), but hopefully this is already something of an improvement.