comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: General circular buffer example not tied to any specific type
Date: Sat, 4 Jul 2020 19:25:22 +0200	[thread overview]
Message-ID: <rdqe1v$dts$1@gioia.aioe.org> (raw)
In-Reply-To: 6ca9747e-698f-4d60-8e23-b883da5d9f38o@googlegroups.com

On 04/07/2020 19:00, Daniel wrote:

> I'm looking for any example of ravenscar buffer able for using any type of data at the same time.
> 
> I suppose it will need to serialize all  data and manipulate it as a group of bytes.
> 
> Does any body knows any example of this written in Ada?

Ring buffer of indefinite elements would be OK. As an element you can 
use this:

    type Item (Size : Stream_Element_Count) is record
        Data : Stream_Element_Array (1..Size);
    end record;

Instantiate the generic buffer with this type. Use stream attributes to 
serialize/deserialize.

Alternatively you can do it with Storage_Element in the above and use a 
fake storage pool to store/restore objects. Or a combination "for 
X'Address use Y" with pragma Import (Ada, X);

If the type set is somewhat statically known you can use a variant 
record as an element too.

In some cases you can have a ring buffer of type tags and a set of ring 
buffers. For each type tag you would keep values in a separate ring buffer.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de

  reply	other threads:[~2020-07-04 17:25 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-04 17:00 General circular buffer example not tied to any specific type Daniel
2020-07-04 17:25 ` Dmitry A. Kazakov [this message]
2020-07-05  9:37   ` Simon Wright
2020-07-05  9:52     ` Simon Wright
2020-07-05 13:25       ` Jeffrey R. Carter
2020-07-05 15:36         ` Simon Wright
2020-07-05 18:46           ` Dmitry A. Kazakov
2020-07-05 19:51             ` Simon Wright
2020-07-06  8:11         ` Simon Wright
2020-07-06  8:58           ` Jeffrey R. Carter
2020-07-06 10:34             ` Simon Wright
2020-07-06 11:07               ` Dmitry A. Kazakov
2020-09-03 10:31 ` riya patel
2020-09-24  4:10 ` nimaopatel121
2020-09-24  4:39   ` J-P. Rosen
2020-09-25 14:32 ` Simon Wright
replies disabled

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