Re: copying a structure



Hi Michael,

Thank you very much for your help on this topic and on the cORBA-free
isuue.

Best regards,

Peter Van Osta

==============================================
Michael Meeks wrote:
> 
> Hi Peter,
> 
> On Wed, 2003-07-16 at 15:17, Peter Van Osta wrote:
> > Is it possible to receive a structure by the client from the server ?
> 
>         Of course.
> 
> > In the client I have declared some static structures of the same type as
> > some which I get back form the server. However I cannot do &mystruct =
> > get_struct_from_server( ... );
> 
>         Right - although 'static' variables are mostly a menace.
> 
> > I have to declare a structure *pointstruct and then use pointstruct =
> > get_struct_from_server( ... ); Afterwards I have to copy all the
> > elements of the structure "pointstruct" to "mystruct" one by one. The
> > next best thing would be to copy "pointstruct" intto "mystruct" in one
> > command, but the structures contain strings, so that would need special
> > CORBA-care ?
> 
>         So - there are several approaches, here is a simple one:
> 
> static MyType *ptr= NULL;
> 
> CORBA_free (ptr);
> ptr = MyMethod_getStruct (obj, ev);
> if (ev->_major != CORBA_NO_EXCEPTION)
>     ptr = NULL;
> 
>         Thus you don't bother with the copying action, but just use a static
> pointer.
> 
>         We have primitives inside the orb to do type informed deep structure
> copying, but we don't expose any that don't allocate eg.
> ORBit_copy_value, precisely because people get confused about ownership
> / lifecycle.
> 
>         HTH,
> 
>                 Michael.
> 
> --
>  michael@ximian.com  <><, Pseudo Engineer, itinerant idiot



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]