comp.lang.ada
 help / color / mirror / Atom feed
From: Sebastian Madunic <Sebastian.Madunic@avionics.saab.se>
Subject: Re: Generic and Access problem
Date: Thu, 9 Jan 2003 11:33:28 +0100
Date: 2003-01-09T11:33:28+01:00	[thread overview]
Message-ID: <mailman.1042108262.20315.comp.lang.ada@ada.eu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 446 bytes --]

Strange I didn't have any problems opening it, anyway here is another try...

/S

"Grein, Christoph" <christoph.grein@eurocopter.com> wrote in message
news:<mailman.1042107482.19914.comp.lang.ada@ada.eu.org>...
> At least here, the attachment looks like:
> 
> > 
> > begin 600 generic_pool.ads
> > M9V5N97)I8PT*("`@+2T@5&AI<R!I<R!T:&4@='EP92!F;W(@=&AE(&]B:F5C
> > M=',@=&AA="!C;VUP<FES97,@=&AE('!O;VP-"B`@('1Y<&4@271E;5]4>7!E
> 
> Rest omitted.


[-- Attachment #2: generic_pool.adb --]
[-- Type: application/octet-stream, Size: 878 bytes --]

--with System.Address_To_Access_Conversions;

package body Generic_Pool is
------------------------------------------------------------------------
   -- Public types and objects
   Dummy_Item : aliased Item_Type;


   -- create an access-to-variable view of the pool:
--   package Access_Conversions is new
--      System.Address_To_Access_Conversions (Id_Type);

------------------------------------------------------------------------
   -- Returns a reference to the indexed item. 

   function Item (P : Id_Type; Ix : Index_Type) return Reference_Type is
      -- create an access-to-variable view of the pool:
--      P_Ref : constant Access_Conversions.Object_Pointer :=
--         Access_Conversions.To_Pointer(P'Address);
   begin
         return P.Buf(Ix)'access;
   end Item;

------------------------------------------------------------------------
end Generic_Pool;

[-- Attachment #3: generic_pool.ads --]
[-- Type: application/octet-stream, Size: 1000 bytes --]

generic
   -- This is the type for the objects that comprises the pool
   type Item_Type is private;

   -- This is the type for the index that are used to access the objects
   -- of the pool. 
   type Index_Type is (<>);

package Generic_Pool is
------------------------------------------------------------------------
   -- Public types and objects

   type Id_Type is private;
   type Reference_Type is access all Item_Type;

------------------------------------------------------------------------
   -- Returns a reference to the indexed item. 
   function Item (
      P : Id_Type;
      Ix : Index_Type)
      return Reference_Type;

------------------------------------------------------------------------
   -- Private types
private
   type Buffer_Type is array (Index_Type) of aliased Item_Type;

   type Id_Type is
   record
      Buf       : Buffer_Type;
      None_Allocated_Yet : Boolean := True;
      Last_Used   : Index_Type := Index_Type'First;
   end record;
   
end Generic_Pool;

             reply	other threads:[~2003-01-09 10:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-09 10:33 Sebastian Madunic [this message]
     [not found] <avjgbd$m7e$1@newstoo.ericsson.se>
2003-01-09 14:13 ` Generic and Access problem David C. Hoos
  -- strict thread matches above, loose matches on Subject: below --
2003-01-09 11:03 Grein, Christoph
2003-01-09 10:10 Grein, Christoph
replies disabled

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