Skip to content

Commit dce3c32

Browse files
committed
Drop opaque handle for stateless algorithm
1 parent 733d272 commit dce3c32

File tree

4 files changed

+7
-40
lines changed

4 files changed

+7
-40
lines changed

src/components/sunline_srukf/component-sunline_srukf-implementation.adb

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
with Nav_Att.C;
66
with Sunline_Srukf_Input.C;
77
with Sunline_Srukf_Output.C;
8+
with Sunline_Srukf_Algorithm_C; use Sunline_Srukf_Algorithm_C;
89
with Algorithm_Wrapper_Util;
910

1011
package body Component.Sunline_Srukf.Implementation is
@@ -14,17 +15,12 @@ package body Component.Sunline_Srukf.Implementation is
1415
--------------------------------------------------
1516
-- Initializes the sunline SRuKF algorithm.
1617
overriding procedure Init (Self : in out Instance) is
18+
pragma Unreferenced (Self);
1719
begin
18-
-- Allocate C++ class on the heap
19-
Self.Alg := Create;
20+
-- Stateless algorithm, nothing to initialize.
21+
null;
2022
end Init;
2123

22-
not overriding procedure Destroy (Self : in out Instance) is
23-
begin
24-
-- Free the C++ heap data.
25-
Destroy (Self.Alg);
26-
end Destroy;
27-
2824
---------------------------------------
2925
-- Invokee connector primitives:
3026
---------------------------------------
@@ -56,7 +52,6 @@ package body Component.Sunline_Srukf.Implementation is
5652

5753
-- Call the C algorithm:
5854
Output_C : constant Sunline_Srukf_Output.C.U_C := Update_State (
59-
Self.Alg,
6055
Input => Input_C'Unchecked_Access
6156
);
6257
begin

src/components/sunline_srukf/component-sunline_srukf-implementation.ads

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
-- Includes:
66
with Tick;
7-
with Sunline_Srukf_Algorithm_C; use Sunline_Srukf_Algorithm_C;
87

98
-- Sunline SRuKF pass-through algorithm wrapping the C++ SunlineSRuKFAlgorithm.
109
package Component.Sunline_Srukf.Implementation is
@@ -17,13 +16,12 @@ package Component.Sunline_Srukf.Implementation is
1716
--------------------------------------------------
1817
-- Initializes the sunline SRuKF algorithm.
1918
overriding procedure Init (Self : in out Instance);
20-
not overriding procedure Destroy (Self : in out Instance);
2119

2220
private
2321

2422
-- The component class instance record:
2523
type Instance is new Sunline_Srukf.Base_Instance with record
26-
Alg : Sunline_Srukf_Algorithm_Access := null;
24+
null;
2725
end record;
2826

2927
---------------------------------------

src/components/sunline_srukf/sunline_srukf_algorithm_c.ads

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,16 @@ package Sunline_Srukf_Algorithm_C is
2424
-- Runtime validation: ensure Ada constant matches C definition
2525
pragma Assert (Unsigned_32 (MAX_NUM_CSS) = Get_Max_Num_Css);
2626

27-
--* Opaque handle for a SunlineSRuKFAlgorithm instance.
28-
type Sunline_Srukf_Algorithm is limited private;
29-
type Sunline_Srukf_Algorithm_Access is access all Sunline_Srukf_Algorithm;
30-
31-
--* @brief Construct a new SunlineSRuKFAlgorithm.
32-
function Create
33-
return Sunline_Srukf_Algorithm_Access
34-
with Import => True,
35-
Convention => C,
36-
External_Name => "SunlineSRuKFAlgorithm_create";
37-
38-
--* @brief Destroy a SunlineSRuKFAlgorithm.
39-
procedure Destroy
40-
(Self : Sunline_Srukf_Algorithm_Access)
41-
with Import => True,
42-
Convention => C,
43-
External_Name => "SunlineSRuKFAlgorithm_destroy";
44-
45-
--* @brief Run the sunline SRuKF update step.
46-
--* @param Self The algorithm instance.
27+
--* @brief Run the sunline SRuKF update step (stateless).
4728
--* @param Input Pointer to the input structure (read-only).
4829
--* @return The computed output.
4930
function Update_State
50-
(Self : Sunline_Srukf_Algorithm_Access;
51-
Input : Sunline_Srukf_Input.C.U_C_Access)
31+
(Input : Sunline_Srukf_Input.C.U_C_Access)
5232
return Sunline_Srukf_Output.C.U_C
5333
with Import => True,
5434
Convention => C,
5535
External_Name => "SunlineSRuKFAlgorithm_updateState";
5636

57-
private
58-
59-
-- Private representation: opaque null record
60-
type Sunline_Srukf_Algorithm is null record;
61-
6237
end Sunline_Srukf_Algorithm_C;
6338

6439
pragma Style_Checks (On);

src/components/sunline_srukf/test/sunline_srukf_tests-implementation.adb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ package body Sunline_Srukf_Tests.Implementation is
3131
overriding procedure Tear_Down_Test (Self : in out Instance) is
3232
begin
3333
-- Free component heap:
34-
Self.Tester.Component_Instance.Destroy;
3534
Self.Tester.Final_Base;
3635
end Tear_Down_Test;
3736

0 commit comments

Comments
 (0)