From: Gautier write-only <gautier_niouzes@hotmail.com>
Subject: Re: Record type as generic parameter
Date: Thu, 13 Aug 2009 06:34:31 -0700 (PDT)
Date: 2009-08-13T06:34:31-07:00 [thread overview]
Message-ID: <f47b6dcd-f7f6-46e5-95d8-527901007b74@f37g2000yqn.googlegroups.com> (raw)
In-Reply-To: ajp06h.ocv.ln@hunter.axlog.fr
On 13 Aug., 12:23, Jean-Pierre Rosen <ro...@adalog.fr> wrote:
> Any reason why you cannot make a generic package that would *export*
> Association and Scenario_Definition
No!
> (and procedure Fill_Scenarios),
Yes!
> rather than importing them?
So first of all, thanks for the very nice idea!
The "Yes!" is because the exporting generic package is in (or withed
by) a very low-level, satellite package, DB_Data.Geo, that basically
consists in data pumped (once for all) from a database in form of big
enumerated types and constant arrays. So it cannot "see" the
definitions needed for Fill_Scenarios.
But the "No!" is valid as well, considering the types used for
defining these scenarios.
So the solution is:
1) In the low-level package DB_Data.Geo.Links:
generic
type Scenario is (<>);
package Scenario_framework is
-- pairs:
type Association is record
scen: Scenario;
it : Item;
end record;
-- list of pairs:
type Scenario_definition is array(Positive range <>) of
Association;
end Scenario_framework;
package Dept_Xyz is new Scenario_framework
(DB_Data.Geo.Dept_Xyz_Scenario);
dept_xyz_scenario_definition: constant
Dept_Xyz.Scenario_definition:=
(
(Scen_abc, Item_56),
(Scen_abc, Item_345),
(Scen_uvw, Item_12),
2) In the high-level package:
generic
type Scenario is (<>);
with package Framework is new Scenario_framework(Scenario);
def: Framework.Scenario_definition;
procedure Fill_Scenarios;
One instanciation is then:
procedure Fill_Dept_Xyz_Scenarios is
new Fill_Scenarios(
Dept_Xyz_Scenario,
Dept_Xyz,
dept_xyz_scenario_definition
);
That's it!
Thanks again
_________________________________________________________
Gautier's Ada programming -- http://sf.net/users/gdemont/
NB: For a direct answer, e-mail address on the Web site!
next prev parent reply other threads:[~2009-08-13 13:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2009-08-13 10:30 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox