1------------------------------------------------------------------------------
2--                                                                          --
3--                            Matreshka Project                             --
4--                                                                          --
5--                          Ada Modeling Framework                          --
6--                                                                          --
7--                        Runtime Library Component                         --
8--                                                                          --
9------------------------------------------------------------------------------
10--                                                                          --
11-- Copyright © 2011-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: 2937 $ $Date: 2012-05-01 21:07:27 +0400 (Tue, 01 May 2012) $
43------------------------------------------------------------------------------
44with AMF.Elements;
45with AMF.Internals.Element_Collections;
46with AMF.Internals.Helpers;
47with AMF.Internals.Tables.UML_Attributes;
48with AMF.Visitors.UML_Iterators;
49with AMF.Visitors.UML_Visitors;
50with League.Strings.Internals;
51with Matreshka.Internals.Strings;
52
53package body AMF.Internals.UML_Extends is
54
55   -------------------
56   -- Enter_Element --
57   -------------------
58
59   overriding procedure Enter_Element
60    (Self    : not null access constant UML_Extend_Proxy;
61     Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
62     Control : in out AMF.Visitors.Traverse_Control) is
63   begin
64      if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
65         AMF.Visitors.UML_Visitors.UML_Visitor'Class
66          (Visitor).Enter_Extend
67            (AMF.UML.Extends.UML_Extend_Access (Self),
68           Control);
69      end if;
70   end Enter_Element;
71
72   -------------------
73   -- Leave_Element --
74   -------------------
75
76   overriding procedure Leave_Element
77    (Self    : not null access constant UML_Extend_Proxy;
78     Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
79     Control : in out AMF.Visitors.Traverse_Control) is
80   begin
81      if Visitor in AMF.Visitors.UML_Visitors.UML_Visitor'Class then
82         AMF.Visitors.UML_Visitors.UML_Visitor'Class
83          (Visitor).Leave_Extend
84            (AMF.UML.Extends.UML_Extend_Access (Self),
85           Control);
86      end if;
87   end Leave_Element;
88
89   -------------------
90   -- Visit_Element --
91   -------------------
92
93   overriding procedure Visit_Element
94    (Self     : not null access constant UML_Extend_Proxy;
95     Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
96     Visitor  : in out AMF.Visitors.Abstract_Visitor'Class;
97     Control  : in out AMF.Visitors.Traverse_Control) is
98   begin
99      if Iterator in AMF.Visitors.UML_Iterators.UML_Iterator'Class then
100         AMF.Visitors.UML_Iterators.UML_Iterator'Class
101          (Iterator).Visit_Extend
102            (Visitor,
103             AMF.UML.Extends.UML_Extend_Access (Self),
104             Control);
105      end if;
106   end Visit_Element;
107
108   -------------------
109   -- Get_Condition --
110   -------------------
111
112   overriding function Get_Condition
113    (Self : not null access constant UML_Extend_Proxy)
114       return AMF.UML.Constraints.UML_Constraint_Access is
115   begin
116      return
117        AMF.UML.Constraints.UML_Constraint_Access
118         (AMF.Internals.Helpers.To_Element
119           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Condition
120             (Self.Element)));
121   end Get_Condition;
122
123   -------------------
124   -- Set_Condition --
125   -------------------
126
127   overriding procedure Set_Condition
128    (Self : not null access UML_Extend_Proxy;
129     To   : AMF.UML.Constraints.UML_Constraint_Access) is
130   begin
131      AMF.Internals.Tables.UML_Attributes.Internal_Set_Condition
132       (Self.Element,
133        AMF.Internals.Helpers.To_Element
134         (AMF.Elements.Element_Access (To)));
135   end Set_Condition;
136
137   -----------------------
138   -- Get_Extended_Case --
139   -----------------------
140
141   overriding function Get_Extended_Case
142    (Self : not null access constant UML_Extend_Proxy)
143       return AMF.UML.Use_Cases.UML_Use_Case_Access is
144   begin
145      return
146        AMF.UML.Use_Cases.UML_Use_Case_Access
147         (AMF.Internals.Helpers.To_Element
148           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Extended_Case
149             (Self.Element)));
150   end Get_Extended_Case;
151
152   -----------------------
153   -- Set_Extended_Case --
154   -----------------------
155
156   overriding procedure Set_Extended_Case
157    (Self : not null access UML_Extend_Proxy;
158     To   : AMF.UML.Use_Cases.UML_Use_Case_Access) is
159   begin
160      AMF.Internals.Tables.UML_Attributes.Internal_Set_Extended_Case
161       (Self.Element,
162        AMF.Internals.Helpers.To_Element
163         (AMF.Elements.Element_Access (To)));
164   end Set_Extended_Case;
165
166   -------------------
167   -- Get_Extension --
168   -------------------
169
170   overriding function Get_Extension
171    (Self : not null access constant UML_Extend_Proxy)
172       return AMF.UML.Use_Cases.UML_Use_Case_Access is
173   begin
174      return
175        AMF.UML.Use_Cases.UML_Use_Case_Access
176         (AMF.Internals.Helpers.To_Element
177           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Extension
178             (Self.Element)));
179   end Get_Extension;
180
181   -------------------
182   -- Set_Extension --
183   -------------------
184
185   overriding procedure Set_Extension
186    (Self : not null access UML_Extend_Proxy;
187     To   : AMF.UML.Use_Cases.UML_Use_Case_Access) is
188   begin
189      AMF.Internals.Tables.UML_Attributes.Internal_Set_Extension
190       (Self.Element,
191        AMF.Internals.Helpers.To_Element
192         (AMF.Elements.Element_Access (To)));
193   end Set_Extension;
194
195   ----------------------------
196   -- Get_Extension_Location --
197   ----------------------------
198
199   overriding function Get_Extension_Location
200    (Self : not null access constant UML_Extend_Proxy)
201       return AMF.UML.Extension_Points.Collections.Ordered_Set_Of_UML_Extension_Point is
202   begin
203      return
204        AMF.UML.Extension_Points.Collections.Wrap
205         (AMF.Internals.Element_Collections.Wrap
206           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Extension_Location
207             (Self.Element)));
208   end Get_Extension_Location;
209
210   ----------------
211   -- Get_Source --
212   ----------------
213
214   overriding function Get_Source
215    (Self : not null access constant UML_Extend_Proxy)
216       return AMF.UML.Elements.Collections.Set_Of_UML_Element is
217   begin
218      return
219        AMF.UML.Elements.Collections.Wrap
220         (AMF.Internals.Element_Collections.Wrap
221           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Source
222             (Self.Element)));
223   end Get_Source;
224
225   ----------------
226   -- Get_Target --
227   ----------------
228
229   overriding function Get_Target
230    (Self : not null access constant UML_Extend_Proxy)
231       return AMF.UML.Elements.Collections.Set_Of_UML_Element is
232   begin
233      return
234        AMF.UML.Elements.Collections.Wrap
235         (AMF.Internals.Element_Collections.Wrap
236           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Target
237             (Self.Element)));
238   end Get_Target;
239
240   -------------------------
241   -- Get_Related_Element --
242   -------------------------
243
244   overriding function Get_Related_Element
245    (Self : not null access constant UML_Extend_Proxy)
246       return AMF.UML.Elements.Collections.Set_Of_UML_Element is
247   begin
248      return
249        AMF.UML.Elements.Collections.Wrap
250         (AMF.Internals.Element_Collections.Wrap
251           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Related_Element
252             (Self.Element)));
253   end Get_Related_Element;
254
255   ---------------------------
256   -- Get_Client_Dependency --
257   ---------------------------
258
259   overriding function Get_Client_Dependency
260    (Self : not null access constant UML_Extend_Proxy)
261       return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
262   begin
263      return
264        AMF.UML.Dependencies.Collections.Wrap
265         (AMF.Internals.Element_Collections.Wrap
266           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
267             (Self.Element)));
268   end Get_Client_Dependency;
269
270   -------------------------
271   -- Get_Name_Expression --
272   -------------------------
273
274   overriding function Get_Name_Expression
275    (Self : not null access constant UML_Extend_Proxy)
276       return AMF.UML.String_Expressions.UML_String_Expression_Access is
277   begin
278      return
279        AMF.UML.String_Expressions.UML_String_Expression_Access
280         (AMF.Internals.Helpers.To_Element
281           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
282             (Self.Element)));
283   end Get_Name_Expression;
284
285   -------------------------
286   -- Set_Name_Expression --
287   -------------------------
288
289   overriding procedure Set_Name_Expression
290    (Self : not null access UML_Extend_Proxy;
291     To   : AMF.UML.String_Expressions.UML_String_Expression_Access) is
292   begin
293      AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
294       (Self.Element,
295        AMF.Internals.Helpers.To_Element
296         (AMF.Elements.Element_Access (To)));
297   end Set_Name_Expression;
298
299   -------------------
300   -- Get_Namespace --
301   -------------------
302
303   overriding function Get_Namespace
304    (Self : not null access constant UML_Extend_Proxy)
305       return AMF.UML.Namespaces.UML_Namespace_Access is
306   begin
307      return
308        AMF.UML.Namespaces.UML_Namespace_Access
309         (AMF.Internals.Helpers.To_Element
310           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
311             (Self.Element)));
312   end Get_Namespace;
313
314   ------------------------
315   -- Get_Qualified_Name --
316   ------------------------
317
318   overriding function Get_Qualified_Name
319    (Self : not null access constant UML_Extend_Proxy)
320       return AMF.Optional_String is
321   begin
322      declare
323         use type Matreshka.Internals.Strings.Shared_String_Access;
324
325         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
326           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
327
328      begin
329         if Aux = null then
330            return (Is_Empty => True);
331
332         else
333            return (False, League.Strings.Internals.Create (Aux));
334         end if;
335      end;
336   end Get_Qualified_Name;
337
338   -------------------------
339   -- All_Owning_Packages --
340   -------------------------
341
342   overriding function All_Owning_Packages
343    (Self : not null access constant UML_Extend_Proxy)
344       return AMF.UML.Packages.Collections.Set_Of_UML_Package is
345   begin
346      --  Generated stub: replace with real body!
347      pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
348      raise Program_Error with "Unimplemented procedure UML_Extend_Proxy.All_Owning_Packages";
349      return All_Owning_Packages (Self);
350   end All_Owning_Packages;
351
352   -----------------------------
353   -- Is_Distinguishable_From --
354   -----------------------------
355
356   overriding function Is_Distinguishable_From
357    (Self : not null access constant UML_Extend_Proxy;
358     N : AMF.UML.Named_Elements.UML_Named_Element_Access;
359     Ns : AMF.UML.Namespaces.UML_Namespace_Access)
360       return Boolean is
361   begin
362      --  Generated stub: replace with real body!
363      pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
364      raise Program_Error with "Unimplemented procedure UML_Extend_Proxy.Is_Distinguishable_From";
365      return Is_Distinguishable_From (Self, N, Ns);
366   end Is_Distinguishable_From;
367
368   ---------------
369   -- Namespace --
370   ---------------
371
372   overriding function Namespace
373    (Self : not null access constant UML_Extend_Proxy)
374       return AMF.UML.Namespaces.UML_Namespace_Access is
375   begin
376      --  Generated stub: replace with real body!
377      pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
378      raise Program_Error with "Unimplemented procedure UML_Extend_Proxy.Namespace";
379      return Namespace (Self);
380   end Namespace;
381
382end AMF.Internals.UML_Extends;
383