comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: Idiom for a class and an object in Ada
Date: Mon, 18 Oct 2004 15:40:58 -0400
Date: 2004-10-18T19:28:49+00:00	[thread overview]
Message-ID: <41741971$0$91011$39cecf19@news.twtelecom.net> (raw)
In-Reply-To: 9175719.eWmeGlFrVu@linux1.krischik.com


"Martin Krischik" <krischik@users.sourceforge.net> wrote in message 
news:9175719.eWmeGlFrVu@linux1.krischik.com...
> Marin David Condic wrote:
>
>> Suppose I have a class with one or a limited set of objects. The objects
>> are "global" in the sense that they hang around from program startup
>> thru the entire life of execution. An example would be an A/D Converter
>> class - My little control box might have 3 or 4 A/Ds in it - they're
>> always there and I want the data associated with them to be static (not
>> declared on the stack.)
>>
>> Question: What is the preferred Ada idiom for defining such a creature?

See my previous post.  You could either declare the known instances in the 
package itself:

package AD_Converters is
   type AD_Converter (<>) is limited private;
   ... -- ops

   function Huey return AD_Converter;
   function Dewey return AD_Converter;
   function Louie return AD_Converter;

end AD_Converters;

The other possibility is to declare each function as a child:

package AD_Converters.Huey_Converters is
   function Huey return AD_Converter;
end;

Alternatively, you can hide the package like this:

function AD_Converters.Huey return AD_Converter; --spec

private package AD_Converters.Huey_Converters is
   Huey : AD_Converter;
   .. --whatever else is necessary for the Huey object
end;

with AD_Converters.Huey_Conveters;
function AD_Converters.Huey return AD_Converter is --body
begin
   return Huey_Converters.Huey;
end;


Whether you declare all the objects up in the root package or as child 
functions is determined by whether your application always manipulates the 
objects as a group (that's the case in the genealogy example), and how many 
unique dependencies each object has (if the library units you need to make a 
Huey object are the same as the library units you need to make a Dewey 
object, then they might as well be declared together).





  reply	other threads:[~2004-10-18 19:40 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-18 11:47 Idiom for a class and an object in Ada Marin David Condic
2004-10-18 12:14 ` Martin Krischik
2004-10-18 19:40   ` Matthew Heaney [this message]
2004-10-19 12:59   ` Marin David Condic
2004-10-19 14:46     ` Martin Dowie
2004-10-19 15:55       ` Matthew Heaney
2004-10-19 18:31         ` Martin Dowie
2004-10-19 15:52     ` Matthew Heaney
2004-10-18 12:26 ` Marius Amado Alves
2004-10-19  2:09   ` Jeffrey Carter
2004-10-19  3:28     ` Matthew Heaney
2004-10-19 12:53       ` Marin David Condic
2004-10-19 14:44         ` Matthew Heaney
2004-10-19 15:01           ` Dmitry A. Kazakov
2004-10-19 15:40             ` Matthew Heaney
2004-10-20  7:58               ` Dmitry A. Kazakov
2004-10-20 12:31                 ` Marin David Condic
2004-10-20 13:53                   ` Dmitry A. Kazakov
2004-10-20 15:23                   ` Matthew Heaney
2004-10-21 12:24                     ` Marin David Condic
2004-10-21 17:15                       ` Matthew Heaney
2004-10-20  5:39         ` Simon Wright
2004-10-20  7:24           ` Matthew Heaney
2004-10-20  8:39             ` Dmitry A. Kazakov
2004-10-21  1:36             ` Jeffrey Carter
2004-10-21  1:46               ` Matthew Heaney
2004-10-21  7:51                 ` Dmitry A. Kazakov
2004-10-21 12:45                   ` Matthew Heaney
2004-10-21 14:11                     ` Dmitry A. Kazakov
2004-10-22  1:04                 ` Jeffrey Carter
2004-10-22  1:36                   ` Matthew Heaney
2004-10-21 19:31               ` Kevin Cline
2004-10-21 22:02                 ` Matthew Heaney
2004-10-22  0:10                   ` Matthew Heaney
2004-10-21  8:25             ` Martin Dowie
2004-10-20 17:04           ` Matthew Heaney
2004-10-20 19:37             ` Simon Wright
2004-10-20 20:04               ` Matthew Heaney
2004-10-22  5:37                 ` Simon Wright
2004-10-20  1:10       ` Jeffrey Carter
2004-10-20  7:04         ` Matthew Heaney
2004-10-20 12:42           ` Marin David Condic
2004-10-20 12:55             ` Matthew Heaney
2004-10-20 15:27             ` Matthew Heaney
2004-10-21  1:36               ` Matthew Heaney
2004-10-19 12:38   ` Marin David Condic
2004-10-18 16:59 ` Matthew Heaney
2004-10-18 18:02 ` Martin Dowie
2004-10-19 13:06   ` Marin David Condic
2004-10-19 14:51     ` Martin Dowie
2004-10-20 16:20 ` Michael Paus
2004-10-20 17:15   ` Matthew Heaney
2004-10-20 17:55     ` Michael Paus
2004-10-21 12:33   ` Marin David Condic
  -- strict thread matches above, loose matches on Subject: below --
2004-10-21 13:59 Stephen Leake
replies disabled

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