|
|
|
|||||
|
Hello,
I am a newbie and looking at ice-e now as 1st time. I am basically in the same need: defining a variant type to serialize/deserialize over the wire. In SOAP I use anytype for that. With slice (ICE-E), how I define a variant that can hold a sequence of bytes? class VariantBINARY extends Variant { sequence<byte> value; }; would pops a syntax error. Thanks in advance, Marco Monguzzi Last edited by mmongu : 04-05-2007 at 06:36 AM. |
|
||||||
|
You cannot directly use a sequence like that. You must first typedef it and use the resulting type. sequence<byte> is pre-defined in slice/Ice/BuiltinSequences.ice. So you can do something like:
#include <Ice/BuiltinSequences.ice> class VariantBINARY extends Variant { Ice::ByteSeq value; }; Also note that with Ice-E you cannot send a class by-value over the wire. |
|
|||||
|
Hi Matthew,
thanks for your reply. Quote:
enum VTYPE { VTEMPTY, VTBIT, VTBYTE, VTSHORT, VTINT, VTUBYTE, VTUSHORT, VTUINT, VTFLOAT, VTDOUBLE, VTSTRING, VTBINARY, VTTIME }; struct Timestamp { long utc; short msec; }; //FIXME: need support for UBYTE, USHORT, UINT class Variant { VTYPE type; }; class VariantBIT extends Variant { bool value; }; class VariantBYTE extends Variant { byte value; }; class VariantSHORT extends Variant { short value; }; class VariantINT extends Variant { int value; }; class VariantFLOAT extends Variant { float value; }; class VariantDOUBLE extends Variant { double value; }; class VariantSTRING extends Variant { string value; }; class VariantTIME extends Variant { Timestamp value; }; //FIXME: binary as seq of bytes? class VariantBINARY extends Variant { Ice::ByteSeq value; }; struct TRV { int ec; Timestamp ts; byte qual; Variant value; }; I see I can compile with slice2cpp for ICE but not for ICE-E. As you mentioned slice for ICE-E warns that 'struct data member 'value' cannot be a value object'. Should I consider the full blown ICE? Thanks Marco |
|
||||||
|
One way to emulate a union with Ice-E is to do the following:
Code:
enum Discriminator { A, B, C };
sequence<TypeA> ASeq;
sequence<TypeB> BSeq;
sequence<TypeB> CSeq;
struct Variant {
Discriminator activeType;
ASeq a;
BSeq b;
CSeq c;
};
This is not quite as convenient as using derived classes but, in practice, it's workable, and it is quite efficient: the empty sequences consume only a single byte each on the wire. Cheers, Michi. |
|
||||||
|
Hi Marco,
This very much depends on your target platform. If you have just a few MBs of flash and RAM, then you should probably use Ice-E. Otherwise, you can use Ice. In particular, if your target is a regular Intel/AMD Linux/Windows system, there is no compelling reason to use Ice-E instead of Ice. Best regards, Bernard |
|
|||||
|
Quote:
thanks for your reply. My test case would target custom embedded platforms as servers (MIPS vr4131@200MHz/wce4.2/64MB RAM/128MB flash) and commercial PDA/mobiles as clients (WCE5 and symbian). Even thought the work behind the full ICE is amazing, I am afraid it wouldn't fit my needs. The idea is comparing against rtcorba, embedded soap and custom protocols. Marco |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Deprecating Classes in ICE | kamran | Help Center | 1 | 09-07-2006 06:57 PM |
| C# classes | semerich | Comments | 3 | 02-08-2006 09:23 AM |
| Sequence of 'unions'? | dwolfe5272 | Help Center | 6 | 10-18-2004 05:38 PM |
| About Classes as Unions | level | Help Center | 2 | 04-09-2004 02:45 AM |
| Why operations on classes? | bernard | Comments | 1 | 02-21-2003 11:36 AM |