[serialization] Re-serialization ??
Is there a way to do a "re-serialization" of an object structure? Let's say I have a couple of objects, and I serialize them to "State A", then change a few things. Ideally, I'd like to just deserialize "State A" so that I get the objects back to that state, without boost::serialization creating new objects for me. Is it doable? (it is for an undo implementation) TIA /Rob
One way to do that could be to use the Memento pattern, as described in the book "Design Patterns" by Gamma et al. That is, create a new object that encapsulates the state of the original object. The state object would be the one serialized and de-serialized, and passed into and out of the original objects to modify the state. Regards, Markus. Robert Bielik wrote:
Is there a way to do a "re-serialization" of an object structure? Let's say I have a couple of objects, and I serialize them to "State A", then change a few things. Ideally, I'd like to just deserialize "State A" so that I get the objects back to that state, without boost::serialization creating new objects for me.
Is it doable? (it is for an undo implementation)
TIA /Rob _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Is there a way to do a "re-serialization" of an object structure? Let's say I have a couple of objects, and I serialize them to "State A", then change a few things. Ideally, I'd like to just deserialize "State A" so that I get the objects back to that state, without boost::serialization creating new objects for me.
absolutely. however i think this is only appropriate if you have very fine grained objects. my most recent encounter with serialization and undo/redo was in a diagram editor. it was important to track many small changes to object state (i.e. location) but simply serializing the object each time would have been overkill. much better to serialize a rectangle on its own. (apologies if this is a glimpse of the crashingly obvious!). jerry
In article <480F1DB6.9060000@xponaut.se>, robert.bielik@xponaut.se says...
Is there a way to do a "re-serialization" of an object structure? Let's say I have a couple of objects, and I serialize them to "State A", then change a few things. Ideally, I'd like to just deserialize "State A" so that I get the objects back to that state, without boost::serialization creating new objects for me.
Is it doable? (it is for an undo implementation)
TIA /Rob
I don't have an answer, but I do have a problem that is (I think) quite similar, which I was just planning to ask about today. In my case, I have a big graph of objects that I serialize. After serialization, that data is processed externally, and the results are serialized in a similar way. While de-serializing this updated data, I would like to merge it on the fly with my original data, just updating object state as necessary and using my existing object pointers where possible -- I want to avoid the memory and overhead of reading in the entire new object graph and then traversing it to merge it into my original objects. For example, in my original data set I serialize object A, and then object B with pointer-to-A. This data is processed, and I de-serialize the results. When I read (possibly modified) object A, I would like to update my existing object A with any changed state, and then (this is the part I don't know how to do) have the input archive use the address of my existing object A when it deserializes B. So my question is also... is this doable? More specifically, is it doable without modifying the existing library code? Thanks, Scott
New objects are created only in the case of pointers. Robert Ramey Robert Bielik wrote:
Is there a way to do a "re-serialization" of an object structure? Let's say I have a couple of objects, and I serialize them to "State A", then change a few things. Ideally, I'd like to just deserialize "State A" so that I get the objects back to that state, without boost::serialization creating new objects for me.
Is it doable? (it is for an undo implementation)
TIA /Rob
participants (5)
-
Jerry
-
Markus Svilans
-
Robert Bielik
-
Robert Ramey
-
Scott Howlett