From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED.2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: General circular buffer example not tied to any specific type Date: Sat, 4 Jul 2020 19:25:22 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <6ca9747e-698f-4d60-8e23-b883da5d9f38o@googlegroups.com> NNTP-Posting-Host: 2uCIJahv+a4XEBqttj5Vkw.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:59338 List-Id: 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