Xref: utzoo comp.lang.c++:5593 comp.object:449 Path: utzoo!attcan!uunet!cs.utexas.edu!mailrus!ames!sun-barr!lll-winken!arisia!sgi!shinobu!odin!warp.sgi.com!kipp From: kipp@warp.sgi.com (Kipp Hickman) Newsgroups: comp.lang.c++,comp.object Subject: Re: Shippable C++ Objects (RFC) Message-ID: <1542@odin.SGI.COM> Date: 20 Nov 89 17:49:35 GMT References: <31.UUL1.3#5109@pantor.UUCP> Sender: news@odin.SGI.COM Reply-To: kipp@warp.sgi.com (Kipp Hickman) Organization: Silicon Graphics, Entry Systems Division Lines: 24 To eliminate the ``switch'' implied by the object reconstruction mechanism, all you need is a dictionary. The key is the tag which identifies the object in its byte stream form (a string works nicely). The value is a pointer to a function to perform the reconstruction. Usually, the function is encode thusly: void (*reader)(ObjectReader& source, void* where); The "source" argument specifies the source of the byte stream, and provides operations to retrieve data (could be a stream, for instance). The "where" argument provides an (optional) address where the object should be placed, for the cases where the object is imbedded, and shouldn't allocate its own memory. In C++ 2.0, you implement the above function as follows: void FooReader(ObjectReader& source, void* where) { Foo* f = new(where) Foo(source); } Lots of details left as an exercise to the reader... :-) kipp hickman silicon graphics inc.