How to dump and restore an Object
Jump to navigation
Jump to search
TODO. Examples, understand better what really happens.
Problem. I want to dump an object and store it into the filesystem the recover it when I whish it will be a proper time. How do I do ?
Solution. There are several ways to solve this problem trading off simplicity and power. Let's go from the simplest to the most complex and powerful.
- Solution-1. The simplest, using
ObjectFoo>>storeString
or the equivalent for streams.- +] Very easy
- +] The dump is human readable
- -] It is not intended to dump cyclic structures
- -] The internal variables of ObjectFoo are stored by position, not by name. If you change the class ObjectFoo and then try to recover and old dump you will make a mess.
- Solution-2.
ReferenceStream>>dumpOnFile:
- -] more complex, it spits out a binary file
- +] restist to cycles in the data structure to dump
- Solution-3.
SmartRefStream>>dumpOnFile:
- -] even more complex, larger file, binary file
- +] resist to cycles
- +] resist to moderate changes in the ObjectFoo class because internal variable are stored with name and value.