How to store/load alternate object representations?
Ned Konz
ned at bike-nomad.com
Tue Aug 6 04:09:35 UTC 2002
Hi wizards,
I've made a new MorphProperties class to replace the
IdentityDictionaries that were in the otherProperties instvar of
MorphExtensions.
But I want to be able to write backwards-compatible files; this should
be pretty easy, as I can convert back and forth between
MorphProperties and IdentityDictionary objects.
So I overrode MorphExtension>>storeDataOn: to store an
IdentityDictionary instead of the MorphProperties:
MorphExtension>>
storeDataOn: aDataStream
"Store my properties as an IdentityDictionary for backwards
compatibility"
| oldProps |
oldProps _ otherProperties.
otherProperties _ otherProperties ifNotNil: [ IdentityDictionary
newFrom: otherProperties ].
[ super storeDataOn: aDataStream ] ensure: [ otherProperties _
oldProps ]
And then to read MorphExtensions back in, I have this:
readDataFrom: aDataStream size: varsOnDisk
"Fill in the fields of self based on the contents of aDataStream.
Return self.
Read in the instance-variables written by Object>>storeDataOn:."
super readDataFrom: aDataStream size: varsOnDisk.
otherProperties _ MorphProperties convertedFrom: otherProperties.
Problem is, when I store a project it still stores MorphProperties
obejcts (which don't load into older images).
What do I need to do to make sure that the MorphExtensions are always
stored with IdentityDictionaries?
Thanks,
--
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE
More information about the Squeak-dev
mailing list
|