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