Proper way to save and load object linked list / container / graph like structures
1 view (last 30 days)
Show older comments
Hi everyone,
I'm currently developing a rather large and complex data structure based around Matlab's OOP. I have a central container object that stores a bunch of other objects (2 different kinds, similar to edges and nodes), where always some objects of one kind have some objects of the other kind as property defined. Hence it's very similar to a linked list / tree / graph. These objects perform complex computations that are based around their linked neighbourhood. To save computations I save these objects in a .mat file. But after loading I get a lot of undesired behaviour where property values have not been saved properly and/or are restored wrong on loading. While playing around with some low level test examples I could not really reproduce this behaviour, hence it's hard for me to post example code. But I asserted that when I inspect the properties prior to saving everything is correct. After saving values are restored falsely, but when I force recomputation of these values they give me the correct property value again. But the whole idea of saving the objects was to avoid recomputation, so that is not a solution.
Interestingly while playing around with low level examples I found the order of calls to loadobj interesting: The first one to be called when I'm loading the container object is not the container but rather one of the smaller objects. Now the issue is that the object in the property values are instantiated with skeleton objects and the loadobj call is completed without loading these ones. Rather every smaller object is loaded after another while swapping between the two different kinds and then the container is restored.
Therefore I'm very confused what would be the correct way of changing saveobj and loadobj to restore this linked data structure. For sure I can save the result of the computations as fields in an struct, but how would I recreate the links when the entries in the fields in the struct are empty skeleton objects?
Hope you can help me!
David
0 Comments
Answers (0)
See Also
Categories
Find more on Use COM Objects in MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!