[DUG] Automation types and blobs
Conor Boyd
Conor.Boyd at trimble.co.nz
Wed May 31 16:10:52 NZST 2006
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: delphi-bounces at ns3.123.co.nz [mailto:delphi-bounces at ns3.123.co.nz]
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).
More information about the Delphi
mailing list