-------------------------------------------------- -------- ------------------------ -- -- -- OCARINA COMPONENTS -- -- -- -- O C A R I N A . D I A . P A R S E R . C O R E . C O N N E C T I O N S -- -- -- -- 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 Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with DOM.Core.Nodes; package body Ocarina.Dia.Parser.Core.Connections is -- Parses a connection point procedure Get_Connection_Point (N : DOM.Core.node; CP : in out connection_point) is use DOM.Core; AS : constant named_node_map := DOM.Core.Nodes.Attributes (N); begin CP.Object_ID := To_Unbounded_String (Get_Required_Attribute (AS, "to")); CP.Port := Integer'value (Get_Required_Attribute (AS, "connection")); end Get_Connection_Point; -- Parses the connections associated to a Line node function Get_Connection (N : DOM.Core.node) return connection is use DOM.Core; E : DOM.Core.node; C : connection; begin if N /= null and then N.Node_Type = element_node and then DOM.Core.Nodes.Node_Name (N) = "dia:connections" then declare SP : connection_point; EP : connection_point; CL : constant DOM.Core.node_list := DOM.Core.Nodes.Child_Nodes (N); Index : Natural := 0; begin Get_Required_Child (CL, "dia:connection", Index, E); Get_Connection_Point (E, SP); Index := Index + 1; Get_Required_Child (CL, "dia:connection", Index, E); Get_Connection_Point (E, EP); C.Start_Point := SP; C.End_Point := EP; return C; exception when Missing_Child => raise Dangling_Connection; when Missing_Attribute => raise Missing_Attribute; end; end if; raise Dangling_Connection; end Get_Connection; end Ocarina.Dia.Parser.Core.Connections;