comp.lang.ada
 help / color / mirror / Atom feed
* Record type as generic parameter
@ 2009-08-13  9:52 Gautier write-only
  2009-08-13 10:23 ` Jean-Pierre Rosen
  2009-08-13 10:30 ` Jacob Sparre Andersen
  0 siblings, 2 replies; 4+ messages in thread
From: Gautier write-only @ 2009-08-13  9:52 UTC (permalink / raw)


Hello,
Let's say I have an enumerated type called Scenario, and I want to
fill some data structure with the following information: for each
scenario, I have a certain number of items (of a defined type), which
is varying according to the scenario. That information is stored in an
array with pairs (scenario, item). An item might by appearing in
several scenarios, it is why I don't have simply an array(Item) of
Scenario. Everything fine up to now. Now, I would like to make it
generic, since I have several sets of scenario - i.e. different
enumerated types like Scenario. Then, my favourite Ada compiler
doesn't want a record as generic parameter:

      generic
        type Scenario is range <>;
        type Association is record
          scen: Scenario;
          it  : Item;
        end record;
        scenario_definition: array(Positive range <>) of Association;
      procedure Fill_Scenarios;

Any nice workaround ?
A not-so-nice one is to have two arrays, one array of Scenario, one
array of Item.
Ideally I would keep the type like Association above.
  XY_scenario_definition:
    constant array(Positive range <>) of XY_Association:=
    (
      (Scen_abc, Item_56),
      (Scen_abc, Item_345),
      (Scen_uvw, Item_12),
     ..
The data are easier to pump from a database directly as Ada sources,
they are then easier to read, and there is no chance of messing
positions as with the two arrays solution.
TIA
_________________________________________________________
Gautier's Ada programming -- http://sf.net/users/gdemont/
NB: For a direct answer, e-mail address on the Web site!




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-08-13 13:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-13  9:52 Record type as generic parameter Gautier write-only
2009-08-13 10:23 ` Jean-Pierre Rosen
2009-08-13 13:34   ` Gautier write-only
2009-08-13 10:30 ` Jacob Sparre Andersen

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