From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FREEMAIL_REPLYTO_END_DIGIT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,23c6847871d5deb4 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-11-30 00:26:09 PST From: Patrick Hohmeyer Subject: Re: Example of OSI package/data structure? Newsgroups: comp.lang.ada Reply-To: pi3_1415926536@yahoo.ca References: <3C04A024.DEAFCE6@meppen.sema.slb.com> <3C04C0AA.70073D03@meppen.sema.slb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8Bit User-Agent: KNode/0.3.2 Message-ID: <4mHN7.18776$Ju6.3148919@news20.bellglobal.com> Date: Fri, 30 Nov 2001 03:46:40 -0500 NNTP-Posting-Host: 65.94.190.113 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1007108608 65.94.190.113 (Fri, 30 Nov 2001 03:23:28 EST) NNTP-Posting-Date: Fri, 30 Nov 2001 03:23:28 EST Organization: Bell Sympatico Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Xref: archiver1.google.com comp.lang.ada:17207 Date: 2001-11-30T03:46:40-05:00 List-Id: 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