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: 3435 $ $Date: 2012-11-14 08:26:06 +0400 (Wed, 14 Nov 2012) $ 43------------------------------------------------------------------------------ 44with AMF.Internals.Element_Collections; 45with AMF.Internals.Tables.DI_Metamodel; 46with AMF.Internals.Tables.Standard_Profile_L2_Metamodel; 47with AMF.Internals.Tables.Standard_Profile_L3_Metamodel; 48with AMF.Internals.Tables.UML_Attribute_Mappings; 49with AMF.Internals.Tables.UML_Element_Table; 50with AMF.Internals.Tables.UML_Metamodel; 51with AMF.Internals.Tables.UMLDI_Metamodel; 52 53package body AMF.Internals.Factories.UML_Module_Factory is 54 55 procedure Construct_Union 56 (Element : AMF.Internals.AMF_Element; 57 Property : AMF.Internals.CMOF_Element; 58 Link : AMF.Internals.AMF_Link); 59 60 -------------------- 61 -- Connect_Extent -- 62 -------------------- 63 64 overriding procedure Connect_Extent 65 (Self : not null access constant UML_Module_Factory; 66 Element : AMF.Internals.AMF_Element; 67 Extent : AMF.Internals.AMF_Extent) 68 is 69 pragma Unreferenced (Self); 70 71 begin 72 AMF.Internals.Tables.UML_Element_Table.Table (Element).Extent := Extent; 73 end Connect_Extent; 74 75 ---------------------- 76 -- Connect_Link_End -- 77 ---------------------- 78 79 overriding procedure Connect_Link_End 80 (Self : not null access constant UML_Module_Factory; 81 Element : AMF.Internals.AMF_Element; 82 Property : AMF.Internals.CMOF_Element; 83 Link : AMF.Internals.AMF_Link; 84 Other : AMF.Internals.AMF_Element) 85 is 86 pragma Unreferenced (Self); 87 88 use AMF.Internals.Tables; 89 use AMF.Internals.Tables.DI_Metamodel; 90 use AMF.Internals.Tables.Standard_Profile_L2_Metamodel; 91 use AMF.Internals.Tables.Standard_Profile_L3_Metamodel; 92 use AMF.Internals.Tables.UML_Attribute_Mappings; 93 use AMF.Internals.Tables.UML_Metamodel; 94 use AMF.Internals.Tables.UMLDI_Metamodel; 95 96 begin 97 -- Properties which comes from UML metamodel. 98 99 if Property in MB_UML .. ML_UML then 100 declare 101 PO : constant AMF.Internals.CMOF_Element := Property - MB_UML; 102 103 begin 104 if PO in UML_Collection_Offset'Range (2) then 105 AMF.Internals.Element_Collections.Internal_Append 106 (UML_Element_Table.Table (Element).Member (0).Collection 107 + UML_Collection_Offset 108 (UML_Element_Table.Table (Element).Kind, PO), 109 Other, 110 Link); 111 112 elsif PO in UML_Member_Offset'Range (2) 113 and then UML_Member_Offset 114 (UML_Element_Table.Table (Element).Kind, PO) /= 0 115 then 116 UML_Element_Table.Table (Element).Member 117 (UML_Member_Offset 118 (UML_Element_Table.Table (Element).Kind, PO)).Link := Link; 119 120 else 121 AMF.Internals.Element_Collections.Internal_Append 122 (UML_Element_Table.Table (Element).Member (0).Collection, 123 Other, 124 Link); 125 end if; 126 end; 127 128 elsif Property in MB_Standard_Profile_L2 .. ML_Standard_Profile_L2 then 129 declare 130 PO : constant AMF.Internals.CMOF_Element 131 := Property - MB_Standard_Profile_L2; 132 133 begin 134 if PO in Standard_Profile_L2_Collection_Offset'Range (2) then 135 AMF.Internals.Element_Collections.Internal_Append 136 (UML_Element_Table.Table (Element).Member (0).Collection 137 + Standard_Profile_L2_Collection_Offset 138 (UML_Element_Table.Table (Element).Kind, PO), 139 Other, 140 Link); 141 142 elsif PO in Standard_Profile_L2_Member_Offset'Range (2) 143 and then Standard_Profile_L2_Member_Offset 144 (UML_Element_Table.Table (Element).Kind, PO) /= 0 145 then 146 UML_Element_Table.Table (Element).Member 147 (Standard_Profile_L2_Member_Offset 148 (UML_Element_Table.Table (Element).Kind, PO)).Link := Link; 149 150 else 151 AMF.Internals.Element_Collections.Internal_Append 152 (UML_Element_Table.Table (Element).Member (0).Collection, 153 Other, 154 Link); 155 end if; 156 end; 157 158 elsif Property in MB_Standard_Profile_L3 .. ML_Standard_Profile_L3 then 159 declare 160 PO : constant AMF.Internals.CMOF_Element 161 := Property - MB_Standard_Profile_L3; 162 163 begin 164 if PO in Standard_Profile_L3_Collection_Offset'Range (2) then 165 AMF.Internals.Element_Collections.Internal_Append 166 (UML_Element_Table.Table (Element).Member (0).Collection 167 + Standard_Profile_L3_Collection_Offset 168 (UML_Element_Table.Table (Element).Kind, PO), 169 Other, 170 Link); 171 172 elsif PO in Standard_Profile_L3_Member_Offset'Range (2) 173 and then Standard_Profile_L3_Member_Offset 174 (UML_Element_Table.Table (Element).Kind, PO) /= 0 175 then 176 UML_Element_Table.Table (Element).Member 177 (Standard_Profile_L3_Member_Offset 178 (UML_Element_Table.Table (Element).Kind, PO)).Link := Link; 179 180 else 181 AMF.Internals.Element_Collections.Internal_Append 182 (UML_Element_Table.Table (Element).Member (0).Collection, 183 Other, 184 Link); 185 end if; 186 end; 187 188 elsif Property in MB_DI .. ML_DI then 189 declare 190 PO : constant AMF.Internals.CMOF_Element 191 := Property - MB_DI; 192 193 begin 194 if PO in DI_Collection_Offset'Range (2) then 195 AMF.Internals.Element_Collections.Internal_Append 196 (UML_Element_Table.Table (Element).Member (0).Collection 197 + DI_Collection_Offset 198 (UML_Element_Table.Table (Element).Kind, PO), 199 Other, 200 Link); 201 202 elsif PO in DI_Member_Offset'Range (2) 203 and then DI_Member_Offset 204 (UML_Element_Table.Table (Element).Kind, PO) /= 0 205 then 206 UML_Element_Table.Table (Element).Member 207 (DI_Member_Offset 208 (UML_Element_Table.Table (Element).Kind, PO)).Link := Link; 209 210 else 211 AMF.Internals.Element_Collections.Internal_Append 212 (UML_Element_Table.Table (Element).Member (0).Collection, 213 Other, 214 Link); 215 end if; 216 end; 217 218 elsif Property in MB_UMLDI .. ML_UMLDI then 219 declare 220 PO : constant AMF.Internals.CMOF_Element 221 := Property - MB_UMLDI; 222 223 begin 224 if PO in UMLDI_Collection_Offset'Range (2) then 225 AMF.Internals.Element_Collections.Internal_Append 226 (UML_Element_Table.Table (Element).Member (0).Collection 227 + UMLDI_Collection_Offset 228 (UML_Element_Table.Table (Element).Kind, PO), 229 Other, 230 Link); 231 232 elsif PO in UMLDI_Member_Offset'Range (2) 233 and then UMLDI_Member_Offset 234 (UML_Element_Table.Table (Element).Kind, PO) /= 0 235 then 236 UML_Element_Table.Table (Element).Member 237 (UMLDI_Member_Offset 238 (UML_Element_Table.Table (Element).Kind, PO)).Link := Link; 239 240 else 241 AMF.Internals.Element_Collections.Internal_Append 242 (UML_Element_Table.Table (Element).Member (0).Collection, 243 Other, 244 Link); 245 end if; 246 end; 247 end if; 248 end Connect_Link_End; 249 250 --------------------- 251 -- Construct_Union -- 252 --------------------- 253 254 procedure Construct_Union 255 (Element : AMF.Internals.AMF_Element; 256 Property : AMF.Internals.CMOF_Element; 257 Link : AMF.Internals.AMF_Link) is separate; 258 259 -------------------------- 260 -- Synchronize_Link_Set -- 261 -------------------------- 262 263 overriding procedure Synchronize_Link_Set 264 (Self : not null access constant UML_Module_Factory; 265 Element : AMF.Internals.AMF_Element; 266 Property : AMF.Internals.CMOF_Element; 267 Link : AMF.Internals.AMF_Link) is 268 begin 269 -- Construct derived unions. 270 271 Construct_Union (Element, Property, Link); 272 end Synchronize_Link_Set; 273 274 ---------------- 275 -- To_Element -- 276 ---------------- 277 278 overriding function To_Element 279 (Self : not null access constant UML_Module_Factory; 280 Element : AMF.Internals.AMF_Element) return AMF.Elements.Element_Access 281 is 282 pragma Unreferenced (Self); 283 284 begin 285 return AMF.Internals.Tables.UML_Element_Table.Table (Element).Proxy; 286 end To_Element; 287 288end AMF.Internals.Factories.UML_Module_Factory; 289