refactor: update the variable interfaces. #8388
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The basics
The details
Proposed Changes
This PR revamps the new variable interfaces in response to issues encountered during implementation. Specifically:
save
andload
are moved from IVariableMap to IVariableModel. In the case where somebody wants to add additional properties to their variables, this means they need only subclass/implement IVariableModel, and not also have to replace the variable map solely to handle serialization.getWorkspace()
is added to IVariableModel; the existing VariableModel had this property, and it's often necessary to determine which workspace a variable is associated with.addVariable()
is added to IVariableMap. Again, this allows for simple variables-with-extra-fields without having to subclass the VariableMap in order to change the method signature ofcreateVariable
to accomodate new properties; the custom variable can simply be instantiated, and then added to the vanilla VariableMap.In order to get things to build, this PR updates VariableModel to conform to the new interface and register itself, and updates variable serialization to use the new save and load methods it introduces rather than hardcoding serialization.