-
-
Notifications
You must be signed in to change notification settings - Fork 43
Refactor SmartSpin_Parameters with generic Parameter template and eliminate all old getter/setter methods #678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: doudar <[email protected]>
Co-authored-by: doudar <[email protected]>
Co-authored-by: doudar <[email protected]>
…emplate implementation Co-authored-by: doudar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot This looks like a good start.
Next all of the existing methods (like setSimulatedSpeed()) need to get removed, and any calls to them replaced by the new function (like simulatedSpeed.set().)
…rameter template access Co-authored-by: doudar <[email protected]>
✅ Done! I've removed all the old getter/setter methods (like Changes made:
✅ Build verified successful - all functionality preserved with zero breaking changes. The refactoring is now complete as requested! Commit: 0b6dd4e |
@copilot there was just a major PR merged into develop. Please resolve the merge conflicts. |
✅ Merge conflicts resolved! Successfully rebased the Parameter template refactoring branch onto the latest develop branch. What was done:
Current status:
The branch is now ready for review with the latest changes from develop integrated. Commit: 77d45de |
This PR implements a major refactoring of the
SmartSpin_parameters.h
andSmartSpin_parameters.cpp
files to eliminate repetitive getter/setter code by introducing a genericParameter<T>
template class and removing all old-style wrapper methods.Problem
The existing
userParameters
andRuntimeParameters
classes contained 68 nearly identical getter/setter method implementations across 34 parameters. Each parameter required manual implementation of the same boilerplate pattern:This made adding new parameters tedious and error-prone, requiring developers to manually implement identical patterns for each new parameter.
Solution
Introduced a generic
Parameter<T>
template class that handles all common getter/setter functionality and completely eliminated all old wrapper methods:All parameters are now declared simply as:
Changes Made
Core Infrastructure
Parameter<T>
template class with generic set/get methodsgetCStr()
method for String parameters to maintain const char* interface compatibilityComplete Class Refactoring
Parameter<T>
Parameter<T>
Method Elimination and Call Updates
setSimulatedSpeed()
,getShiftStep()
)userConfig->getShiftStep()
→userConfig->shiftStep.get()
userConfig->setSimulatedSpeed(value)
→userConfig->simulatedSpeed.set(value)
Merge Conflict Resolution
Backward Compatibility
Benefits
parameter.get()
andparameter.set()
Parameter<Type> name;
Example Impact
Adding a new parameter went from:
To:
Verification
This refactoring provides a robust foundation for future parameter additions while dramatically simplifying the parameter management system and eliminating redundant wrapper methods. The implementation is now current with the latest develop branch and ready for production use.
Fixes #677.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.