Fyttyn
Member
|
polymorphic serialization?
how should i go about saving and loading derived types? For classes like abilities, actions, skills, etc?
In unity since it was C# I could serialize something called an assemblyqualifiedname, then deserialize once to the base class to read it, and a second time into the correct class. It also had a way to serialize whole classes with JsonUtility i think? This let me make persistent components that I could easily extend for easy saving and loading. I'm not sure how to do this with derived classes in C++ or Esenthel or if it's possible
(This post was last modified: 01-31-2020 05:02 AM by Fyttyn.)
|
|
01-31-2020 04:44 AM |
|
RedcrowProd
Member
|
RE: polymorphic serialization?
You could use virtual classes, you can call parent func and derived class func
you can call in derived class super.savefunc and then do your savefunc of derived class
You will have to do full serialization by yourself, but its really not hard and you can use chunk to make it more consistent if you are having hard time
I believe my savemanager does something similar
(This post was last modified: 01-31-2020 04:00 PM by RedcrowProd.)
|
|
01-31-2020 08:03 AM |
|
Fyttyn
Member
|
RE: polymorphic serialization?
(01-31-2020 08:03 AM)RedcrowProd Wrote: You could use virtual classes, you can call parent func and derived class func
you can call in derived class super.savefunc and then do your savefunc of derived class
You will have to do full serialization by yourself, but its really not hard and you can use chunk to make it more consistent if you are having hard time
I believe my savemanager does something similar
sorry, i'm a noob.
What if I have a Memx of custom class pointers? How would I know which derived class to deserialize into? Like for example Memx<Ability*> or Memx<Action*> where there may be different derived types.
|
|
01-31-2020 06:31 PM |
|
RedcrowProd
Member
|
RE: polymorphic serialization?
Oh ok, in that case i would have all the custom save func in my savemgr and pass along my file to avoid some spaghetti saving happening
I would :
Call savemgr.savegame()
In that func call saveaction() then saveability() passing your &file
In those func do file.cmpintv(memx.elems) repao(memx.elms).save
To load it then just do in the same order the loading and you can populate your class with saved var
(This post was last modified: 02-01-2020 08:52 AM by RedcrowProd.)
|
|
01-31-2020 11:50 PM |
|