Archived
This forum has been archived. Please start a new discussion on GitHub.
Requesting suggestions for how to fake polymorphic values in Ice-E
I'm trying to implement something similar to the ShapeProcessor example presented in the manual (pps 123-124), but I want to do it in Ice-E.
The problem I've run into is Ice-E's lack of support for 1) pass-by-value for classes; and 2) sequences of objects. I'd really like to be able to do both of these in Ice-E.
So, does anyone have a suggestion for a good way to fake it? That is, if your ShapeProcessor was running on an embedded device, what would be the best way to modify the Slice (below) for Ice-E?
If I relaxed my requirements so that I could live without sequences of objects, would that help make faking things easier? The Slice could be:
Any ideas? Many thanks!
best,
chris
The problem I've run into is Ice-E's lack of support for 1) pass-by-value for classes; and 2) sequences of objects. I'd really like to be able to do both of these in Ice-E.
So, does anyone have a suggestion for a good way to fake it? That is, if your ShapeProcessor was running on an embedded device, what would be the best way to modify the Slice (below) for Ice-E?
class Shape { // Definitions for shapes, such as size, center, etc. }; class Circle extends Shape { // Definitions for circles, such as radius... }; class Rectangle extends Shape { // Definitions for rectangles, such as width and length... }; sequence<Shape> ShapeSeq; interface ShapeProcessor { void processShapes(ShapeSeq ss); };
If I relaxed my requirements so that I could live without sequences of objects, would that help make faking things easier? The Slice could be:
class Shape { // Definitions for shapes, such as size, center, etc. }; class Circle extends Shape { // Definitions for circles, such as radius... }; class Rectangle extends Shape { // Definitions for rectangles, such as width and length... }; interface ShapeProcessor { void processShape(Shape s); };
Any ideas? Many thanks!
best,
chris
0
Comments
-
Hi Chris,
There is no simple work-around. Maybe you could use structs and sequences of structs, e.g.struct Shape { // data members common to all shapes }; struct Circle { Shape shape; // Circle-specific data members }; struct Rectangle { Shape shape; // Rectangle-specific data members };
and then in your C++ or Java code, create wrappers that provide the desired polymorphic API.
processShapes is the most difficult. This could work for some applications:void processShapes(ShapeSeq ss, CircleSeq cs, RectangleSeq rs);
Cheers,
Bernard0