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