Machines currently have a mix of public typedefs (like CoordMapT, IODriverTypes, etc) and public functions (like clampMoveRate, doHomeBeforeFirstMovement). The typedefs were chosen in order to avoid making the Machine manage any data or logic that involves state, but they limit things - template parameters can only be integers and compile-time constants, etc, and it causes some unnecessary templating that also restricts runtime reconfiguration/calibration.
I think a better solution, which still avoids making the Machine manage data accesses, is to replace these typedefs with functions like createCoordMap and createIODrivers which, rather than return references to private data members, just create the appropriate object and return that. Then the State can manage the lifetime/access restrictions to the actual data. This should not result in any performance decrease, as all the information used previously is still computable at compile-time. And users of these functions should still be able to compute the type (for storage) via auto or decltype.
Machines currently have a mix of public typedefs (like
CoordMapT
,IODriverTypes
, etc) and public functions (likeclampMoveRate
,doHomeBeforeFirstMovement
). The typedefs were chosen in order to avoid making the Machine manage any data or logic that involves state, but they limit things - template parameters can only be integers and compile-time constants, etc, and it causes some unnecessary templating that also restricts runtime reconfiguration/calibration.I think a better solution, which still avoids making the Machine manage data accesses, is to replace these typedefs with functions like
createCoordMap
andcreateIODrivers
which, rather than return references to private data members, just create the appropriate object and return that. Then the State can manage the lifetime/access restrictions to the actual data. This should not result in any performance decrease, as all the information used previously is still computable at compile-time. And users of these functions should still be able to compute the type (for storage) viaauto
ordecltype
.