------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Cheddar is a GNU GPL real time scheduling analysis tool. -- This program provides services to automatically check performances -- of real time architectures. -- -- Copyright (C) 2002-2010, by Frank Singhoff, Alain Plantec, Jerome Legrand -- -- The Cheddar project was started in 2002 by -- the LISyC Team, University of Western Britanny. -- -- Since 2008, Ellidiss technologies also contributes to the development of -- Cheddar and provides industrial support. -- -- 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: 523 $ -- $Date: 2012-09-26 15:09:39 +0200 (Wed, 26 Sep 2012) $ -- $Author: fotsing $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ 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; File_Name : in Unbounded_String) is begin 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); 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 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; if not Found then raise Event_Analyzer_Not_Found; 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;