with System;
with GNAT.Source_Info;
with RTIDDS.Low_Level.dds_c.sequence_h;
generic
type Element is limited private;
type Element_Access is access all Element;
type Index_Type is range <>;
First_Element : Index_Type;
type Element_Array is array (Index_Type range <>) of aliased Element;
with procedure Initialize (Self : in out Element) is <>;
with procedure Finalize (Self : in out Element) is <>;
with procedure Copy (Dst : in out Element; Src : in Element) is <>;
package DDS_Support.Sequences_Generic is
SEQUENCE_MAGIC_NUMBER : constant := 16#7344#;
type Memory_Element_Pointer is
array (First_Element .. Index_Type'Last) of aliased Element_Access;
subtype Memory_Element_Array is
Element_Array (First_Element .. Index_Type'Last);
type Memory_Element_Array_Pointer is access all Memory_Element_Array;
pragma No_Strict_Aliasing (Memory_Element_Array_Pointer);
type Element_Array_Access is access all Element_Array;
type NElement_Access is new Element_Access;
type Memory_Element_Pointer_Access is access all Memory_Element_Pointer;
type Sequence is record
Owned : aliased Boolean := True;
Contiguous_Buffer : aliased Memory_Element_Array_Pointer := null;
Discontiguous_Buffer : aliased Memory_Element_Pointer_Access := null;
Maximum : aliased Index_Type := 0;
Length : aliased Index_Type := 0;
Sequence_Init : aliased Integer := SEQUENCE_MAGIC_NUMBER;
Read_Token1 : aliased System.Address := System.Null_Address;
Read_Token2 : aliased System.Address := System.Null_Address;
ElementPointersAllocation : aliased RTIDDS.Low_Level.dds_c.sequence_h.DDS_SeqElementTypeAllocationParams_t := (1, 1, 1);
ElementDeallocParams : aliased RTIDDS.Low_Level.dds_c.sequence_h.DDS_SeqElementTypeDeallocationParams_t := (1, 1);
end record with
Iterable => (First => I_First_Element,
Next => I_Next,
Has_Element => I_Has_Element,
Element => I_Get_Element);
type Sequence_Access is access all Sequence;
function I_First_Element (Self : Sequence) return Index_Type;
function I_Next (Self : Sequence; C : Index_Type) return Index_Type;
function I_Has_Element (Self : Sequence; C : Index_Type) return Standard.Boolean;
function I_Get_Element (Self : Sequence; C : Index_Type) return Element_Access;
procedure Initialize
(Self : not null access Sequence);
function Get_Reference (Self : not null access constant Sequence;
Index : Index_Type) return Element_Access;
procedure Set_Element (Self : not null access Sequence;
Index : Index_Type;
Elt : Element);
procedure Append (Self : not null access Sequence;
Elt : Element);
procedure Iterate
(Self : not null access Sequence;
Handle : not null access procedure (continue : in out Boolean; elt : Element_Access));
function Get (Self : not null access constant Sequence;
Index : Index_Type) return Element;
function Get_Element_Pointers_Allocation
(Self : not null access constant Sequence)
return Boolean;
procedure Set_Element_Pointers_Allocation
(Self : not null access Sequence;
Allocate_Pointers : in Boolean);
function Get_Maximum
(Self : not null access constant Sequence) return Index_Type;
procedure Set_Maximum (Self : not null access Sequence;
New_Max : in Index_Type);
function Get_Length
(Self : not null access constant Sequence) return Index_Type;
procedure Set_Length (Self : not null access Sequence;
New_Length : in Index_Type);
procedure Ensure_Length (Self : not null access Sequence;
Length : in Index_Type;
Max : in Index_Type);
procedure Copy_No_Alloc (Self : not null access Sequence;
Src : not null access constant Sequence);
procedure Copy (Self : not null access Sequence;
Src : not null access constant Sequence);
procedure From_Array (Self : not null access Sequence;
Src : in Element_Array);
procedure To_Array (Self : not null access constant Sequence;
Target : out Element_Array);
function To_Array
(Self : not null access constant Sequence) return Element_Array;
procedure Loan_Contiguous (Self : not null access Sequence;
Buffer : not null access Element_Array;
New_Length : in Index_Type;
New_Max : in Index_Type);
procedure Loan_Discontiguous (Self : access Sequence;
Buffer : not null access Element_Access;
New_Length : in Index_Type;
New_Max : in Index_Type);
procedure Unloan (Self : not null access Sequence);
function Has_Ownership
(Self : not null access constant Sequence) return Boolean;
procedure Finalize (Self : not null access Sequence);
SEQUENCE_UNINITIALIZED : exception;
SEQUENCE_ERROR : exception;
DEFAULT_SEQUENCE : aliased constant Sequence :=
(Owned => True,
Contiguous_Buffer => null,
Discontiguous_Buffer => null,
Maximum => 0,
Length => 0,
Sequence_Init => SEQUENCE_MAGIC_NUMBER,
Read_Token1 => System.Null_Address,
Read_Token2 => System.Null_Address,
ElementPointersAllocation => (1, 1, 1),
ElementDeallocParams => (1, 1));
procedure Check_InvariantsI
(Self : not null access constant Sequence;
Calling_Function : Standard.String := GNAT.Source_Info.Enclosing_Entity);
procedure Check_InitI (Self : not null access constant Sequence);
procedure Copy_No_AllocI (Self : not null access Sequence;
Src : not null access constant Sequence);
procedure Get_Read_TokenI (Self : not null access constant Sequence;
Token1 : not null access System.Address;
Token2 : not null access System.Address);
procedure Set_Read_TokenI (Self : not null access Sequence;
Token1 : in System.Address;
Token2 : in System.Address);
function Get_Contiguous_BufferI (Self : not null access constant Sequence)
return access Memory_Element_Array;
function Get_DisContiguous_BufferI (Self : not null access constant Sequence)
return access Memory_Element_Pointer;
end DDS_Support.Sequences_Generic;