------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- 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-2020, Frank Singhoff, Alain Plantec, Jerome Legrand, -- Hai Nam Tran, Stephane Rubini -- -- The Cheddar project was started in 2002 by -- Frank Singhoff, Lab-STICC UMR 6285, 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: 3477 $ -- $Date: 2020-07-13 11:43:48 +0200 (lun., 13 juil. 2020) $ -- $Author: $ ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ with Ada.Exceptions; use Ada.Exceptions; with Translate; use Translate; with Objects; use Objects; with Objects.extended; use Objects.extended; with unbounded_strings; use unbounded_strings; with initialize_framework; use initialize_framework; with Debug; use Debug; package body Scheduling_Error_Set is procedure Check_Scheduling_Error (My_Scheduling_Errors : in Scheduling_Errors_Set; Name : in Unbounded_String; A_Scheduling_Error_Record : in Scheduling_Error_Record) is A_Scheduling_Error : Scheduling_Error_Ptr; My_Iterator : Scheduling_Errors_Iterator; begin if (get_number_of_elements (My_Scheduling_Errors) > 0) then reset_iterator (My_Scheduling_Errors, My_Iterator); loop current_element (My_Scheduling_Errors, A_Scheduling_Error, My_Iterator); if (Name = A_Scheduling_Error.name) then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Scheduling_Error (Current_Language) & " " & Name & " : " & Lb_Scheduling_Error_Name (Current_Language) & Lb_Already_Defined (Current_Language))); end if; exit when is_last_element (My_Scheduling_Errors, My_Iterator); next_element (My_Scheduling_Errors, My_Iterator); end loop; end if; if (Name = "") then Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Scheduling_Error_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_Scheduling_Error (Current_Language) & " " & Name & " : " & Lb_Scheduling_Error_Name (Current_Language) & Lb_Colon & Lb_Invalid_Identifier (Current_Language))); end if; end Check_Scheduling_Error; procedure Add_Scheduling_Error (My_Scheduling_Errors : in out Scheduling_Errors_Set; Name : in Unbounded_String; A_Scheduling_Error_Record : in Scheduling_Error_Record) is Dummy : Scheduling_Error_Ptr; begin Add_Scheduling_Error(My_Scheduling_Errors, Dummy, Name, A_Scheduling_Error_Record); end Add_Scheduling_Error; procedure Add_Scheduling_Error (My_Scheduling_Errors : in out Scheduling_Errors_Set; A_Scheduling_Error : in out Scheduling_Error_Ptr; Name : in Unbounded_String; A_Scheduling_Error_Record : in Scheduling_Error_Record) is My_Iterator : iterator; begin Check_Initialize; Check_Scheduling_Error(My_Scheduling_Errors, Name, A_Scheduling_Error_Record); A_Scheduling_Error := new Scheduling_Error; A_Scheduling_Error.name := Name; A_Scheduling_Error.error_type := A_Scheduling_Error_Record.error_type; A_Scheduling_Error.time := A_Scheduling_Error_Record.time; A_Scheduling_Error.error_action := A_Scheduling_Error_Record.error_action; A_Scheduling_Error.user_defined_action := A_Scheduling_Error_Record.user_defined_action; add (My_Scheduling_Errors, A_Scheduling_Error); exception when full_set => Raise_Exception (Invalid_Parameter'Identity, To_String (Lb_Can_Not_Define_More_Scheduling_Errors (Current_Language))); end Add_Scheduling_Error; function Search_Scheduling_Error (My_Scheduling_Errors : in Scheduling_Errors_Set; Name : in Unbounded_String) return Scheduling_Error_Ptr is My_Iterator : Iterator; A_Scheduling_Error : Scheduling_Error_Ptr; Result : Scheduling_Error_Ptr; Found : Boolean := False; begin if not is_empty(My_Scheduling_Errors) then reset_iterator (My_Scheduling_Errors, My_Iterator); loop current_element (My_Scheduling_Errors, A_Scheduling_Error, My_Iterator); if (A_Scheduling_Error.name = Name) then Found := True; Result := A_Scheduling_Error; end if; exit when is_last_element (My_Scheduling_Errors, My_Iterator); next_element (My_Scheduling_Errors, My_Iterator); end loop; end if; if not Found then Raise_Exception (Scheduling_Error_Not_Found'Identity, To_String (Lb_Scheduling_Error_Name (Current_Language) & "=" & Name)); end if; return Result; end Search_Scheduling_Error; function Search_Scheduling_Error_By_Id (My_Scheduling_Errors : in Scheduling_Errors_Set; id : in Unbounded_String) return Scheduling_Error_Ptr is My_Iterator : Iterator; A_Scheduling_Error : Scheduling_Error_Ptr; Result : Scheduling_Error_Ptr; Found : Boolean := False; begin if not is_empty(My_Scheduling_Errors) then reset_iterator (My_Scheduling_Errors, My_Iterator); loop current_element (My_Scheduling_Errors, A_Scheduling_Error, My_Iterator); if (A_Scheduling_Error.cheddar_private_id = id) then Found := True; Result := A_Scheduling_Error; end if; exit when is_last_element (My_Scheduling_Errors, My_Iterator); next_element (My_Scheduling_Errors, My_Iterator); end loop; end if; if not Found then Raise_Exception (Scheduling_Error_Not_Found'Identity, To_String (Lb_Scheduling_Error_Id (Current_Language) & "=" & id)); end if; return Result; end Search_Scheduling_Error_By_Id; end Scheduling_Error_Set;