comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <martin@krischik.com>
Subject: Re: OO problem: Performing actions on messages (very long, sorry)
Date: Wed, 22 Dec 2004 19:16:30 +0100
Date: 2004-12-22T19:16:30+01:00	[thread overview]
Message-ID: <1285664.R9jkH16bOA@linux1.krischik.com> (raw)
In-Reply-To: 1103737351.196460.85450@f14g2000cwb.googlegroups.com

per wrote:

> Hi Dimitri, thanx for your answers.
> 
> Sorry for the yucky code/text. All indentation and line breaks was
> screwed up:( I'm using google groups (for the first time). Not very
> user friendly. Had to compose this answer in a separate file and
> manually paste in the citations so this answer is also a bit yucky...
> 
>>> Each action child shall be able to "do something" with a message in
> the
>>> virtual (is that the Ada term?) procedure Execute.
>>
>>No. It is called "primitive operation".
> 
> OK. But is there no distinction between operations that may dispatch
> and those those who cannot? Execute, for example, may be a primitive
> operation of each child regardless of if the parent has declared it or
> not. So "primitive operation" doesn't tell that dispatching will be
> possible or not, right?

All primitve operations dispach.

>>> The action Action.Override serves as an example in this post. This
>>> action shall override a field in a message.
>>
>>One cannot override a field. Presently Ada's inheritance model is a
> type
>>extension one. I.e. you can add a field, but not replace it with
> another.
> 
> No! I was unclear. I'm not trying to override anything in that sense.
> 
> The messages are basically records filled with values. It's the
> _values_ in the existing message structures the Action.Override is
> supposed to override:
 
> type Instance is new Message.Instance with
> record
> A : Float;
> B : Integer;
> ...
> end record;

Maybe you want to read about a "variant record":

http://en.wikibooks.org/wiki/Programming:Ada:Types:record#Variant_Record

It just might get you a new idea. 

> Somewhere some mechanism assigns the initial values:
> M1 : Message.M1.Instance;
> Put_A(M1, 1.0);
> Put_B(M1, 1);

You could try a qualified expression:

http://en.wikibooks.org/wiki/Programming:Ada:Subtypes#Evaluate_As
 
>>procedure Put (M : Instance; A : ArgumentType) is
>>begin
>>  M.Extension := A;
>>end Put;
> 
> You're saying I should replace every single field in every message
> record with an extension as above?

Well, a variant record initialized by a qualified expression might be the
better option.
 
With Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com



  reply	other threads:[~2004-12-22 18:16 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-22 13:49 OO problem: Performing actions on messages (very long, sorry) per
2004-12-22 15:17 ` Dmitry A. Kazakov
2004-12-22 16:28 ` Martin Krischik
2004-12-22 17:42   ` per
2004-12-22 18:16     ` Martin Krischik [this message]
2004-12-22 19:54     ` Dmitry A. Kazakov
2005-01-03 12:37       ` per
2005-01-03 14:14         ` Dmitry A. Kazakov
2005-01-04 12:05           ` per
2005-01-04 13:30             ` Dmitry A. Kazakov
2005-01-04 15:21               ` per
2005-01-04 17:47                 ` Dmitry A. Kazakov
2005-01-05 12:01                   ` per
2005-01-05 13:23                     ` Dmitry A. Kazakov
2005-01-05 15:59                       ` per
2005-01-05 20:44                         ` Dmitry A. Kazakov
2005-01-10  8:42                           ` per
2005-01-10 14:22                             ` Dmitry A. Kazakov
2005-01-10 16:24                               ` per
2005-01-10 19:09                                 ` Dmitry A. Kazakov
2005-01-11  9:06                                   ` per
2004-12-22 17:46   ` per
2004-12-22 18:02     ` Martin Krischik
2005-01-03 10:05       ` per
2004-12-22 18:35     ` u_int32_t
2004-12-22 18:38       ` u_int32_t
2004-12-24 18:52 ` Nick Roberts
2005-01-03 16:59   ` per
2005-01-10 12:10   ` per
2005-01-10 13:49     ` Marius Amado Alves
2005-01-10 21:54 ` Simon Wright
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox