comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: Variant records..
Date: Tue, 17 Feb 2004 10:31:23 -0500
Date: 2004-02-17T10:31:23-05:00	[thread overview]
Message-ID: <i6ydneSMe-RWrq_d4p2dnA@comcast.com> (raw)
In-Reply-To: <e8f9995c.0402170656.45b1aa3d@posting.google.com>

Ganesh Ramasivan wrote:

> Anyways, in the case above, how can I pass a second discriminant. This
> is because I need to be able to select a particular command for a
> particular radar.

One way is:

  type RADAR_TYPE_CHOICE is (RADAR_A, RADAR_B);

  type RADAR_COMMAND_CHOICE is (RADAR_STATE,
                                RADAR_MODE,
                                RADAR_DISPLAY_RANGE_SELECT);

  type RADAR_COMMAND_TYPE
       (RADAR_TYPE_CHOICE := RADAR_A;
        RADAR_COMMAND_CHOICE := RADAR_STATE)is
     record
       case RADAR_COMMAND_CHOICE is
       when RADAR_DISPLAY_RANGE_SELECT =>
         < a whole bunch of parameters...>
         case RADAR_TYPE_CHOICE is
         when RADAR_A =>
           <Radar A specific parameters>
         when RADAR_B =>
           <Radar B specific parameters>
         end case;
       when others =>
         null;
       end case;
     end record;

But with this approach, you can't have indentically named elements that 
are of different types or subtypes for Radars A and B.  You can of 
course give those parameters different names.

Or you can have:

     type Radar_A_Display_Range_Select is...
     type Radar_B_Display_Range_Select is...

type RADAR_COMMAND_TYPE
       (RADAR_TYPE_CHOICE := RADAR_A;
        RADAR_COMMAND_CHOICE := RADAR_STATE)is
     record
       case RADAR_COMMAND_CHOICE is
       when RADAR_DISPLAY_RANGE_SELECT =>
         case RADAR_TYPE_CHOICE is
         when RADAR_A =>
              RADAR_A_DISPLAY_RANGE: RADAR_A_DISPLAY_RANGE_SELECT;
         when RADAR_B =>
              RADAR_B_DISPLAY_RANGE: RADAR_B_DISPLAY_RANGE_SELECT;
         end case;
       when others =>
         null;
       end case;
     end record;

The potential probleme with this approach is the potentially long names 
for the individual elements.  However, if you set the command via an 
aggregate, that problem goes away.  (Unless your software development 
plan requires named notation for aggregates. ;-)

Either style works.  Does this answer your question?

-- 
                                           Robert I. Eachus

"The war on terror is a different kind of war, waged capture by capture, 
cell by cell, and victory by victory. Our security is assured by our 
perseverance and by our sure belief in the success of liberty." -- 
George W. Bush




  reply	other threads:[~2004-02-17 15:31 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-15 22:51 Variant records Ganesh Ramasivan
2004-02-16 10:57 ` Preben Randhol
2004-02-16 15:25   ` Ganesh Ramasivan
2004-02-16 15:46     ` Ludovic Brenta
2004-02-16 16:16     ` Preben Randhol
2004-02-17 14:37       ` Ganesh Ramasivan
2004-02-17 15:43         ` Preben Randhol
2004-02-16 16:59   ` Ganesh Ramasivan
2004-02-16 20:14     ` Simon Wright
2004-02-17 14:56       ` Ganesh Ramasivan
2004-02-17 15:31         ` Robert I. Eachus [this message]
2004-02-16 23:17 ` tmoran
  -- strict thread matches above, loose matches on Subject: below --
1999-09-14  0:00 Variant Records Shawn Barber
1999-09-14  0:00 ` Mark Lundquist
1999-09-14  0:00 ` David C. Hoos, Sr.
1999-09-14  0:00 ` Matthew Heaney
1986-10-31  9:08 variant records Dean Luick
1986-11-03 14:17 ` Bev Sobelman
1986-11-05 16:35 ` stuart
1986-11-06 15:40 ` stt
replies disabled

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