------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real-time scheduling analysis tool. -- This program provides services to automatically check schedulability and -- other performance criteria of real-time architecture models. -- -- Copyright (C) 2002-2016, Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285 laboratory, Université de Bretagne Occidentale -- -- Cheddar has been published in the "Agence de Protection des Programmes/France" in 2008. -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- The full list of contributors and sponsors can be found in AUTHORS.txt and SPONSORS.txt -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- Contact : cheddar@listes.univ-brest.fr -- ------------------------------------------------------------------------------ -- Last update : -- $Rev: 1249 $ -- $Date: 2014-08-28 07:02:15 +0200 (Fri, 28 Aug 2014) $ -- $Author: singhoff $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Objects; use Objects; with Objects.extended; use Objects.extended; with Translate; use Translate; with unbounded_strings; use unbounded_strings; with initialize_framework; use initialize_framework; with Event_Analyzers.extended; use Event_Analyzers.extended; package body Event_Analyzer_Set is procedure Check_Event_Analyzer (My_Event_Analyzers : in Event_Analyzers_Set; Name : in Unbounded_String; File_Name : in Unbounded_String) is begin if Name = "" then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_event_analyzer_Name (Current_Language) & Lb_Mandatory (Current_Language))); end if; if not Is_A_Valid_Identifier (Name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_event_analyzer (Current_Language) & " " & Name & " : " & Lb_Event_Analyzer_Name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; if File_Name = "" then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Event_Analyzer_Name (Current_Language) & Lb_Mandatory (Current_Language))); end if; if not Is_A_Valid_Identifier (File_Name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Event_Analyzer_Name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; end Check_Event_Analyzer; procedure Add_Event_Analyzer (My_Event_Analyzers : in out Event_Analyzers_Set; Name : in Unbounded_String; File_Name : in Unbounded_String) is An_Event_Analyzer : Event_Analyzer_Ptr; My_Iterator : iterator; begin Check_Initialize; Check_Event_Analyzer (My_Event_Analyzers, Name, file_name); if (get_number_of_elements (My_Event_Analyzers) > 0) then reset_iterator (My_Event_Analyzers, My_Iterator); loop current_element (My_Event_Analyzers, An_Event_Analyzer, My_Iterator); if (Name = An_Event_Analyzer.name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Event_Analyzer (Current_Language) & " " & Name & " : " & Lb_Event_Analyzer_Name (Current_Language) & Lb_Already_Defined (Current_Language))); end if; exit when is_last_element (My_Event_Analyzers, My_Iterator); next_element (My_Event_Analyzers, My_Iterator); end loop; end if; An_Event_Analyzer := new extended_Event_Analyzer; An_Event_Analyzer.event_analyzer_source_file_name := File_Name; An_Event_Analyzer.name := Name; add (My_Event_Analyzers, An_Event_Analyzer); exception when full_set => Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Can_Not_Define_More_Event_Analyzers (Current_Language))); end Add_Event_Analyzer; function Search_Event_Analyzer (My_Event_Analyzers : in Event_Analyzers_Set; Name : in Unbounded_String) return Event_Analyzer_Ptr is My_Iterator : iterator; An_Event_Analyzer : Event_Analyzer_Ptr; Result : Event_Analyzer_Ptr; Found : Boolean := False; begin if not is_empty(My_Event_Analyzers) then reset_iterator (My_Event_Analyzers, My_Iterator); loop current_element (My_Event_Analyzers, An_Event_Analyzer, My_Iterator); if (An_Event_Analyzer.name = Name) then Found := True; Result := An_Event_Analyzer; end if; exit when is_last_element (My_Event_Analyzers, My_Iterator); next_element (My_Event_Analyzers, My_Iterator); end loop; end if; if not Found then Raise_Exception (Event_Analyzer_Not_Found'identity, To_String (Lb_event_analyzer_name (Current_Language) & "=" & name)); end if; return Result; end Search_Event_Analyzer; function Export_Aadl_Properties (My_Event_Analyzers : in Event_Analyzers_Set; Number_Of_Ht : in Natural) return Unbounded_String is An_Event_Analyzer : Event_Analyzer_Ptr; My_Iterator : Event_Analyzers_Iterator; Result : Unbounded_String := empty_string; begin if not is_empty (My_Event_Analyzers) then reset_iterator (My_Event_Analyzers, My_Iterator); for I in 1 .. Number_Of_Ht loop Result := Result & ASCII.HT; end loop; Result := Result & To_Unbounded_String ("Cheddar_Properties::Source_Text => ") & """"; loop current_element (My_Event_Analyzers, An_Event_Analyzer, My_Iterator); Result := Result & To_String (An_Event_Analyzer.event_analyzer_source_file_name); exit when is_last_element (My_Event_Analyzers, My_Iterator); next_element (My_Event_Analyzers, My_Iterator); Result := Result & ","; end loop; Result := Result & """" & ";" & unbounded_lf; end if; return Result; end Export_Aadl_Properties; end Event_Analyzer_Set;