Re: [BLACKBOX] Storing an extended object

From: [at]} <Josef>
Date: Tue, 11 Nov 2008 10:03:26 +0100

----boundary-LibPST-iamunique-406873322_-_-
Content-type: text/plain

Make the Externalize method EXTENSIBLE.
Then you can overwrite it in the sub class.
I would not recommend to handle sub classes in
the base class.

Note:
The general convention is, as far as I undestand it,
to (1) call the super method and (2) to store a version code
and (3) to store the data.
Storing a (one byte) version code gives you the opportunity to
change the persistent file format later without
invalidating any existing files.
Internalize would then of course have to support all
previous formats.
The storage overhead is acceptable.

- JT



----- Original Message -----
From: "Douglas G. Danforth" <danforth{([at]})nowhere.xy
To: <BLACKBOX{([at]})nowhere.xy
Sent: Tuesday, November 11, 2008 12:20 AM
Subject: [BLACKBOX] Storing an extended object


>I am not quite sure how to implement the Externalize and Internalize
> procedures
> for objects that are an extension of a base type. If I write an
> Externalize procedure
> (one for the base and one for the extension) then BB complains. So must
> I do something
> like the following?
>
> TYPE
> Base = POINTER TO EXTENSIBLE RECORD(Stores.Store)
> data: INTEGER
> END;
> Sub = POINTER TO RECORD(Base)
> moreData: INTEGER;
> END;
>
> PROCEDURE (base: Base) Externalize- (VAR wr: Stores.Writer);
> BEGIN
> wr.WriteInt(base.data);
> WITH base: Sub DO
> wr.WriteInt(base.moreData);
> ELSE
> END
> END Externalize;
>
> But now when I internalize what must I do?
>
> This seems cumbersome and not very elegant.
> -Doug Danforth


----
To unsubscribe, send a message with body "SIGNOFF BLACKBOX" to LISTSERV{([at]})nowhere.xy----boundary-LibPST-iamunique-406873322_-_-
Content-type: application/rtf
Content-transfer-encoding: base64
Content-Disposition: attachment; filename="rtf-body.rtf"
e1xydGYxXGFuc2lcYW5zaWNwZzEyNTJcZnJvbXRleHQgXGRlZmYwe1xmb250dGJsDQp7XGYwXGZz
d2lzcyBBcmlhbDt9DQp7XGYxXGZtb2Rlcm4gQ291cmllciBOZXc7fQ0Ke1xmMlxmbmlsXGZjaGFy
c2V0MiBTeW1ib2w7fQ0Ke1xmM1xmbW9kZXJuXGZ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xwYXINCj4gICAgUFJPQ0VEVVJFIChiYXNlOiBCYXNlKSBFeHRlcm5hbGl6
ZS0gKFZBUiB3cjogU3RvcmVzLldyaXRlcik7XHBhcg0KPiAgICBCRUdJTlxwYXINCj4gICAgICAg
d3IuV3JpdGVJbnQoYmFzZS5kYXRhKTtccGFyDQo+ICAgICAgIFdJVEggYmFzZTogU3ViIERPXHBh
cg0KPiAgICAgICAgICB3ci5Xcml0ZUludChiYXNlLm1vcmVEYXRhKTtccGFyDQo+ICAgICAgIEVM
U0VccGFyDQo+ICAgICAgIEVORFxwYXINCj4gICAgRU5EIEV4dGVybmFsaXplO1xwYXINCj4gXHBh
cg0KPiBCdXQgbm93IHdoZW4gSSBpbnRlcm5hbGl6ZSB3aGF0IG11c3QgSSBkbz9ccGFyDQo+IFxw
YXINCj4gVGhpcyBzZWVtcyBjdW1iZXJzb21lIGFuZCBub3QgdmVyeSBlbGVnYW50LlxwYXINCj4g
LURvdWcgRGFuZm9ydGhccGFyDQpccGFyDQpccGFyDQotLS0tXHBhcg0KVG8gdW5zdWJzY3JpYmUs
IHNlbmQgYSBtZXNzYWdlIHdpdGggYm9keSAiU0lHTk9GRiBCTEFDS0JPWCIgdG8gTElTVFNFUlZA
TElTVFMuT0JFUk9OLkNIXHBhcg0KfQ==
----boundary-LibPST-iamunique-406873322_-_---
Received on Tue Nov 11 2008 - 10:03:26 UTC

This archive was generated by hypermail 2.3.0 : Thu Sep 26 2013 - 06:30:51 UTC