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: 2864 $ $Date: 2012-04-13 14:08:07 +0400 (Fri, 13 Apr 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_Element_Imports is
54
55   -------------------
56   -- Enter_Element --
57   -------------------
58
59   overriding procedure Enter_Element
60    (Self    : not null access constant UML_Element_Import_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_Element_Import
67            (AMF.UML.Element_Imports.UML_Element_Import_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_Element_Import_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_Element_Import
84            (AMF.UML.Element_Imports.UML_Element_Import_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_Element_Import_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_Element_Import
102            (Visitor,
103             AMF.UML.Element_Imports.UML_Element_Import_Access (Self),
104             Control);
105      end if;
106   end Visit_Element;
107
108   ---------------
109   -- Get_Alias --
110   ---------------
111
112   overriding function Get_Alias
113    (Self : not null access constant UML_Element_Import_Proxy)
114       return AMF.Optional_String is
115   begin
116      declare
117         use type Matreshka.Internals.Strings.Shared_String_Access;
118
119         Aux : constant Matreshka.Internals.Strings.Shared_String_Access
120           := AMF.Internals.Tables.UML_Attributes.Internal_Get_Alias (Self.Element);
121
122      begin
123         if Aux = null then
124            return (Is_Empty => True);
125
126         else
127            return (False, League.Strings.Internals.Create (Aux));
128         end if;
129      end;
130   end Get_Alias;
131
132   ---------------
133   -- Set_Alias --
134   ---------------
135
136   overriding procedure Set_Alias
137    (Self : not null access UML_Element_Import_Proxy;
138     To   : AMF.Optional_String) is
139   begin
140      if To.Is_Empty then
141         AMF.Internals.Tables.UML_Attributes.Internal_Set_Alias
142          (Self.Element, null);
143
144      else
145         AMF.Internals.Tables.UML_Attributes.Internal_Set_Alias
146          (Self.Element,
147           League.Strings.Internals.Internal (To.Value));
148      end if;
149   end Set_Alias;
150
151   --------------------------
152   -- Get_Imported_Element --
153   --------------------------
154
155   overriding function Get_Imported_Element
156    (Self : not null access constant UML_Element_Import_Proxy)
157       return AMF.UML.Packageable_Elements.UML_Packageable_Element_Access is
158   begin
159      return
160        AMF.UML.Packageable_Elements.UML_Packageable_Element_Access
161         (AMF.Internals.Helpers.To_Element
162           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Imported_Element
163             (Self.Element)));
164   end Get_Imported_Element;
165
166   --------------------------
167   -- Set_Imported_Element --
168   --------------------------
169
170   overriding procedure Set_Imported_Element
171    (Self : not null access UML_Element_Import_Proxy;
172     To   : AMF.UML.Packageable_Elements.UML_Packageable_Element_Access) is
173   begin
174      AMF.Internals.Tables.UML_Attributes.Internal_Set_Imported_Element
175       (Self.Element,
176        AMF.Internals.Helpers.To_Element
177         (AMF.Elements.Element_Access (To)));
178   end Set_Imported_Element;
179
180   -----------------------------
181   -- Get_Importing_Namespace --
182   -----------------------------
183
184   overriding function Get_Importing_Namespace
185    (Self : not null access constant UML_Element_Import_Proxy)
186       return AMF.UML.Namespaces.UML_Namespace_Access is
187   begin
188      return
189        AMF.UML.Namespaces.UML_Namespace_Access
190         (AMF.Internals.Helpers.To_Element
191           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Importing_Namespace
192             (Self.Element)));
193   end Get_Importing_Namespace;
194
195   -----------------------------
196   -- Set_Importing_Namespace --
197   -----------------------------
198
199   overriding procedure Set_Importing_Namespace
200    (Self : not null access UML_Element_Import_Proxy;
201     To   : AMF.UML.Namespaces.UML_Namespace_Access) is
202   begin
203      AMF.Internals.Tables.UML_Attributes.Internal_Set_Importing_Namespace
204       (Self.Element,
205        AMF.Internals.Helpers.To_Element
206         (AMF.Elements.Element_Access (To)));
207   end Set_Importing_Namespace;
208
209   --------------------
210   -- Get_Visibility --
211   --------------------
212
213   overriding function Get_Visibility
214    (Self : not null access constant UML_Element_Import_Proxy)
215       return AMF.UML.UML_Visibility_Kind is
216   begin
217      return
218        AMF.Internals.Tables.UML_Attributes.Internal_Get_Visibility
219         (Self.Element);
220   end Get_Visibility;
221
222   --------------------
223   -- Set_Visibility --
224   --------------------
225
226   overriding procedure Set_Visibility
227    (Self : not null access UML_Element_Import_Proxy;
228     To   : AMF.UML.UML_Visibility_Kind) is
229   begin
230      AMF.Internals.Tables.UML_Attributes.Internal_Set_Visibility
231       (Self.Element, To);
232   end Set_Visibility;
233
234   ----------------
235   -- Get_Source --
236   ----------------
237
238   overriding function Get_Source
239    (Self : not null access constant UML_Element_Import_Proxy)
240       return AMF.UML.Elements.Collections.Set_Of_UML_Element is
241   begin
242      return
243        AMF.UML.Elements.Collections.Wrap
244         (AMF.Internals.Element_Collections.Wrap
245           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Source
246             (Self.Element)));
247   end Get_Source;
248
249   ----------------
250   -- Get_Target --
251   ----------------
252
253   overriding function Get_Target
254    (Self : not null access constant UML_Element_Import_Proxy)
255       return AMF.UML.Elements.Collections.Set_Of_UML_Element is
256   begin
257      return
258        AMF.UML.Elements.Collections.Wrap
259         (AMF.Internals.Element_Collections.Wrap
260           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Target
261             (Self.Element)));
262   end Get_Target;
263
264   -------------------------
265   -- Get_Related_Element --
266   -------------------------
267
268   overriding function Get_Related_Element
269    (Self : not null access constant UML_Element_Import_Proxy)
270       return AMF.UML.Elements.Collections.Set_Of_UML_Element is
271   begin
272      return
273        AMF.UML.Elements.Collections.Wrap
274         (AMF.Internals.Element_Collections.Wrap
275           (AMF.Internals.Tables.UML_Attributes.Internal_Get_Related_Element
276             (Self.Element)));
277   end Get_Related_Element;
278
279   --------------
280   -- Get_Name --
281   --------------
282
283   overriding function Get_Name
284    (Self : not null access constant UML_Element_Import_Proxy)
285       return League.Strings.Universal_String is
286   begin
287      --  Generated stub: replace with real body!
288      pragma Compile_Time_Warning (Standard.True, "Get_Name unimplemented");
289      raise Program_Error with "Unimplemented procedure UML_Element_Import_Proxy.Get_Name";
290      return Get_Name (Self);
291   end Get_Name;
292
293end AMF.Internals.UML_Element_Imports;
294