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=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,740e91341085efe3,start X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!o13g2000cwo.googlegroups.com!not-for-mail From: defaultuserbr@yahoo.com Newsgroups: comp.lang.ada Subject: Some help for a C++ guy Date: 7 Apr 2005 15:14:22 -0700 Organization: http://groups.google.com Message-ID: <1112912062.146885.324110@o13g2000cwo.googlegroups.com> NNTP-Posting-Host: 130.76.96.14 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1112912066 13759 127.0.0.1 (7 Apr 2005 22:14:26 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 7 Apr 2005 22:14:26 +0000 (UTC) User-Agent: G2/0.2 Complaints-To: groups-abuse@google.com Injection-Info: o13g2000cwo.googlegroups.com; posting-host=130.76.96.14; posting-account=jWLFKg0AAAA9UYjCwxeOEw3zdPk7tNz5 Xref: g2news1.google.com comp.lang.ada:10321 Date: 2005-04-07T15:14:22-07:00 List-Id: I've inherited some code that I'm expanding, and my Ada skills are somewhat weak, I mostly do C and C++. Our system will have multiple messages defined, with three essential components, a data buffer, a status buffer, and a callback. Currently this is defined in a generic package. The package spec follows: with MIL_STD_1553; with OS_Types; generic package Message_Handler is package M1553 renames MIL_STD_1553; procedure Message_Callback (Status : in M1553.IO_Status_T); function Num_Message_Callbacks return OS_Types.Unsigned_Word; function Num_Errors return OS_Types.Unsigned_Word; Data_Buf_Ptr : constant M1553.Data_Buf_VPtr_T := new M1553.Data_Buf; Stat_Buf_Ptr : constant M1553.Status_Buf_VPtr_T := new M1553.Status_Buf_T; end Message_Handler; Then in the implementation code, there's stuff like: package Message_0_Handler is new Message_Handler; package Message_5_Handler is new Message_Handler; The buffers and the callback have to be registered for each of these instantiated messages through another subroutine. I don't much like this. It's cumbersome even for a couple of messages, let alone when we grow to 20 or more, because we have duplicated code for each registration. What I'd like is to have some sort of array of the messages. That way one could iterate over the array and reduce duplicate code and chance for errors. I guess I'm thinking an OO approach, as long as the various members could be passed as arguments to the registration routines. We are working in Ada95. However one twist is that we are using Gnat Pro with something called a certifiable subset. Here some stuff about it: http://www.extensionmedia.com/windriver/datasheet.php?ds=2 I don't know much more myself, other than we can't use tasking. I understand that such limitations may make this too implementation-specific for a general newsgroup. Any help would be appreciated. Brian