Thanks Conor,
I didn't realise variant arrays were automation compatible - the help
doesn't indicate this. Would this work for a VB or C++ client app?
I'm wondering if I can shortcut the whole thing though - I have an
automation interface that represents, say, a polygon. Since the client
code still has to formulate a variant array (to pass to the
TStreamable), why not just pass the variant array to the polygon interface?
eg, IMyPolygon.AddPoints(Points : OleVariant);
Cheers,
Phil.
Conor Boyd wrote:
Look into creating some sort of streaming framework.
E.g.
Have a base TStreamable class.
Then declare "transport" type classes for each item of data you want to
pass between client and server.
Have your base TStreamable class know how to take a stream and turn it
into an OleVariant.
Have each of your transport classes implement a ReadFromStream and
SaveToStream method which writes the internal values of the object to
the stream.
E.g.
Tstreamable = class
Public
procedure ReadFromStream(Stream: Tstream); virtual;
procedure WriteToStream(Stream: Tstream); virtual;
function ToVariant: OleVariant;
procedure FromVariant(vrnt: OleVariant);
End;
TMyInfo = class(Tstreamable)
Private
FSomeInfo: String;
FSomeOtherInfo: Tpoint;
Public
procedure ReadFromStream(Stream: Tstream); override;
procedure WriteToStream(Stream: Tstream); override;
property SomeInfo: String read FSomeInfo write FSomeInfo;
property SomeOtherInfo; Tpoint read FSomeOtherInfo write
FSomeOtherInfo;
End;
Your TMyInfo class knows how to read and write it's internal fields
to/from a Tstream.
Your code that wants to send that info between client and server calls
ToVariant and FromVariant on the TMyInfo class and sends the OleVariant.
The ToVariant and FromVariant methods need to take a Tstream and turn it
into a VarArray of type varByte, which is the actual OleVariant that
gets transported.
I wrote this at some speed, so not sure if it'll make 100% sense
straight off. Let me know if you want more specifics or some sample
code.
I use this type of framework for transporting classes, records, arrays,
etc. You can chain this type of stuff together so that complex objects
in turn use the ReadFromStream/WriteToStream methods on internal fields
as appropriate.
HTH,
Conor
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Phil Middlemiss
Having read the help about which data types are automation compatible,
it seems there is no quick way to send a chuck of memory to an
automation object: The only option I can see is to send the data integer
by integer (if I'm sending TPoint then send X and Y for every point).
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi
begin:vcard
fn:Phil Middlemiss
n:Middlemiss;Phil
org:Vision Software, MTS Ltd
email;internet:[EMAIL PROTECTED]
title:Project Leader
tel;work:+64 7 3480001
tel;cell:+64 27 4592648
x-mozilla-html:TRUE
url:http://www.tumonz.co.nz
version:2.1
end:vcard
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi