comp.lang.ada
 help / color / mirror / Atom feed
* problem with abstract types
@ 2002-10-31 12:06 Ulrich Eckhardt
  2002-10-31 13:15 ` John English
                   ` (3 more replies)
  0 siblings, 4 replies; 30+ messages in thread
From: Ulrich Eckhardt @ 2002-10-31 12:06 UTC (permalink / raw)


Hi,

i am starting my first project in ada (A complete rewrite
of WHFC, see my Homepage). For this i want to
write an OS independend way to store configuration
informations (on windows in the registry and on unix in
human readable config files).

Therefore my idea was to created a package registry wich defines
an abstract type registry and several abstract functions
and (at this time) one real function .

package registry is
   type registry is abstract tagged limited private;
   type registry_Access is access all registry'Class;

   procedure openRegistry(reg : in out registry; ..) is abstract;
   function getRegistry( .. ) return registry_Access
   [..]

Also i have created a child package registry.unix,
which implements the abstract functions for using on
unix:

  package registry.unix is
     type file_registry is new registry with private;
     procedure openRegistry(reg : in out file_registry; ..);  	
     [..]

Also i will create a package registry.win which does the
same for windows.
package registry.win is
     type win_registry is new registry with private;
     procedure openRegistry(reg : in out win_registry; ..);

The function getRegistry of the main package should return
and initialize now depending on the os a package registry.win
or registry.unix, since for the use of this package it
should not be visible on which platform it was compiled.

function getRegistry (a : in sys_access; p_name : in Unbounded_String)
   return registry_Access is
   r : registry_Access;
   begin
     if compiled = SYS_UNIX then
        r := new file_registry(s_access => a);
     else
        r := new win_registry();
     end if;
     return r;
end getRegistry;

So in a testprogramm i use :

with registry; use registry;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;

procedure main is
    reg : registry_Access;
    err : r_error;
begin
    reg := getRegistry(CLASS_USER,To_Unbounded_String("registrytest"));
    openRegistry(reg'access,err);
end main;

But when compiling this code i get a
main.adb:10:20: prefix of "access" attribute must be aliased

Any hints what i am missing, or comments how such things are better
done in ada?

Uli
-- 
Ulrich Eckhardt
http://www.uli-eckhardt.de




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

end of thread, other threads:[~2002-11-04 20:08 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-31 12:06 problem with abstract types Ulrich Eckhardt
2002-10-31 13:15 ` John English
2002-10-31 14:43   ` Ulrich Eckhardt
2002-10-31 17:18     ` Robert I. Eachus
2002-10-31 18:20       ` Jeffrey Carter
2002-10-31 20:58         ` Robert I. Eachus
2002-11-01 10:57       ` Ulrich Eckhardt
2002-11-01 12:05         ` Simon Wright
2002-11-01 17:03           ` Robert A Duff
2002-11-04 15:18             ` Robert I. Eachus
2002-11-04 16:14               ` Robert A Duff
2002-10-31 13:32 ` David C. Hoos
2002-10-31 13:47   ` problem with posters Peter Hermann
2002-10-31 14:15     ` Preben Randhol
2002-10-31 14:35   ` problem with abstract types Ulrich Eckhardt
2002-11-01  8:31     ` Dmitry A.Kazakov
2002-11-01 11:32       ` Ulrich Eckhardt
2002-10-31 15:31 ` Simon Wright
2002-10-31 17:22 ` Stephen Leake
2002-11-01 10:25   ` Ulrich Eckhardt
2002-11-04 14:30     ` Ted Dennison
2002-11-04 15:08     ` Ulrich Eckhardt
2002-11-04 15:32       ` Stephen Leake
2002-11-04 17:12         ` Ulrich Eckhardt
2002-11-04 17:43           ` David C. Hoos
2002-11-04 19:34             ` Ulrich Eckhardt
2002-11-04 19:54             ` Stephen Leake
2002-11-04 20:08             ` Robert A Duff
2002-11-01 11:15   ` Preben Randhol
2002-11-01 17:21     ` Stephen Leake

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