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_Instance_Values is
54
55   -------------------
56   -- Enter_Element --
57   -------------------
58
59   overriding procedure Enter_Element
60    (Self    : not null access constant UML_Instance_Value_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_Instance_Value
67            (AMF.UML.Instance_Values.UML_Instance_Value_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_Instance_Value_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_Instance_Value
84            (AMF.UML.Instance_Values.UML_Instance_Value_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_Instance_Value_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_Instance_Value
102            (Visitor,
103             AMF.UML.Instance_Values.UML_Instance_Value_Access (Self),
104             Control);
105      end if;
106   end Visit_Element;
107
108   ------------------
109   -- Get_Instance --
110   ------------------
111
112   overriding function Get_Instance
113    (Self : not null access constant UML_Instance_Value_Proxy)
114       return AMF.UML.Instance_Specifications.UML_Instance_Specification_Access is
115   begin
116      return
117        AMF.UML.Instance_Specifications.UML_Instance_Specification_Access
118         (AMF.Internals.Helpers.To_Element
119           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Instance
120             (Self.Element)));
121   end Get_Instance;
122
123   ------------------
124   -- Set_Instance --
125   ------------------
126
127   overriding procedure Set_Instance
128    (Self : not null access UML_Instance_Value_Proxy;
129     To   : AMF.UML.Instance_Specifications.UML_Instance_Specification_Access) is
130   begin
131      AMF.Internals.Tables.UML_Attributes.Internal_Set_Instance
132       (Self.Element,
133        AMF.Internals.Helpers.To_Element
134         (AMF.Elements.Element_Access (To)));
135   end Set_Instance;
136
137   --------------
138   -- Get_Type --
139   --------------
140
141   overriding function Get_Type
142    (Self : not null access constant UML_Instance_Value_Proxy)
143       return AMF.UML.Types.UML_Type_Access is
144   begin
145      return
146        AMF.UML.Types.UML_Type_Access
147         (AMF.Internals.Helpers.To_Element
148           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Type
149             (Self.Element)));
150   end Get_Type;
151
152   --------------
153   -- Set_Type --
154   --------------
155
156   overriding procedure Set_Type
157    (Self : not null access UML_Instance_Value_Proxy;
158     To   : AMF.UML.Types.UML_Type_Access) is
159   begin
160      AMF.Internals.Tables.UML_Attributes.Internal_Set_Type
161       (Self.Element,
162        AMF.Internals.Helpers.To_Element
163         (AMF.Elements.Element_Access (To)));
164   end Set_Type;
165
166   ---------------------------
167   -- Get_Client_Dependency --
168   ---------------------------
169
170   overriding function Get_Client_Dependency
171    (Self : not null access constant UML_Instance_Value_Proxy)
172       return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
173   begin
174      return
175        AMF.UML.Dependencies.Collections.Wrap
176         (AMF.Internals.Element_Collections.Wrap
177           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
178             (Self.Element)));
179   end Get_Client_Dependency;
180
181   -------------------------
182   -- Get_Name_Expression --
183   -------------------------
184
185   overriding function Get_Name_Expression
186    (Self : not null access constant UML_Instance_Value_Proxy)
187       return AMF.UML.String_Expressions.UML_String_Expression_Access is
188   begin
189      return
190        AMF.UML.String_Expressions.UML_String_Expression_Access
191         (AMF.Internals.Helpers.To_Element
192           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
193             (Self.Element)));
194   end Get_Name_Expression;
195
196   -------------------------
197   -- Set_Name_Expression --
198   -------------------------
199
200   overriding procedure Set_Name_Expression
201    (Self : not null access UML_Instance_Value_Proxy;
202     To   : AMF.UML.String_Expressions.UML_String_Expression_Access) is
203   begin
204      AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
205       (Self.Element,
206        AMF.Internals.Helpers.To_Element
207         (AMF.Elements.Element_Access (To)));
208   end Set_Name_Expression;
209
210   -------------------
211   -- Get_Namespace --
212   -------------------
213
214   overriding function Get_Namespace
215    (Self : not null access constant UML_Instance_Value_Proxy)
216       return AMF.UML.Namespaces.UML_Namespace_Access is
217   begin
218      return
219        AMF.UML.Namespaces.UML_Namespace_Access
220         (AMF.Internals.Helpers.To_Element
221           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
222             (Self.Element)));
223   end Get_Namespace;
224
225   ------------------------
226   -- Get_Qualified_Name --
227   ------------------------
228
229   overriding function Get_Qualified_Name
230    (Self : not null access constant UML_Instance_Value_Proxy)
231       return AMF.Optional_String is
232   begin
233      declare
234         use type Matreshka.Internals.Strings.Shared_String_Access;
235
236         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
237           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
238
239      begin
240         if Aux = null then
241            return (Is_Empty => True);
242
243         else
244            return (False, League.Strings.Internals.Create (Aux));
245         end if;
246      end;
247   end Get_Qualified_Name;
248
249   -----------------------------------
250   -- Get_Owning_Template_Parameter --
251   -----------------------------------
252
253   overriding function Get_Owning_Template_Parameter
254    (Self : not null access constant UML_Instance_Value_Proxy)
255       return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
256   begin
257      return
258        AMF.UML.Template_Parameters.UML_Template_Parameter_Access
259         (AMF.Internals.Helpers.To_Element
260           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Owning_Template_Parameter
261             (Self.Element)));
262   end Get_Owning_Template_Parameter;
263
264   -----------------------------------
265   -- Set_Owning_Template_Parameter --
266   -----------------------------------
267
268   overriding procedure Set_Owning_Template_Parameter
269    (Self : not null access UML_Instance_Value_Proxy;
270     To   : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
271   begin
272      AMF.Internals.Tables.UML_Attributes.Internal_Set_Owning_Template_Parameter
273       (Self.Element,
274        AMF.Internals.Helpers.To_Element
275         (AMF.Elements.Element_Access (To)));
276   end Set_Owning_Template_Parameter;
277
278   ----------------------------
279   -- Get_Template_Parameter --
280   ----------------------------
281
282   overriding function Get_Template_Parameter
283    (Self : not null access constant UML_Instance_Value_Proxy)
284       return AMF.UML.Template_Parameters.UML_Template_Parameter_Access is
285   begin
286      return
287        AMF.UML.Template_Parameters.UML_Template_Parameter_Access
288         (AMF.Internals.Helpers.To_Element
289           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Template_Parameter
290             (Self.Element)));
291   end Get_Template_Parameter;
292
293   ----------------------------
294   -- Set_Template_Parameter --
295   ----------------------------
296
297   overriding procedure Set_Template_Parameter
298    (Self : not null access UML_Instance_Value_Proxy;
299     To   : AMF.UML.Template_Parameters.UML_Template_Parameter_Access) is
300   begin
301      AMF.Internals.Tables.UML_Attributes.Internal_Set_Template_Parameter
302       (Self.Element,
303        AMF.Internals.Helpers.To_Element
304         (AMF.Elements.Element_Access (To)));
305   end Set_Template_Parameter;
306
307   -------------------
308   -- Boolean_Value --
309   -------------------
310
311   overriding function Boolean_Value
312    (Self : not null access constant UML_Instance_Value_Proxy)
313       return AMF.Optional_Boolean is
314   begin
315      --  Generated stub: replace with real body!
316      pragma Compile_Time_Warning (Standard.True, "Boolean_Value unimplemented");
317      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Boolean_Value";
318      return Boolean_Value (Self);
319   end Boolean_Value;
320
321   -------------------
322   -- Integer_Value --
323   -------------------
324
325   overriding function Integer_Value
326    (Self : not null access constant UML_Instance_Value_Proxy)
327       return AMF.Optional_Integer is
328   begin
329      --  Generated stub: replace with real body!
330      pragma Compile_Time_Warning (Standard.True, "Integer_Value unimplemented");
331      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Integer_Value";
332      return Integer_Value (Self);
333   end Integer_Value;
334
335   ------------------------
336   -- Is_Compatible_With --
337   ------------------------
338
339   overriding function Is_Compatible_With
340    (Self : not null access constant UML_Instance_Value_Proxy;
341     P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access)
342       return Boolean is
343   begin
344      --  Generated stub: replace with real body!
345      pragma Compile_Time_Warning (Standard.True, "Is_Compatible_With unimplemented");
346      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Is_Compatible_With";
347      return Is_Compatible_With (Self, P);
348   end Is_Compatible_With;
349
350   -------------------
351   -- Is_Computable --
352   -------------------
353
354   overriding function Is_Computable
355    (Self : not null access constant UML_Instance_Value_Proxy)
356       return Boolean is
357   begin
358      --  Generated stub: replace with real body!
359      pragma Compile_Time_Warning (Standard.True, "Is_Computable unimplemented");
360      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Is_Computable";
361      return Is_Computable (Self);
362   end Is_Computable;
363
364   -------------
365   -- Is_Null --
366   -------------
367
368   overriding function Is_Null
369    (Self : not null access constant UML_Instance_Value_Proxy)
370       return Boolean is
371   begin
372      --  Generated stub: replace with real body!
373      pragma Compile_Time_Warning (Standard.True, "Is_Null unimplemented");
374      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Is_Null";
375      return Is_Null (Self);
376   end Is_Null;
377
378   ----------------
379   -- Real_Value --
380   ----------------
381
382   overriding function Real_Value
383    (Self : not null access constant UML_Instance_Value_Proxy)
384       return AMF.Optional_Real is
385   begin
386      --  Generated stub: replace with real body!
387      pragma Compile_Time_Warning (Standard.True, "Real_Value unimplemented");
388      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Real_Value";
389      return Real_Value (Self);
390   end Real_Value;
391
392   ------------------
393   -- String_Value --
394   ------------------
395
396   overriding function String_Value
397    (Self : not null access constant UML_Instance_Value_Proxy)
398       return AMF.Optional_String is
399   begin
400      --  Generated stub: replace with real body!
401      pragma Compile_Time_Warning (Standard.True, "String_Value unimplemented");
402      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.String_Value";
403      return String_Value (Self);
404   end String_Value;
405
406   ---------------------
407   -- Unlimited_Value --
408   ---------------------
409
410   overriding function Unlimited_Value
411    (Self : not null access constant UML_Instance_Value_Proxy)
412       return AMF.Optional_Unlimited_Natural is
413   begin
414      --  Generated stub: replace with real body!
415      pragma Compile_Time_Warning (Standard.True, "Unlimited_Value unimplemented");
416      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Unlimited_Value";
417      return Unlimited_Value (Self);
418   end Unlimited_Value;
419
420   -------------------------
421   -- All_Owning_Packages --
422   -------------------------
423
424   overriding function All_Owning_Packages
425    (Self : not null access constant UML_Instance_Value_Proxy)
426       return AMF.UML.Packages.Collections.Set_Of_UML_Package is
427   begin
428      --  Generated stub: replace with real body!
429      pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
430      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.All_Owning_Packages";
431      return All_Owning_Packages (Self);
432   end All_Owning_Packages;
433
434   -----------------------------
435   -- Is_Distinguishable_From --
436   -----------------------------
437
438   overriding function Is_Distinguishable_From
439    (Self : not null access constant UML_Instance_Value_Proxy;
440     N : AMF.UML.Named_Elements.UML_Named_Element_Access;
441     Ns : AMF.UML.Namespaces.UML_Namespace_Access)
442       return Boolean is
443   begin
444      --  Generated stub: replace with real body!
445      pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
446      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Is_Distinguishable_From";
447      return Is_Distinguishable_From (Self, N, Ns);
448   end Is_Distinguishable_From;
449
450   ---------------
451   -- Namespace --
452   ---------------
453
454   overriding function Namespace
455    (Self : not null access constant UML_Instance_Value_Proxy)
456       return AMF.UML.Namespaces.UML_Namespace_Access is
457   begin
458      --  Generated stub: replace with real body!
459      pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
460      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Namespace";
461      return Namespace (Self);
462   end Namespace;
463
464   ---------------------------
465   -- Is_Template_Parameter --
466   ---------------------------
467
468   overriding function Is_Template_Parameter
469    (Self : not null access constant UML_Instance_Value_Proxy)
470       return Boolean is
471   begin
472      --  Generated stub: replace with real body!
473      pragma Compile_Time_Warning (Standard.True, "Is_Template_Parameter unimplemented");
474      raise Program_Error with "Unimplemented procedure UML_Instance_Value_Proxy.Is_Template_Parameter";
475      return Is_Template_Parameter (Self);
476   end Is_Template_Parameter;
477
478end AMF.Internals.UML_Instance_Values;
479