WIP: Generic memory persistence class #2171
Draft
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.
This PR aims to implement a simple interface to store and load program state to the memory.
Why is this a good idea?
Because it provides a simple interface for developers and reduces the amount of IO-code people have to write. Writing persistent apps would only be a matter of defining the persistent data struct, inheriting from
Persistent
and loading/saving the data in the constructor/desconstructor (and maybe we can automate this away, not sure though).What is already there?
In
utility/Persistent.h
is a new template classPersistent<T>
.It holds a versioned struct of data which it can save to and load from the memory. The code is taken from the settings implementation.
For testing/reference I changed the score of the Paddle game to be persistent.
What is missing?
Currently, I have a linker error I cannot get rid of. It's probably easy for someone who knows more about C++ than me.
Therefore it's not tested either.