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_Control_Flows is
54
55   -------------------
56   -- Enter_Element --
57   -------------------
58
59   overriding procedure Enter_Element
60    (Self    : not null access constant UML_Control_Flow_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_Control_Flow
67            (AMF.UML.Control_Flows.UML_Control_Flow_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_Control_Flow_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_Control_Flow
84            (AMF.UML.Control_Flows.UML_Control_Flow_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_Control_Flow_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_Control_Flow
102            (Visitor,
103             AMF.UML.Control_Flows.UML_Control_Flow_Access (Self),
104             Control);
105      end if;
106   end Visit_Element;
107
108   ------------------
109   -- Get_Activity --
110   ------------------
111
112   overriding function Get_Activity
113    (Self : not null access constant UML_Control_Flow_Proxy)
114       return AMF.UML.Activities.UML_Activity_Access is
115   begin
116      return
117        AMF.UML.Activities.UML_Activity_Access
118         (AMF.Internals.Helpers.To_Element
119           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Activity
120             (Self.Element)));
121   end Get_Activity;
122
123   ------------------
124   -- Set_Activity --
125   ------------------
126
127   overriding procedure Set_Activity
128    (Self : not null access UML_Control_Flow_Proxy;
129     To   : AMF.UML.Activities.UML_Activity_Access) is
130   begin
131      AMF.Internals.Tables.UML_Attributes.Internal_Set_Activity
132       (Self.Element,
133        AMF.Internals.Helpers.To_Element
134         (AMF.Elements.Element_Access (To)));
135   end Set_Activity;
136
137   ---------------
138   -- Get_Guard --
139   ---------------
140
141   overriding function Get_Guard
142    (Self : not null access constant UML_Control_Flow_Proxy)
143       return AMF.UML.Value_Specifications.UML_Value_Specification_Access is
144   begin
145      return
146        AMF.UML.Value_Specifications.UML_Value_Specification_Access
147         (AMF.Internals.Helpers.To_Element
148           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Guard
149             (Self.Element)));
150   end Get_Guard;
151
152   ---------------
153   -- Set_Guard --
154   ---------------
155
156   overriding procedure Set_Guard
157    (Self : not null access UML_Control_Flow_Proxy;
158     To   : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is
159   begin
160      AMF.Internals.Tables.UML_Attributes.Internal_Set_Guard
161       (Self.Element,
162        AMF.Internals.Helpers.To_Element
163         (AMF.Elements.Element_Access (To)));
164   end Set_Guard;
165
166   ------------------
167   -- Get_In_Group --
168   ------------------
169
170   overriding function Get_In_Group
171    (Self : not null access constant UML_Control_Flow_Proxy)
172       return AMF.UML.Activity_Groups.Collections.Set_Of_UML_Activity_Group is
173   begin
174      return
175        AMF.UML.Activity_Groups.Collections.Wrap
176         (AMF.Internals.Element_Collections.Wrap
177           (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Group
178             (Self.Element)));
179   end Get_In_Group;
180
181   ----------------------
182   -- Get_In_Partition --
183   ----------------------
184
185   overriding function Get_In_Partition
186    (Self : not null access constant UML_Control_Flow_Proxy)
187       return AMF.UML.Activity_Partitions.Collections.Set_Of_UML_Activity_Partition is
188   begin
189      return
190        AMF.UML.Activity_Partitions.Collections.Wrap
191         (AMF.Internals.Element_Collections.Wrap
192           (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Partition
193             (Self.Element)));
194   end Get_In_Partition;
195
196   ----------------------------
197   -- Get_In_Structured_Node --
198   ----------------------------
199
200   overriding function Get_In_Structured_Node
201    (Self : not null access constant UML_Control_Flow_Proxy)
202       return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access is
203   begin
204      return
205        AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access
206         (AMF.Internals.Helpers.To_Element
207           (AMF.Internals.Tables.UML_Attributes.Internal_Get_In_Structured_Node
208             (Self.Element)));
209   end Get_In_Structured_Node;
210
211   ----------------------------
212   -- Set_In_Structured_Node --
213   ----------------------------
214
215   overriding procedure Set_In_Structured_Node
216    (Self : not null access UML_Control_Flow_Proxy;
217     To   : AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access) is
218   begin
219      AMF.Internals.Tables.UML_Attributes.Internal_Set_In_Structured_Node
220       (Self.Element,
221        AMF.Internals.Helpers.To_Element
222         (AMF.Elements.Element_Access (To)));
223   end Set_In_Structured_Node;
224
225   --------------------
226   -- Get_Interrupts --
227   --------------------
228
229   overriding function Get_Interrupts
230    (Self : not null access constant UML_Control_Flow_Proxy)
231       return AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access is
232   begin
233      return
234        AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access
235         (AMF.Internals.Helpers.To_Element
236           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Interrupts
237             (Self.Element)));
238   end Get_Interrupts;
239
240   --------------------
241   -- Set_Interrupts --
242   --------------------
243
244   overriding procedure Set_Interrupts
245    (Self : not null access UML_Control_Flow_Proxy;
246     To   : AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access) is
247   begin
248      AMF.Internals.Tables.UML_Attributes.Internal_Set_Interrupts
249       (Self.Element,
250        AMF.Internals.Helpers.To_Element
251         (AMF.Elements.Element_Access (To)));
252   end Set_Interrupts;
253
254   ------------------------
255   -- Get_Redefined_Edge --
256   ------------------------
257
258   overriding function Get_Redefined_Edge
259    (Self : not null access constant UML_Control_Flow_Proxy)
260       return AMF.UML.Activity_Edges.Collections.Set_Of_UML_Activity_Edge is
261   begin
262      return
263        AMF.UML.Activity_Edges.Collections.Wrap
264         (AMF.Internals.Element_Collections.Wrap
265           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Edge
266             (Self.Element)));
267   end Get_Redefined_Edge;
268
269   ----------------
270   -- Get_Source --
271   ----------------
272
273   overriding function Get_Source
274    (Self : not null access constant UML_Control_Flow_Proxy)
275       return AMF.UML.Activity_Nodes.UML_Activity_Node_Access is
276   begin
277      return
278        AMF.UML.Activity_Nodes.UML_Activity_Node_Access
279         (AMF.Internals.Helpers.To_Element
280           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Source
281             (Self.Element)));
282   end Get_Source;
283
284   ----------------
285   -- Set_Source --
286   ----------------
287
288   overriding procedure Set_Source
289    (Self : not null access UML_Control_Flow_Proxy;
290     To   : AMF.UML.Activity_Nodes.UML_Activity_Node_Access) is
291   begin
292      AMF.Internals.Tables.UML_Attributes.Internal_Set_Source
293       (Self.Element,
294        AMF.Internals.Helpers.To_Element
295         (AMF.Elements.Element_Access (To)));
296   end Set_Source;
297
298   ----------------
299   -- Get_Target --
300   ----------------
301
302   overriding function Get_Target
303    (Self : not null access constant UML_Control_Flow_Proxy)
304       return AMF.UML.Activity_Nodes.UML_Activity_Node_Access is
305   begin
306      return
307        AMF.UML.Activity_Nodes.UML_Activity_Node_Access
308         (AMF.Internals.Helpers.To_Element
309           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Target
310             (Self.Element)));
311   end Get_Target;
312
313   ----------------
314   -- Set_Target --
315   ----------------
316
317   overriding procedure Set_Target
318    (Self : not null access UML_Control_Flow_Proxy;
319     To   : AMF.UML.Activity_Nodes.UML_Activity_Node_Access) is
320   begin
321      AMF.Internals.Tables.UML_Attributes.Internal_Set_Target
322       (Self.Element,
323        AMF.Internals.Helpers.To_Element
324         (AMF.Elements.Element_Access (To)));
325   end Set_Target;
326
327   ----------------
328   -- Get_Weight --
329   ----------------
330
331   overriding function Get_Weight
332    (Self : not null access constant UML_Control_Flow_Proxy)
333       return AMF.UML.Value_Specifications.UML_Value_Specification_Access is
334   begin
335      return
336        AMF.UML.Value_Specifications.UML_Value_Specification_Access
337         (AMF.Internals.Helpers.To_Element
338           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Weight
339             (Self.Element)));
340   end Get_Weight;
341
342   ----------------
343   -- Set_Weight --
344   ----------------
345
346   overriding procedure Set_Weight
347    (Self : not null access UML_Control_Flow_Proxy;
348     To   : AMF.UML.Value_Specifications.UML_Value_Specification_Access) is
349   begin
350      AMF.Internals.Tables.UML_Attributes.Internal_Set_Weight
351       (Self.Element,
352        AMF.Internals.Helpers.To_Element
353         (AMF.Elements.Element_Access (To)));
354   end Set_Weight;
355
356   -----------------
357   -- Get_Is_Leaf --
358   -----------------
359
360   overriding function Get_Is_Leaf
361    (Self : not null access constant UML_Control_Flow_Proxy)
362       return Boolean is
363   begin
364      return
365        AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Leaf
366         (Self.Element);
367   end Get_Is_Leaf;
368
369   -----------------
370   -- Set_Is_Leaf --
371   -----------------
372
373   overriding procedure Set_Is_Leaf
374    (Self : not null access UML_Control_Flow_Proxy;
375     To   : Boolean) is
376   begin
377      AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Leaf
378       (Self.Element, To);
379   end Set_Is_Leaf;
380
381   ---------------------------
382   -- Get_Redefined_Element --
383   ---------------------------
384
385   overriding function Get_Redefined_Element
386    (Self : not null access constant UML_Control_Flow_Proxy)
387       return AMF.UML.Redefinable_Elements.Collections.Set_Of_UML_Redefinable_Element is
388   begin
389      return
390        AMF.UML.Redefinable_Elements.Collections.Wrap
391         (AMF.Internals.Element_Collections.Wrap
392           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefined_Element
393             (Self.Element)));
394   end Get_Redefined_Element;
395
396   ------------------------------
397   -- Get_Redefinition_Context --
398   ------------------------------
399
400   overriding function Get_Redefinition_Context
401    (Self : not null access constant UML_Control_Flow_Proxy)
402       return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is
403   begin
404      return
405        AMF.UML.Classifiers.Collections.Wrap
406         (AMF.Internals.Element_Collections.Wrap
407           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Redefinition_Context
408             (Self.Element)));
409   end Get_Redefinition_Context;
410
411   ---------------------------
412   -- Get_Client_Dependency --
413   ---------------------------
414
415   overriding function Get_Client_Dependency
416    (Self : not null access constant UML_Control_Flow_Proxy)
417       return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
418   begin
419      return
420        AMF.UML.Dependencies.Collections.Wrap
421         (AMF.Internals.Element_Collections.Wrap
422           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
423             (Self.Element)));
424   end Get_Client_Dependency;
425
426   -------------------------
427   -- Get_Name_Expression --
428   -------------------------
429
430   overriding function Get_Name_Expression
431    (Self : not null access constant UML_Control_Flow_Proxy)
432       return AMF.UML.String_Expressions.UML_String_Expression_Access is
433   begin
434      return
435        AMF.UML.String_Expressions.UML_String_Expression_Access
436         (AMF.Internals.Helpers.To_Element
437           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
438             (Self.Element)));
439   end Get_Name_Expression;
440
441   -------------------------
442   -- Set_Name_Expression --
443   -------------------------
444
445   overriding procedure Set_Name_Expression
446    (Self : not null access UML_Control_Flow_Proxy;
447     To   : AMF.UML.String_Expressions.UML_String_Expression_Access) is
448   begin
449      AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
450       (Self.Element,
451        AMF.Internals.Helpers.To_Element
452         (AMF.Elements.Element_Access (To)));
453   end Set_Name_Expression;
454
455   -------------------
456   -- Get_Namespace --
457   -------------------
458
459   overriding function Get_Namespace
460    (Self : not null access constant UML_Control_Flow_Proxy)
461       return AMF.UML.Namespaces.UML_Namespace_Access is
462   begin
463      return
464        AMF.UML.Namespaces.UML_Namespace_Access
465         (AMF.Internals.Helpers.To_Element
466           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
467             (Self.Element)));
468   end Get_Namespace;
469
470   ------------------------
471   -- Get_Qualified_Name --
472   ------------------------
473
474   overriding function Get_Qualified_Name
475    (Self : not null access constant UML_Control_Flow_Proxy)
476       return AMF.Optional_String is
477   begin
478      declare
479         use type Matreshka.Internals.Strings.Shared_String_Access;
480
481         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
482           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
483
484      begin
485         if Aux = null then
486            return (Is_Empty => True);
487
488         else
489            return (False, League.Strings.Internals.Create (Aux));
490         end if;
491      end;
492   end Get_Qualified_Name;
493
494   ------------------------
495   -- Is_Consistent_With --
496   ------------------------
497
498   overriding function Is_Consistent_With
499    (Self : not null access constant UML_Control_Flow_Proxy;
500     Redefinee : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
501       return Boolean is
502   begin
503      --  Generated stub: replace with real body!
504      pragma Compile_Time_Warning (Standard.True, "Is_Consistent_With unimplemented");
505      raise Program_Error with "Unimplemented procedure UML_Control_Flow_Proxy.Is_Consistent_With";
506      return Is_Consistent_With (Self, Redefinee);
507   end Is_Consistent_With;
508
509   -----------------------------------
510   -- Is_Redefinition_Context_Valid --
511   -----------------------------------
512
513   overriding function Is_Redefinition_Context_Valid
514    (Self : not null access constant UML_Control_Flow_Proxy;
515     Redefined : AMF.UML.Redefinable_Elements.UML_Redefinable_Element_Access)
516       return Boolean is
517   begin
518      --  Generated stub: replace with real body!
519      pragma Compile_Time_Warning (Standard.True, "Is_Redefinition_Context_Valid unimplemented");
520      raise Program_Error with "Unimplemented procedure UML_Control_Flow_Proxy.Is_Redefinition_Context_Valid";
521      return Is_Redefinition_Context_Valid (Self, Redefined);
522   end Is_Redefinition_Context_Valid;
523
524   -------------------------
525   -- All_Owning_Packages --
526   -------------------------
527
528   overriding function All_Owning_Packages
529    (Self : not null access constant UML_Control_Flow_Proxy)
530       return AMF.UML.Packages.Collections.Set_Of_UML_Package is
531   begin
532      --  Generated stub: replace with real body!
533      pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
534      raise Program_Error with "Unimplemented procedure UML_Control_Flow_Proxy.All_Owning_Packages";
535      return All_Owning_Packages (Self);
536   end All_Owning_Packages;
537
538   -----------------------------
539   -- Is_Distinguishable_From --
540   -----------------------------
541
542   overriding function Is_Distinguishable_From
543    (Self : not null access constant UML_Control_Flow_Proxy;
544     N : AMF.UML.Named_Elements.UML_Named_Element_Access;
545     Ns : AMF.UML.Namespaces.UML_Namespace_Access)
546       return Boolean is
547   begin
548      --  Generated stub: replace with real body!
549      pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
550      raise Program_Error with "Unimplemented procedure UML_Control_Flow_Proxy.Is_Distinguishable_From";
551      return Is_Distinguishable_From (Self, N, Ns);
552   end Is_Distinguishable_From;
553
554   ---------------
555   -- Namespace --
556   ---------------
557
558   overriding function Namespace
559    (Self : not null access constant UML_Control_Flow_Proxy)
560       return AMF.UML.Namespaces.UML_Namespace_Access is
561   begin
562      --  Generated stub: replace with real body!
563      pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
564      raise Program_Error with "Unimplemented procedure UML_Control_Flow_Proxy.Namespace";
565      return Namespace (Self);
566   end Namespace;
567
568end AMF.Internals.UML_Control_Flows;
569