WIP: Generic memory persistence class#2171
WIP: Generic memory persistence class#2171minacode wants to merge 1 commit intoInfiniTimeOrg:mainfrom
Conversation
this aims at providing a simple interface to store and load program state to the memory.
|
Build checks have not completed. Possible reasons for this are:
|
|
Love this concept! I'll see if I can look at the linker error sometime soon, this week is looking busy for me though :( |
|
Hey there, I was asking similar questions (#2321), and was pointed here. I think I found the build error: Line 32 of I don't know if I can submit a change to this PR (I'm not a git/hub expert either), so hopefully this helps. A couple other things that I found while looking at this:
Another thing to consider: does this make more sense as a class template, or should the persistent data itself be the templated class? I ask because I can imagine a situation where an app might need access to more than one set of persistent data, or conceivably two apps might want to reference the same persisted data. |
|
Thank you, @owenfromcanada! That's a lot of good feedback 🙂 I will think about it and come back with a cleaner solution. |
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
Persistentand 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.his 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.