-
Saving objects
I wonder if there is any way to save instances of objects keeping all the relations self-consistent after loading them back.
The problem i see is that pointers would become corrupted after the objects being reloaded into memory. Is there a way to get over that? or do i have to write my own algorithms?
Thanks in advance :)
-
You could 1) index your objects and store the indexes with them. 2) sort your objects by pointer and then have each objects look up their reference's order.
-
thanks. I assume that there is no such automated method. I will use your 1rst) option ;)
thankye!! :D
-
no problemo :) the first will use some extra memory under runtime, so if you don't have too many possible solution for some object references, always try find it in it's array and store the index instead.
Good luck ;)
-
As a note - if you're using MFC:
DECLARE_SERIAL and IMPLEMENT_SERIAL allow you to use CArchive which handles all the overhead of reading/writing any object to/from disk.
SDK - stick with Kedaman's ideas.