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_Messages is
54
55   -------------------
56   -- Enter_Element --
57   -------------------
58
59   overriding procedure Enter_Element
60    (Self    : not null access constant UML_Message_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_Message
67            (AMF.UML.Messages.UML_Message_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_Message_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_Message
84            (AMF.UML.Messages.UML_Message_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_Message_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_Message
102            (Visitor,
103             AMF.UML.Messages.UML_Message_Access (Self),
104             Control);
105      end if;
106   end Visit_Element;
107
108   ------------------
109   -- Get_Argument --
110   ------------------
111
112   overriding function Get_Argument
113    (Self : not null access constant UML_Message_Proxy)
114       return AMF.UML.Value_Specifications.Collections.Ordered_Set_Of_UML_Value_Specification is
115   begin
116      return
117        AMF.UML.Value_Specifications.Collections.Wrap
118         (AMF.Internals.Element_Collections.Wrap
119           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Argument
120             (Self.Element)));
121   end Get_Argument;
122
123   -------------------
124   -- Get_Connector --
125   -------------------
126
127   overriding function Get_Connector
128    (Self : not null access constant UML_Message_Proxy)
129       return AMF.UML.Connectors.UML_Connector_Access is
130   begin
131      return
132        AMF.UML.Connectors.UML_Connector_Access
133         (AMF.Internals.Helpers.To_Element
134           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Connector
135             (Self.Element)));
136   end Get_Connector;
137
138   -------------------
139   -- Set_Connector --
140   -------------------
141
142   overriding procedure Set_Connector
143    (Self : not null access UML_Message_Proxy;
144     To   : AMF.UML.Connectors.UML_Connector_Access) is
145   begin
146      AMF.Internals.Tables.UML_Attributes.Internal_Set_Connector
147       (Self.Element,
148        AMF.Internals.Helpers.To_Element
149         (AMF.Elements.Element_Access (To)));
150   end Set_Connector;
151
152   ---------------------
153   -- Get_Interaction --
154   ---------------------
155
156   overriding function Get_Interaction
157    (Self : not null access constant UML_Message_Proxy)
158       return AMF.UML.Interactions.UML_Interaction_Access is
159   begin
160      return
161        AMF.UML.Interactions.UML_Interaction_Access
162         (AMF.Internals.Helpers.To_Element
163           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Interaction
164             (Self.Element)));
165   end Get_Interaction;
166
167   ---------------------
168   -- Set_Interaction --
169   ---------------------
170
171   overriding procedure Set_Interaction
172    (Self : not null access UML_Message_Proxy;
173     To   : AMF.UML.Interactions.UML_Interaction_Access) is
174   begin
175      AMF.Internals.Tables.UML_Attributes.Internal_Set_Interaction
176       (Self.Element,
177        AMF.Internals.Helpers.To_Element
178         (AMF.Elements.Element_Access (To)));
179   end Set_Interaction;
180
181   ----------------------
182   -- Get_Message_Kind --
183   ----------------------
184
185   overriding function Get_Message_Kind
186    (Self : not null access constant UML_Message_Proxy)
187       return AMF.UML.UML_Message_Kind is
188   begin
189      return
190        AMF.Internals.Tables.UML_Attributes.Internal_Get_Message_Kind
191         (Self.Element);
192   end Get_Message_Kind;
193
194   ----------------------
195   -- Get_Message_Sort --
196   ----------------------
197
198   overriding function Get_Message_Sort
199    (Self : not null access constant UML_Message_Proxy)
200       return AMF.UML.UML_Message_Sort is
201   begin
202      return
203        AMF.Internals.Tables.UML_Attributes.Internal_Get_Message_Sort
204         (Self.Element);
205   end Get_Message_Sort;
206
207   ----------------------
208   -- Set_Message_Sort --
209   ----------------------
210
211   overriding procedure Set_Message_Sort
212    (Self : not null access UML_Message_Proxy;
213     To   : AMF.UML.UML_Message_Sort) is
214   begin
215      AMF.Internals.Tables.UML_Attributes.Internal_Set_Message_Sort
216       (Self.Element, To);
217   end Set_Message_Sort;
218
219   -----------------------
220   -- Get_Receive_Event --
221   -----------------------
222
223   overriding function Get_Receive_Event
224    (Self : not null access constant UML_Message_Proxy)
225       return AMF.UML.Message_Ends.UML_Message_End_Access is
226   begin
227      return
228        AMF.UML.Message_Ends.UML_Message_End_Access
229         (AMF.Internals.Helpers.To_Element
230           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Receive_Event
231             (Self.Element)));
232   end Get_Receive_Event;
233
234   -----------------------
235   -- Set_Receive_Event --
236   -----------------------
237
238   overriding procedure Set_Receive_Event
239    (Self : not null access UML_Message_Proxy;
240     To   : AMF.UML.Message_Ends.UML_Message_End_Access) is
241   begin
242      AMF.Internals.Tables.UML_Attributes.Internal_Set_Receive_Event
243       (Self.Element,
244        AMF.Internals.Helpers.To_Element
245         (AMF.Elements.Element_Access (To)));
246   end Set_Receive_Event;
247
248   --------------------
249   -- Get_Send_Event --
250   --------------------
251
252   overriding function Get_Send_Event
253    (Self : not null access constant UML_Message_Proxy)
254       return AMF.UML.Message_Ends.UML_Message_End_Access is
255   begin
256      return
257        AMF.UML.Message_Ends.UML_Message_End_Access
258         (AMF.Internals.Helpers.To_Element
259           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Send_Event
260             (Self.Element)));
261   end Get_Send_Event;
262
263   --------------------
264   -- Set_Send_Event --
265   --------------------
266
267   overriding procedure Set_Send_Event
268    (Self : not null access UML_Message_Proxy;
269     To   : AMF.UML.Message_Ends.UML_Message_End_Access) is
270   begin
271      AMF.Internals.Tables.UML_Attributes.Internal_Set_Send_Event
272       (Self.Element,
273        AMF.Internals.Helpers.To_Element
274         (AMF.Elements.Element_Access (To)));
275   end Set_Send_Event;
276
277   -------------------
278   -- Get_Signature --
279   -------------------
280
281   overriding function Get_Signature
282    (Self : not null access constant UML_Message_Proxy)
283       return AMF.UML.Named_Elements.UML_Named_Element_Access is
284   begin
285      return
286        AMF.UML.Named_Elements.UML_Named_Element_Access
287         (AMF.Internals.Helpers.To_Element
288           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Signature
289             (Self.Element)));
290   end Get_Signature;
291
292   -------------------
293   -- Set_Signature --
294   -------------------
295
296   overriding procedure Set_Signature
297    (Self : not null access UML_Message_Proxy;
298     To   : AMF.UML.Named_Elements.UML_Named_Element_Access) is
299   begin
300      AMF.Internals.Tables.UML_Attributes.Internal_Set_Signature
301       (Self.Element,
302        AMF.Internals.Helpers.To_Element
303         (AMF.Elements.Element_Access (To)));
304   end Set_Signature;
305
306   ---------------------------
307   -- Get_Client_Dependency --
308   ---------------------------
309
310   overriding function Get_Client_Dependency
311    (Self : not null access constant UML_Message_Proxy)
312       return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
313   begin
314      return
315        AMF.UML.Dependencies.Collections.Wrap
316         (AMF.Internals.Element_Collections.Wrap
317           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Client_Dependency
318             (Self.Element)));
319   end Get_Client_Dependency;
320
321   -------------------------
322   -- Get_Name_Expression --
323   -------------------------
324
325   overriding function Get_Name_Expression
326    (Self : not null access constant UML_Message_Proxy)
327       return AMF.UML.String_Expressions.UML_String_Expression_Access is
328   begin
329      return
330        AMF.UML.String_Expressions.UML_String_Expression_Access
331         (AMF.Internals.Helpers.To_Element
332           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Name_Expression
333             (Self.Element)));
334   end Get_Name_Expression;
335
336   -------------------------
337   -- Set_Name_Expression --
338   -------------------------
339
340   overriding procedure Set_Name_Expression
341    (Self : not null access UML_Message_Proxy;
342     To   : AMF.UML.String_Expressions.UML_String_Expression_Access) is
343   begin
344      AMF.Internals.Tables.UML_Attributes.Internal_Set_Name_Expression
345       (Self.Element,
346        AMF.Internals.Helpers.To_Element
347         (AMF.Elements.Element_Access (To)));
348   end Set_Name_Expression;
349
350   -------------------
351   -- Get_Namespace --
352   -------------------
353
354   overriding function Get_Namespace
355    (Self : not null access constant UML_Message_Proxy)
356       return AMF.UML.Namespaces.UML_Namespace_Access is
357   begin
358      return
359        AMF.UML.Namespaces.UML_Namespace_Access
360         (AMF.Internals.Helpers.To_Element
361           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Namespace
362             (Self.Element)));
363   end Get_Namespace;
364
365   ------------------------
366   -- Get_Qualified_Name --
367   ------------------------
368
369   overriding function Get_Qualified_Name
370    (Self : not null access constant UML_Message_Proxy)
371       return AMF.Optional_String is
372   begin
373      declare
374         use type Matreshka.Internals.Strings.Shared_String_Access;
375
376         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
377           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Qualified_Name (Self.Element);
378
379      begin
380         if Aux = null then
381            return (Is_Empty => True);
382
383         else
384            return (False, League.Strings.Internals.Create (Aux));
385         end if;
386      end;
387   end Get_Qualified_Name;
388
389   ------------------
390   -- Message_Kind --
391   ------------------
392
393   overriding function Message_Kind
394    (Self : not null access constant UML_Message_Proxy)
395       return AMF.UML.UML_Message_Kind is
396   begin
397      --  Generated stub: replace with real body!
398      pragma Compile_Time_Warning (Standard.True, "Message_Kind unimplemented");
399      raise Program_Error with "Unimplemented procedure UML_Message_Proxy.Message_Kind";
400      return Message_Kind (Self);
401   end Message_Kind;
402
403   -------------------------
404   -- All_Owning_Packages --
405   -------------------------
406
407   overriding function All_Owning_Packages
408    (Self : not null access constant UML_Message_Proxy)
409       return AMF.UML.Packages.Collections.Set_Of_UML_Package is
410   begin
411      --  Generated stub: replace with real body!
412      pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
413      raise Program_Error with "Unimplemented procedure UML_Message_Proxy.All_Owning_Packages";
414      return All_Owning_Packages (Self);
415   end All_Owning_Packages;
416
417   -----------------------------
418   -- Is_Distinguishable_From --
419   -----------------------------
420
421   overriding function Is_Distinguishable_From
422    (Self : not null access constant UML_Message_Proxy;
423     N : AMF.UML.Named_Elements.UML_Named_Element_Access;
424     Ns : AMF.UML.Namespaces.UML_Namespace_Access)
425       return Boolean is
426   begin
427      --  Generated stub: replace with real body!
428      pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
429      raise Program_Error with "Unimplemented procedure UML_Message_Proxy.Is_Distinguishable_From";
430      return Is_Distinguishable_From (Self, N, Ns);
431   end Is_Distinguishable_From;
432
433   ---------------
434   -- Namespace --
435   ---------------
436
437   overriding function Namespace
438    (Self : not null access constant UML_Message_Proxy)
439       return AMF.UML.Namespaces.UML_Namespace_Access is
440   begin
441      --  Generated stub: replace with real body!
442      pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
443      raise Program_Error with "Unimplemented procedure UML_Message_Proxy.Namespace";
444      return Namespace (Self);
445   end Namespace;
446
447end AMF.Internals.UML_Messages;
448