--------------------------------------------------------- ----------------------- -- -- -- OCARINA COMPONENTS -- -- -- -- G A I A . G E N E R A T O R -- -- -- -- B o d y -- -- -- -- Copyright (C) 2005-2006, GET-Telecom Paris. -- -- -- -- Ocarina is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 2, or (at your option) any -- -- later version. Ocarina 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 distributed with Ocarina; see file COPYING. -- -- If not, write to the Free Software Foundation, 51 Franklin Street, Fifth -- -- Floor, Boston, MA 02111-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- Ocarina is maintained by the Ocarina team -- -- (ocarina-users@listes.enst.fr) -- -- -- ------------------------------------------------------------------------------ with Namet; with Output; package body Gaia.Generator is -- The chained list type that contains the registered generator modules type Generator_Module; type Generator_Module_Access is access all Generator_Module; type Generator_Module is record Module_Name : Types.Name_Id; Module_Subprogram : Generator_Facility_Access; Next_Module : Generator_Module_Access; end record; Gaia_Generators : Generator_Module_Access := null; ------------------------ -- Register_Generator -- ------------------------ procedure Register_Generator (Generator_Name : String; Generator : Generator_Facility_Access) is use Namet; The_Generator : constant Generator_Module_Access := new Generator_Module; begin if Generator_Name'Length > 0 then Set_Str_To_Name_Buffer (Generator_Name); The_Generator.Module_Name := Name_Find; The_Generator.Module_Subprogram := Generator; The_Generator.Next_Module := Gaia_Generators; Gaia_Generators := The_Generator; end if; end Register_Generator; ---------------------- -- Select_Generator -- ---------------------- function Select_Generator (Module : String) return Generator_Facility_Access is use Namet; use Types; Current_Generator : Generator_Module_Access := Gaia_Generators; Module_Name : Name_Id; begin if Module'Length > 0 then Set_Str_To_Name_Buffer (Module); Module_Name := Name_Find; while Current_Generator /= null loop if Current_Generator.Module_Name = Module_Name then return Current_Generator.Module_Subprogram; end if; Current_Generator := Current_Generator.Next_Module; end loop; end if; return null; end Select_Generator; ---------------------- -- Write_Generators -- ---------------------- procedure Write_Generators (Indent : Natural) is use Output; use Namet; Current_Generator : Generator_Module_Access := Gaia_Generators; begin for Index in 1 .. Indent loop Write_Char (' '); end loop; Write_Line ("Registered generators:"); while Current_Generator /= null loop for Index in 1 .. Indent + 1 loop Write_Char (' '); end loop; Write_Name (Current_Generator.Module_Name); Write_Eol; Current_Generator := Current_Generator.Next_Module; end loop; end Write_Generators; end Gaia.Generator;