Hiya,
I am trying to stream objects of various tagged types between two
boxes.
There are different compilers at each end with differing
Ada.Tags.External_Tags. One compiler (GNAT) has an external
representation the same as the Ada.Tags.Expanded_Name (defined by the
language to be all capitals) and the other compiler uses the same string
but all lower case.
In order to guarantee compatibility at each end, i wish to redefine the
'Class'Output (and 'Class'Input) for my base type to use the (language
defined) Expanded_Name in the stream rather than the external tag...
like so:
type Abstract_Command_Type is abstract tagged null record;
procedure Abstract_Command_Type_Output (
Stream : access Ada.Streams.Root_Stream_Type'Class;
Item : in Abstract_Command_Type'Class);
for Abstract_Command_Type'Class'Output use
Abstract_Command_Type_Output;
My problem is in completing the body of Abstract_Command_Type_Output.
procedure Abstract_Command_Type_Output (
Stream : access Ada.Streams.Root_Stream_Type'Class;
Item : in Abstract_Command_Type'Class) is
begin
String'Output (
Stream, Ada.Tags.Expanded_Name(Item'Tag)));
-- How do I now 'Output the rest of the object... the formal
-- Item only gives me its class...
--
-- This won't work... ideas???
--
Abstract_Command_Type'Output (Stream, Item);
end Abstract_Command_Type_Output;
Perhaps you could suggest how I can complete this Output procedure to
'Output the rest of the object? Or comment on the sanity of overriding
'Class'Ouput and 'Class'Input.
Beyond the problem of actually outputting the rest of the object, one
issue I came across is that, if I extend the Abstract_Command_Type and
do not further override 'Class'Output for the extension, I expect that I
will inherit procedure Abstract_Command_Type_Output for my extension.
Unfortunately, this does not seem to occur. For example:
type Clock_Command_Type is new Abstract_Command_Type with
record
Data : Integer;
end record;
Command : Clock_Command_Type := (
Data => 4);
Clock_Command_Type'Class'Output(<some_stream>, Command);
This does not use Abstract_Command_Type_Output but rather the exisitng,
compiler defined 'Class'Output generated for the extension
Clock_Command_Type without reference to the redefinition for to use
Abstract_Command_Type_Output.
Any assistance would be great.
Thanks,
matt
--
-- Matt Brennan || Vision Systems Ltd || +61 8 8300 4686
--