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