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_Occurrence_Specifications is
54
55   -------------------
56   -- Enter_Element --
57   -------------------
58
59   overriding procedure Enter_Element
60    (Self    : not null access constant UML_Occurrence_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_Occurrence_Specification
67            (AMF.UML.Occurrence_Specifications.UML_Occurrence_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_Occurrence_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_Occurrence_Specification
84            (AMF.UML.Occurrence_Specifications.UML_Occurrence_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_Occurrence_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_Occurrence_Specification
102            (Visitor,
103             AMF.UML.Occurrence_Specifications.UML_Occurrence_Specification_Access (Self),
104             Control);
105      end if;
106   end Visit_Element;
107
108   -----------------
109   -- Get_Covered --
110   -----------------
111
112   overriding function Get_Covered
113    (Self : not null access constant UML_Occurrence_Specification_Proxy)
114       return AMF.UML.Lifelines.UML_Lifeline_Access is
115   begin
116      raise Program_Error;
117      return Get_Covered (Self);
118   end Get_Covered;
119
120   -----------------
121   -- Set_Covered --
122   -----------------
123
124   overriding procedure Set_Covered
125    (Self : not null access UML_Occurrence_Specification_Proxy;
126     To   : AMF.UML.Lifelines.UML_Lifeline_Access) is
127   begin
128      raise Program_Error;
129   end Set_Covered;
130
131   ------------------
132   -- Get_To_After --
133   ------------------
134
135   overriding function Get_To_After
136    (Self : not null access constant UML_Occurrence_Specification_Proxy)
137       return AMF.UML.General_Orderings.Collections.Set_Of_UML_General_Ordering is
138   begin
139      return
140        AMF.UML.General_Orderings.Collections.Wrap
141         (AMF.Internals.Element_Collections.Wrap
142           (AMF.Internals.Tables.UML_Attributes.Internal_Get_To_After
143             (Self.Element)));
144   end Get_To_After;
145
146   -------------------
147   -- Get_To_Before --
148   -------------------
149
150   overriding function Get_To_Before
151    (Self : not null access constant UML_Occurrence_Specification_Proxy)
152       return AMF.UML.General_Orderings.Collections.Set_Of_UML_General_Ordering is
153   begin
154      return
155        AMF.UML.General_Orderings.Collections.Wrap
156         (AMF.Internals.Element_Collections.Wrap
157           (AMF.Internals.Tables.UML_Attributes.Internal_Get_To_Before
158             (Self.Element)));
159   end Get_To_Before;
160
161   -----------------
162   -- Get_Covered --
163   -----------------
164
165   overriding function Get_Covered
166    (Self : not null access constant UML_Occurrence_Specification_Proxy)
167       return AMF.UML.Lifelines.Collections.Set_Of_UML_Lifeline is
168   begin
169      return
170        AMF.UML.Lifelines.Collections.Wrap
171         (AMF.Internals.Element_Collections.Wrap
172           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Covered
173             (Self.Element)));
174   end Get_Covered;
175
176   -------------------------------
177   -- Get_Enclosing_Interaction --
178   -------------------------------
179
180   overriding function Get_Enclosing_Interaction
181    (Self : not null access constant UML_Occurrence_Specification_Proxy)
182       return AMF.UML.Interactions.UML_Interaction_Access is
183   begin
184      return
185        AMF.UML.Interactions.UML_Interaction_Access
186         (AMF.Internals.Helpers.To_Element
187           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Enclosing_Interaction
188             (Self.Element)));
189   end Get_Enclosing_Interaction;
190
191   -------------------------------
192   -- Set_Enclosing_Interaction --
193   -------------------------------
194
195   overriding procedure Set_Enclosing_Interaction
196    (Self : not null access UML_Occurrence_Specification_Proxy;
197     To   : AMF.UML.Interactions.UML_Interaction_Access) is
198   begin
199      AMF.Internals.Tables.UML_Attributes.Internal_Set_Enclosing_Interaction
200       (Self.Element,
201        AMF.Internals.Helpers.To_Element
202         (AMF.Elements.Element_Access (To)));
203   end Set_Enclosing_Interaction;
204
205   ---------------------------
206   -- Get_Enclosing_Operand --
207   ---------------------------
208
209   overriding function Get_Enclosing_Operand
210    (Self : not null access constant UML_Occurrence_Specification_Proxy)
211       return AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access is
212   begin
213      return
214        AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access
215         (AMF.Internals.Helpers.To_Element
216           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Enclosing_Operand
217             (Self.Element)));
218   end Get_Enclosing_Operand;
219
220   ---------------------------
221   -- Set_Enclosing_Operand --
222   ---------------------------
223
224   overriding procedure Set_Enclosing_Operand
225    (Self : not null access UML_Occurrence_Specification_Proxy;
226     To   : AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access) is
227   begin
228      AMF.Internals.Tables.UML_Attributes.Internal_Set_Enclosing_Operand
229       (Self.Element,
230        AMF.Internals.Helpers.To_Element
231         (AMF.Elements.Element_Access (To)));
232   end Set_Enclosing_Operand;
233
234   --------------------------
235   -- Get_General_Ordering --
236   --------------------------
237
238   overriding function Get_General_Ordering
239    (Self : not null access constant UML_Occurrence_Specification_Proxy)
240       return AMF.UML.General_Orderings.Collections.Set_Of_UML_General_Ordering is
241   begin
242      return
243        AMF.UML.General_Orderings.Collections.Wrap
244         (AMF.Internals.Element_Collections.Wrap
245           (AMF.Internals.Tables.UML_Attributes.Internal_Get_General_Ordering
246             (Self.Element)));
247   end Get_General_Ordering;
248
249   ---------------------------
250   -- Get_Client_Dependency --
251   ---------------------------
252
253   overriding function Get_Client_Dependency
254    (Self : not null access constant UML_Occurrence_Specification_Proxy)
255       return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
256   begin
257      return
258        AMF.UML.Dependencies.Collections.Wrap
259         (AMF.Internals.Element_Collections.Wrap
260           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
261             (Self.Element)));
262   end Get_Client_Dependency;
263
264   -------------------------
265   -- Get_Name_Expression --
266   -------------------------
267
268   overriding function Get_Name_Expression
269    (Self : not null access constant UML_Occurrence_Specification_Proxy)
270       return AMF.UML.String_Expressions.UML_String_Expression_Access is
271   begin
272      return
273        AMF.UML.String_Expressions.UML_String_Expression_Access
274         (AMF.Internals.Helpers.To_Element
275           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
276             (Self.Element)));
277   end Get_Name_Expression;
278
279   -------------------------
280   -- Set_Name_Expression --
281   -------------------------
282
283   overriding procedure Set_Name_Expression
284    (Self : not null access UML_Occurrence_Specification_Proxy;
285     To   : AMF.UML.String_Expressions.UML_String_Expression_Access) is
286   begin
287      AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
288       (Self.Element,
289        AMF.Internals.Helpers.To_Element
290         (AMF.Elements.Element_Access (To)));
291   end Set_Name_Expression;
292
293   -------------------
294   -- Get_Namespace --
295   -------------------
296
297   overriding function Get_Namespace
298    (Self : not null access constant UML_Occurrence_Specification_Proxy)
299       return AMF.UML.Namespaces.UML_Namespace_Access is
300   begin
301      return
302        AMF.UML.Namespaces.UML_Namespace_Access
303         (AMF.Internals.Helpers.To_Element
304           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
305             (Self.Element)));
306   end Get_Namespace;
307
308   ------------------------
309   -- Get_Qualified_Name --
310   ------------------------
311
312   overriding function Get_Qualified_Name
313    (Self : not null access constant UML_Occurrence_Specification_Proxy)
314       return AMF.Optional_String is
315   begin
316      declare
317         use type Matreshka.Internals.Strings.Shared_String_Access;
318
319         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
320           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
321
322      begin
323         if Aux = null then
324            return (Is_Empty => True);
325
326         else
327            return (False, League.Strings.Internals.Create (Aux));
328         end if;
329      end;
330   end Get_Qualified_Name;
331
332   -------------------------
333   -- All_Owning_Packages --
334   -------------------------
335
336   overriding function All_Owning_Packages
337    (Self : not null access constant UML_Occurrence_Specification_Proxy)
338       return AMF.UML.Packages.Collections.Set_Of_UML_Package is
339   begin
340      --  Generated stub: replace with real body!
341      pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
342      raise Program_Error with "Unimplemented procedure UML_Occurrence_Specification_Proxy.All_Owning_Packages";
343      return All_Owning_Packages (Self);
344   end All_Owning_Packages;
345
346   -----------------------------
347   -- Is_Distinguishable_From --
348   -----------------------------
349
350   overriding function Is_Distinguishable_From
351    (Self : not null access constant UML_Occurrence_Specification_Proxy;
352     N : AMF.UML.Named_Elements.UML_Named_Element_Access;
353     Ns : AMF.UML.Namespaces.UML_Namespace_Access)
354       return Boolean is
355   begin
356      --  Generated stub: replace with real body!
357      pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
358      raise Program_Error with "Unimplemented procedure UML_Occurrence_Specification_Proxy.Is_Distinguishable_From";
359      return Is_Distinguishable_From (Self, N, Ns);
360   end Is_Distinguishable_From;
361
362   ---------------
363   -- Namespace --
364   ---------------
365
366   overriding function Namespace
367    (Self : not null access constant UML_Occurrence_Specification_Proxy)
368       return AMF.UML.Namespaces.UML_Namespace_Access is
369   begin
370      --  Generated stub: replace with real body!
371      pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
372      raise Program_Error with "Unimplemented procedure UML_Occurrence_Specification_Proxy.Namespace";
373      return Namespace (Self);
374   end Namespace;
375
376end AMF.Internals.UML_Occurrence_Specifications;
377