1------------------------------------------------------------------------------
2--                                                                          --
3--                            Matreshka Project                             --
4--                                                                          --
5--                          Ada Modeling Framework                          --
6--                                                                          --
7--                        Runtime Library Component                         --
8--                                                                          --
9------------------------------------------------------------------------------
10--                                                                          --
11-- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com>                     --
12-- All rights reserved.                                                     --
13--                                                                          --
14-- Redistribution and use in source and binary forms, with or without       --
15-- modification, are permitted provided that the following conditions       --
16-- are met:                                                                 --
17--                                                                          --
18--  * Redistributions of source code must retain the above copyright        --
19--    notice, this list of conditions and the following disclaimer.         --
20--                                                                          --
21--  * Redistributions in binary form must reproduce the above copyright     --
22--    notice, this list of conditions and the following disclaimer in the   --
23--    documentation and/or other materials provided with the distribution.  --
24--                                                                          --
25--  * Neither the name of the Vadim Godunko, IE nor the names of its        --
26--    contributors may be used to endorse or promote products derived from  --
27--    this software without specific prior written permission.              --
28--                                                                          --
29-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS      --
30-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT        --
31-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR    --
32-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     --
33-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,   --
34-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
35-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   --
36-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF   --
37-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING     --
38-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS       --
39-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.             --
40--                                                                          --
41------------------------------------------------------------------------------
42--  $Revision: 3432 $ $Date: 2012-11-14 00:51:21 +0400 (Wed, 14 Nov 2012) $
43------------------------------------------------------------------------------
44with AMF.Internals.Element_Collections;
45with AMF.Internals.Helpers;
46with AMF.Internals.Tables.UML_Attributes;
47
48package body AMF.Internals.UMLDI_UML_Diagram_Elements is
49
50   ---------------
51   -- Container --
52   ---------------
53
54   overriding function Container
55    (Self : not null access constant UMLDI_UML_Diagram_Element_Proxy)
56       return AMF.Elements.Element_Access
57   is
58      use type AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access;
59
60      Owning_Element : constant
61        AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access
62          := UMLDI_UML_Diagram_Element_Proxy'Class (Self.all).Get_Owning_Element;
63
64   begin
65      if Owning_Element /= null then
66         --  Returns owingElement when it is defined, this is most common case
67         --  for classes of UMLDI metamodel.
68
69         return AMF.Elements.Element_Access (Owning_Element);
70
71      else
72         --  Use Container subprogram of parent tagged type to retrieve
73         --  possible container. For UMLDI classes inherited from
74         --  UML::Packageabe this implementation returns value of
75         --  Element::owner attribute.
76
77         return Element_Proxy (Self.all).Container;
78      end if;
79   end Container;
80
81   ------------------------
82   -- Get_Owning_Element --
83   ------------------------
84
85   overriding function Get_Owning_Element
86    (Self : not null access constant UMLDI_UML_Diagram_Element_Proxy)
87       return AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access is
88   begin
89      return
90        AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access
91         (AMF.Internals.Helpers.To_Element
92           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Element
93             (Self.Element)));
94   end Get_Owning_Element;
95
96   ------------------------
97   -- Get_Owning_Element --
98   ------------------------
99
100   overriding function Get_Owning_Element
101    (Self : not null access constant UMLDI_UML_Diagram_Element_Proxy)
102       return AMF.DI.Diagram_Elements.DI_Diagram_Element_Access is
103   begin
104      return
105        AMF.DI.Diagram_Elements.DI_Diagram_Element_Access
106         (AMF.Internals.Helpers.To_Element
107           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Element
108             (Self.Element)));
109   end Get_Owning_Element;
110
111   -----------------------
112   -- Get_Owned_Element --
113   -----------------------
114
115   overriding function Get_Owned_Element
116    (Self : not null access constant UMLDI_UML_Diagram_Element_Proxy)
117       return AMF.UMLDI.UML_Diagram_Elements.Collections.Ordered_Set_Of_UMLDI_UML_Diagram_Element is
118   begin
119      return
120        AMF.UMLDI.UML_Diagram_Elements.Collections.Wrap
121         (AMF.Internals.Element_Collections.Wrap
122           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owned_Element
123             (Self.Element)));
124   end Get_Owned_Element;
125
126   -----------------------
127   -- Get_Owned_Element --
128   -----------------------
129
130   overriding function Get_Owned_Element
131    (Self : not null access constant UMLDI_UML_Diagram_Element_Proxy)
132       return AMF.DI.Diagram_Elements.Collections.Set_Of_DI_Diagram_Element is
133   begin
134      return
135        AMF.DI.Diagram_Elements.Collections.Wrap
136         (AMF.Internals.Element_Collections.Wrap
137           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owned_Element
138             (Self.Element)));
139   end Get_Owned_Element;
140
141   ----------------------
142   -- Get_Shared_Style --
143   ----------------------
144
145   overriding function Get_Shared_Style
146    (Self : not null access constant UMLDI_UML_Diagram_Element_Proxy)
147       return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access is
148   begin
149      return
150        AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access
151         (AMF.Internals.Helpers.To_Element
152           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Shared_Style
153             (Self.Element)));
154   end Get_Shared_Style;
155
156   ----------------------
157   -- Get_Shared_Style --
158   ----------------------
159
160   overriding function Get_Shared_Style
161    (Self : not null access constant UMLDI_UML_Diagram_Element_Proxy)
162       return AMF.DI.Styles.DI_Style_Access is
163   begin
164      return
165        AMF.DI.Styles.DI_Style_Access
166         (AMF.Internals.Helpers.To_Element
167           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Shared_Style
168             (Self.Element)));
169   end Get_Shared_Style;
170
171   ------------------------
172   -- Set_Owning_Element --
173   ------------------------
174
175   overriding procedure Set_Owning_Element
176    (Self : not null access UMLDI_UML_Diagram_Element_Proxy;
177     To   : AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element_Access) is
178   begin
179      raise Program_Error;
180--      AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Element
181--       (Self.Element,
182--        AMF.Internals.Helpers.To_Element
183--         (AMF.Elements.Element_Access (To)));
184   end Set_Owning_Element;
185
186   ----------------------
187   -- Set_Shared_Style --
188   ----------------------
189
190   overriding procedure Set_Shared_Style
191    (Self : not null access UMLDI_UML_Diagram_Element_Proxy;
192     To   : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access) is
193   begin
194      AMF.Internals.Tables.UML_Attributes.Internal_Set_Shared_Style
195       (Self.Element,
196        AMF.Internals.Helpers.To_Element
197         (AMF.Elements.Element_Access (To)));
198   end Set_Shared_Style;
199
200   ----------------------
201   -- Set_Shared_Style --
202   ----------------------
203
204   overriding procedure Set_Shared_Style
205    (Self : not null access UMLDI_UML_Diagram_Element_Proxy;
206     To   : AMF.DI.Styles.DI_Style_Access) is
207   begin
208      AMF.Internals.Tables.UML_Attributes.Internal_Set_Shared_Style
209       (Self.Element,
210        AMF.Internals.Helpers.To_Element
211         (AMF.Elements.Element_Access (To)));
212   end Set_Shared_Style;
213
214end AMF.Internals.UMLDI_UML_Diagram_Elements;
215