From -6856681829183379585
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 109fba,fa4c9935954c426
X-Google-Attributes: gid109fba,public
X-Google-Thread: 113dfb,fa4c9935954c426
X-Google-Attributes: gid113dfb,public
X-Google-Thread: 111308,fa4c9935954c426
X-Google-Attributes: gid111308,public
X-Google-Thread: f78e5,fa4c9935954c426
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-02-23 16:47:44 PST
Newsgroups: comp.client-server,comp.lang.c++,comp.std.c++,comp.os.ms-windows.programmer.win32
Path: bga.com!news.sprintlink.net!EU.net!chsun!pax!cho11884
From: cho11884@pax.eunet.ch (Koch Andres)
Subject: Re: Marshalling C++ Objects
Message-ID: <D4H6JJ.4st@eunet.ch>
Followup-To: comp.client-server,comp.lang.c++,comp.std.c++,comp.os.ms-windows.programmer.win32
Sender: usenet@eunet.ch
Organization: EUnet AG, Switzerland
X-Newsreader: TIN [version 1.2 PL2]
References: <3igf2v$kcd@epsilon.qmw.ac.uk>
Date: Thu, 23 Feb 1995 22:59:42 GMT
Lines: 34
Xref: bga.com comp.client-server:6557 comp.lang.c++:51848 comp.std.c++:6975 comp.os.ms-windows.programmer.win32:9454

Tariq Hamid (tariqh@dcs.qmw.ac.uk) wrote:
: How do you marshal/unmarshal C++ objects. It appears to be a difficult problem
: as the inheritance hierarchy has to be considered.

Not really. We used this approach in two project with message passing and
distributed processes with success. The best way (we think) is to make the
objects straemable by inheriting them from a base class which offers the
virtual interface such as CLASS::toStream and CLASS::fromStream, both take
a Stream Reference as parameter and returning the Reference too. You also
can use the operator>> or operator<< on the class, if you like.

The transporting media class gets the Object to send, and creates a stream
typically a streamable buffer, and then calls the toStream method of that
first class with the stream as parameter. The class firstly calls the
::toStream of his superclass and than puts its data to the stream. On the
receiving side you need to manufacture an empty object (of the same class)
typically using a factory and then call the ::fromStream method of the class
with the received stream. The class callss ::fromStream of his super class
and then unpacks the stream in the same way. This works really well and I
recommend that you look into the Rogue Wave tools++.h class lib, which offers
you various streams build on top of ios and a RWvistream/RWvostream which is
a virtual Stream, so that the class has not to know the format of the stream.
It also has a factory class RWFactory which is easy to use.

We also have built a Class-Lib using the RWtools++ in one project and 
have built an application frame work for distributed application based
on message passing (all C++) for our projects. It serves well, especially
when interfacing with legacy systems.

Hope this gives you some path to follow.
                                 
Andy Koch 
Koch System Engineering, Rossweid 10, CH-5619 Buettikon, Switzerland, 
Tel/Fax: +41 (0) 57 22 99 58                  email: akoch@itr.ch


