comp.lang.ada
 help / color / mirror / Atom feed
From: "Robert I. Eachus" <rieachus@comcast.net>
Subject: Re: allocation of an array
Date: Mon, 01 Mar 2004 21:49:30 -0500
Date: 2004-03-01T21:49:30-05:00	[thread overview]
Message-ID: <38qdnRRBtNuna97d4p2dnA@comcast.com> (raw)
In-Reply-To: <c1vt3t$np4$1@e3k.asi.ansaldo.it>

Davide wrote:

> My machine is a Power-PC with 32-bit alignment. My compiler is AdaMulti.
> I must download long messages composed of 16-bit integers items from a FIFO
> memory device.
> In my implementation I store them into arrays of 16 bit-integers.
> Then I have to filter those buffered messages, extracting a subset of items.
> I chosen to use a constant array of offsets for each message (an offset
> index for each item to extract).
> Then I go through the array extracting items at the specified indexes.
> This is my solution, but now I'm wondering if I could have done better if I
> had "mapped" a record
> to each of those arrays, with 16-bit fields corresponding to the message
> items and copying the relevant items to "filtered" records.
> That's why I was asking about the array allocation, that is therefore
> essential to this solution.

If I understand what you are saying.  You have messages which consist of 
some number of 16-bit chunks.  You need to map some? templates on to the 
received messages and extract data from some of those fields.

I think I will answer by pointing you to the Ada.Streams package.  If 
you can use it for the streams you are dealing with it will make things 
much easier.  The real magic occurs with 'Read and 'Write in the next 
section. (And if you have multiple message formats that depend on 
information in one or more header words, S'Output and S'Input.)

With luck you should be able to declare your messages as a single 
variant record type, and use 'Input to read those messages.

> I still hope that the first solution could be preferable...since I have done
> a lot of code...  :-) ...what do you think, also in terms of portability and
> reusability (i.e independence from platform and compiler, which I like to
> take into account)?

-- 
                                           Robert I. Eachus

"The only thing necessary for the triumph of evil is for good men to do 
nothing." --Edmund Burke




  reply	other threads:[~2004-03-02  2:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-01 14:02 allocation of an array Davide
2004-03-01 15:57 ` Robert I. Eachus
2004-03-01 17:49   ` Davide
2004-03-02  2:49     ` Robert I. Eachus [this message]
2004-03-15 10:37     ` Rod Chapman
replies disabled

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