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