Commit 75b667c6 authored by Maxime Perrotin's avatar Maxime Perrotin

Add iterator on properties

parent dbb332e0
......@@ -724,20 +724,14 @@ procedure BuildSupport is
elsif Get_Category_Of_Component (CI) = CC_Bus then
declare
-- Get the list of properties attaches to the bus
Properties : constant List_Id :=
Ocarina.ME_AADL.AADL_Instances.Nodes.Properties (CI);
Property : Node_Id := First_Node (Properties);
Properties : constant Property_Maps.Map :=
Get_Properties_Map (CI);
Bus_Classifier : Name_Id := No_Name;
Pkg_Name : Name_Id := No_Name;
begin
while Present (Property) loop
-- TODO
null;
-- Put_Line ("Bus property found");
-- Put_Line (Get_Name_String
-- (Display_Name (Identifier (Property))));
-- Put_Line ("Value: I don't know");
Property := Next_Node (Property);
for each in Properties.Iterate loop
Put_Line (Property_Maps.Key (each) & " : " &
Property_Maps.Element (each));
end loop;
Set_Str_To_Name_Buffer ("");
if ATN.Namespace
......
......@@ -5,10 +5,11 @@
with Ada.Text_IO;
with GNAT.OS_Lib;
-- with Imported_Routines;
with Namet;
with Ocarina.Configuration;
with Ocarina.AADL_Values;
with Ocarina.Instances.Queries;
with Ocarina.ME_AADL.AADL_Tree.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nodes;
with Ocarina.ME_AADL.AADL_Instances.Nutils;
with Ada.Characters.Latin_1;
......@@ -23,6 +24,8 @@ package body Buildsupport_Utils is
use Ocarina.ME_AADL.AADL_Instances.Nodes;
use Ocarina.ME_AADL.AADL_Instances.Nutils;
use Ada.Characters.Latin_1;
package ATN renames Ocarina.ME_AADL.AADL_Tree.Nodes;
use type ATN.Node_Kind;
------------
-- Banner --
......@@ -245,6 +248,49 @@ package body Buildsupport_Utils is
end if;
end Get_ASN1_Module_Name;
--------------------------------------------
-- Get all properties as a Map Key/String --
-- Input parameter is an AADL instance --
--------------------------------------------
function Get_Properties_Map (D : Node_Id) return Property_Maps.Map is
properties : constant List_Id :=
Ocarina.ME_AADL.AADL_Instances.Nodes.Properties (D);
result : Property_Maps.Map := Empty_Map;
property : Node_Id := First_Node (properties);
begin
while Present (property) loop
Put (Get_Name_String (Display_Name (Identifier (property))));
Put_Line (" of kind " & ATN.Kind (property)'Img);
result.Insert (Key => Get_Name_String
(Display_Name (Identifier (property))),
New_Item =>
(case ATN.Kind (property) is
when ATN.K_Signed_AADLNumber =>
Ocarina.AADL_Values.Image
(ATN.Value (ATN.Number_Value (property))) &
(if Present (ATN.Unit_Identifier (property)) then " " &
Get_Name_String
(ATN.Display_Name (ATN.Unit_Identifier (property)))
else ""),
when ATN.K_Literal =>
Ocarina.AADL_Values.Image (ATN.Value (property),
Quoted => False),
when ATN.K_Reference_Term =>
Get_Name_String
(ATN.Display_Name (ATN.First_Node -- XXX must iterate
(ATN.List_Items (ATN.Reference_Term (property))))),
when ATN.K_Enumeration_Term =>
Get_Name_String
(ATN.Display_Name (ATN.Identifier (property))),
when ATN.K_Number_Range_Term =>
"RANGE NOT SUPPORTED!",
when others => "ERROR! Unsupported kind: "
& ATN.Kind (property)'Img));
property := Next_Node (property);
end loop;
return result;
end Get_Properties_Map;
-----------------------
-- Get_ASN1_Encoding --
-----------------------
......
-- *************************** buildsupport **************************** --
-- (c) 2015 European Space Agency - maxime.perrotin@esa.int
-- (c) 2017 European Space Agency - maxime.perrotin@esa.int
-- LGPL license, see LICENSE file
-- Set of helper functions for buildsupport
with Ocarina;
with Ocarina,
Types,
Ada.Containers.Indefinite_Ordered_Maps;
with Types;
use Ocarina;
use Ocarina,
Ada.Containers;
package Buildsupport_Utils is
......@@ -68,4 +69,10 @@ package Buildsupport_Utils is
function Get_ASN1_Module_Name (D : Node_Id) return String;
package Property_Maps is new Indefinite_Ordered_Maps (String, String);
use Property_Maps;
function Get_Properties_Map (D : Node_Id) return Property_Maps.Map;
end Buildsupport_Utils;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment