Archived

This forum has been archived. Please start a new discussion on GitHub.

Transporting Arbitrary Recordsets Through Ice

I have a unique problem where I need to transfer recordsets through the Ice framework from a server to a client. The recordsets will quite literally be a subset of a server table, generated from a server-side view. Ideally the slice definition would simply be a struct definition followed by a sequence<somestruct> to hold the data. My problem is that the result sets will be user defined, and as such, I can't define the structure in the slice definition.

Here's a rough example.
module Metadata {
	enum FieldType {
		ftString,
		ftDate,
		ftNumber,
		ftBoolean
	};

	class Field {
		FieldType field_type;
	};
	
	class FieldString extends Field {
		string value;
	};
	
	class FieldDate extends Field {
		long value;
	};
	
	class FieldNumber extends Field {
		double value;
	};
	
	class FieldBoolean extends Field {
		bool value;
	};
	
	sequence<Field> Row;
	sequence<Row> Table;
};

On the client, I could get a Table, loop through each Row, then use the field_type property of the field to know what kind of Field to up-cast into. This seems a little awkward, especially since this will carry an additional byte of information (field type) per cell. I suppose I could come up with a hybrid structure.
module Metadata {
	struct FieldDef {
		string field_name;
		FieldType field_type;
	};

	class Field {};

	class FieldString extends Field {
		string value;
	};

	/* etc... */

	sequence<FieldDef> FieldDefs;
	sequence<Field> Fields;
	sequence<Fields> Data;

	struct Table {
		FieldDefs field_definitions;
		Data table_data;
	};
};

This looks a little better, but I'm open to any improvements in structure to make this better...

TIA

Comments

  • bernard
    bernard Jupiter, FL
    You don't really need to FieldType since you can extract the type of a class-instance from the object itself; but using a FieldType may be more convenient.

    What is your concern? If it's ease of use, then I'd pick something like your first solution. If it's bandwidth usage (because you transfer lots of data), then I'd recommend to look at Dynamic Ice.

    Cheers,
    Bernard