--   (c) Copyright, Real-Time Innovations, 2025. --   All rights reserved. --   No duplications, whole or partial, manual or electronic, may be made --   without express written permission.  Any such copies, or --   revisions thereof, must display this notice unaltered. --   This code contains trade secrets of Real-Time Innovations, Inc. private with Ada.Finalization;
generic type Element_Type is limited private;
type Element_Type_Access is access Element_Type;
with procedure Initialize (item : in out Element_Type) is <>;
with procedure Copy (target : in out Element_Type; source : in Element_Type) is <>;
with procedure Finalize (item : in out Element_Type) is <>;
package DDS.Limited_Holders_Generic is
   --  This is a suport package intended to wrap limited DDS-datatypes    --  in such a way that they coud be used as non limited types.    --  The interface is modeled after Ada.Containers.Holders.    --    --  declare    --    use DDS;    --    package String_Holders is new DDS.Limited_Holders_Generic    --      (Element_Type        => DDS.String,    --       Element_Type_Access => DDS.String_Ptr);    --    --    H1   : String_Holders.Holder;    --    Data : aliased DDS.String := DDS.To_DDS_String("Test Data");    --    H0   : String_Holders.Holder := String_Holders."+"(Data);    --  begin    --    H1 := H0; -- H1 will now contain a copy of the DDS.string Data;    --  end;    --  -- The content of the Holders H0 and H1 will be freed when the    --  -- declare block gous out of scope.    --    --  Note the the holder contains a full copy of the object and an assignment    --  implies a deep copy of the object, it could result in hevy CPU usage: type Holder is tagged private;
function To_Holder (New_Item : Element_Type) return Holder;
function "+" (New_Item : Element_Type) return Holder renames To_Holder;
   --  Create a new holder the contains a copy of the object. function Get (Container : Holder) return Element_Type_Access;
   --  Returns a reference to the stored object. procedure Set (Container : in out Holder; New_Item : Element_Type);
   --  Makes a new copy of the object and stores it in the Holder. procedure References (Container : in out Holder; New_Item : Element_Type_Access);
   --  Sets the holder to reference the object without copy. private type Holder is new Ada.Finalization.Controlled with record
      impl         : Element_Type_Access;       Is_Reference : Boolean := False; end record;
procedure Initialize (Object : in out Holder);
procedure Adjust (Object : in out Holder);
procedure Finalize (Object : in out Holder);
end DDS.Limited_Holders_Generic;