comp.lang.ada
 help / color / mirror / Atom feed
From: Patrick Hohmeyer <pi3_1415926536@yahoo.ca>
Subject: Re: Example of OSI package/data structure?
Date: Fri, 30 Nov 2001 03:46:40 -0500
Date: 2001-11-30T03:46:40-05:00	[thread overview]
Message-ID: <4mHN7.18776$Ju6.3148919@news20.bellglobal.com> (raw)
In-Reply-To: 3C04C0AA.70073D03@meppen.sema.slb.com

Vincent Smeets wrote :

> Thank you for your reply. I will explain why I was thinking about type
> extension but I also will try to redesign using separate packages
> side-by-side. You have made me think in an other direction.

:) It's always good to look from different sides. ;)

> > First question :
> >   Why do you want to limite you to 2 vars in the ads?
> >   Might it be possible that you will reuse the package on
> >   a system with more than 2 devices?
> 
> not without a software change.

OK

> I was thinking of allowing something like:
> Data_Link.Send (
> Channel => Physical.Device_1'Access,
> Data    => "data");
> 
> I know the way of using limited types but then you have to control the
> number of open instances. I was thinking of having only two instances
> that are always open. That way I can leave out the controlling code.
> 

I type is something you can define variables of.
That's somehow the interest of a type.

You might choose to define the Device as an access type :

--------------------
type device is limited private;

Device_1 : T_Device;
Device_2 : T_Device;
--...

private

type T_Device;
type device is access T_device;
--------------------

and everytime you got an Null pointer passed, you know
that it wasn't one of the devices defined in the package.
Or (similiar) put an boolean ok field into the type that is initialised
to false and you set it to true for your 2 devices.
But this still enables the definition of variables outside the package,
they would only be useless.

I would prefere an enumeration type :
type devices is (Device_1,Device_2);

And then you have somewhere in the adb an array that maps the enumeration
to the actual device.

The device type will actually be in the private part,
so that only the child packages can define variables of it.

This limites the choice of the user to the 2 device
and he can even easily store wich device he had use.

But that's just my humble preference.

Oh, and there's the possibility of abstract types,
but to define an abstract type, just to prevent more instances
of a valid type sounds somehow like an abuse to me.
AND you'll have a strange hierarchy
(that might be non-valid in Ada, I haven't tested it) :

abstract device
  device
    abstract data link
      data link
        abstract ... etc.

-- 
Patrick Hohmeyer



  reply	other threads:[~2001-11-30  8:46 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-11-28  8:28 Example of OSI package/data structure? Vincent Smeets
2001-11-28  9:46 ` Patrick Hohmeyer
2001-11-28 10:47   ` Vincent Smeets
2001-11-30  8:46     ` Patrick Hohmeyer [this message]
2001-11-28 11:15 ` David C. Hoos
2001-11-28 11:59 ` Larry Kilgallen
2001-11-28 12:06 ` Lutz Donnerhacke
2001-11-28 14:49   ` Vincent Smeets
replies disabled

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