[DUG] Automation types and blobs
Phil Middlemiss
phil at tumonz.co.nz
Wed May 31 16:34:52 NZST 2006
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: 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).
>
> _______________________________________________
> Delphi mailing list
> Delphi at ns3.123.co.nz
> http://ns3.123.co.nz/mailman/listinfo/delphi
>
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: phil.vcf
Type: text/x-vcard
Size: 250 bytes
Desc: not available
Url : http://ns3.123.co.nz/pipermail/delphi/attachments/20060531/2785d01d/phil.vcf
More information about the Delphi
mailing list