Wallacoloo / printipi

3d printing directly through the Raspberry Pi's GPIO pins
MIT License
141 stars 43 forks source link

Replace public typedefs in drv::Machine with public accessors #45

Closed Wallacoloo closed 9 years ago

Wallacoloo commented 9 years ago

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.

Wallacoloo commented 9 years ago

Fixed in devel, although it will be some time before other parts of the code are refactored to make use of this.