Newsgroups: comp.parallel.pvm
From: jmartin@tractor.cs.uiowa.edu (Jeffrey Martin)
Subject: Re: Passing C++ objects
Organization: The University of Iowa, Iowa City, Iowa, USA
Date: 21 Feb 1996 21:25:18 -0600
Message-ID: <k6gd978ca8x.fsf@tractor.cs.uiowa.edu>

tjb <byer@pangea.stanford.edu> wrote:

> The examples for passing data between processes have shown how it is
> possible to pass variables and arrays of specific types.  How is
> this accomplished when you need to send a object, containing several
> data types of which some may be dynamically allocated, to another
> process.
>
> The worst case could be that the object needs the functionallity to
> send and recieve its variable/array components such that it could
> reconstruct itself.

Somehow, I don't see it as the worst case at all. Having an object
know how to pack and unpack itself seems reasonable to me. How else
would you pack private parts of the object? Normally, I just:

class Object
{
...
public:
   pack(void);
   unpack(void);
...
};

If you really want to imulate the pvm pack/unpacks, you could even
give a general pvm_pkObject function, like (or even template it)

int pvm_pkObject(Object* o, int nitem, int stride)
{
   int i;

   for (i = 0; i < nitem * stride; i += stride)
      o[i].pack();
}

